Introduction
My previous posts have covered exposing OIC integrations as tools. This post goes one step further and looks at creating AI Agents in OIC.
There are a couple of concepts I will cover, before getting to my simple order processing demo.
Let's begin with the Agent Patterns -
Agent Patterns
Patterns provide the guardrails on how agents should go about their tasks. Human agents often have a book of guidelines or a manual they need to internalize, RTFM etc. Ergo, the pattern you choose for your agents can make the difference between effectiveness and pure experimentation. Here are some common integration patterns -
ReAct (Reason & Act)
Seems very plausible, something we should all be doing. We want our agent to think through the problem to be solved and use the tools provided to do that as effectively and efficiently as possible. Constantly reflecting on what has been done and what needs to be done, i.e. alternating between reasoning and acting.
Plan & Execute
In contrast to the reasoning loop, here the AI agent prompts the LLM to generate a complete plan, then executes that plan step by step.
These 2 patterns are currently supported by OIC -
Check out the relevant docs here.
Next, the LLM, the agent's reasoning engine.
LLM
Think of the LLM as the agent's brain. However, the agent is more - it can plan, it has access to tools and it has memory. It is essentially the orchestrator.
Agent Tools
I've already discussed agent tools in previous posts, net, net, tools are used to get the job done. Think of tools that a sales person may have at their disposal e.g. SFDC for managing customers, opportunities etc.
Agents
Human agents are autonomous complex individuals that have the ability to reason, make decisions and use tools to carry out complex tasks. AI Agents are the software equivalent of such.
Human agents work within guidelines, provided by their organization.
AI Agents adhere to guidelines, provided by the agent developer.
With those basics in mind, let's go to the simple demo.
AI Agent for Order Processing
A caveat - this is a simple example, maybe too simple; however, the goal is to show the steps required for creating such in OIC.
Starting point is the following 5 integrations -
Regarding the tools - the names say what they do - Irish customer orders are created in Netsuite via the Create Order Netsuite tool. German orders are pushed to SAP, via the Create Order SAP tool.
The Validate Order tool logic is simple - all orders are valid, except for orders from Irish customers, which have a volume > 50k.
The Check Inventory tool has the following simple logic - all products are in stock except for our exceptional iCar.
Notify Customer sends an email to a customer.
- AI Agents
- Agent Patterns
- Prompt Templates
Let's look at these, one by one -
Agent Patterns
We already discussed the 2 patterns OIC supports; for this use case we will use the ReAct pattern. ReAct = Reasoning and Acting. This pattern enables a stepwise (breaking down a complex task into a series of steps), context-aware (the agent has a memory, enabling it to make smarter and more relevant decisions) approach.Strictly follow all guidelines. It is mandatory that you reflect on all guidelines provided.
1. You should follow the ReAct agent pattern (Reason + Act) when generating a response.
Pattern:
-- Think - using your internal reasoning.
-- Action - Invoke tools to get information, including additional human input.
-- Observe - Process tool response using your internal reasoning.
-- Repeat - Repeat until finished.
2. At each step you provide your think, action, and observe rationale.
3. You should always attempt to get the most relevant information based on tool use.
4. Do not guess or infer tool arguments except for the following reasons:
- You are given specific guidance by the tool on inferring a tool argument.
- You have previous context to make a reasonable assumption.
After saving the Pattern, I notice a new integration and connection have been created in my project -
We will go into the logic of this integration in a later post, but, suffice to say, it is a black box for us now.
The LLM connection is still in draft mode, so I need to enter the relevant details. As you can see, I need to bring my own api key -
AI Agent Creation
Let's look at my Order Processor
agent -
The inputs are as follows:
The agent role -
You are an order processing agent responsible for validating incoming orders.
### Order Processing Steps
#### 1. Validate Order
Use the **Validate Order** tool to check if an order passes our validation rules. If the order is invalid, then use the **Notify Customer** tool to inform the customer. Also include the "message" returned by Validate Order. If an order is invalid, processing stops immediately; in such cases, detail exactly why this order failed validation.
#### 2. Check Inventory
Use the **Check Inventory** tool to check if the product is in stock. If the product is out of stock, use the **Notify Customer** tool to inform the customer. Ensure the "message" passed to the Notify Customer tool is relevant and friendly. Remember, we are razor focused on customer satisfaction. If an order's product is no longer in stock, processing stops immediately; in such cases, detail exactly why this order's processing has been terminated.
#### 3. Create Order in one of our ERP systems
Use the **Create Order SAP** tool to create orders for German customers.
Use the **Create Order Netsuite** tool to create orders for Irish customers
The Tools - here I select the 5 tools available.
Prompt Templates - more about them in a later post, net, net these are reusable templates, where one can ensure consistency etc.
That's all I need now, so let's activate the agent and test it.
Run the Agent
Process the following order - customer is NiallC, customer is from Ireland. customer email address is nnnnnn@gmail.com. The order is for the following product, iBike. Price is 4567
I check out the response -
I check out the response -
Summa Summarum
Again, mea culpa for the simplicity of the use case. We could easily have done this without AI Agents, however, it is a good use case for demoing the mechanics for how to create and run AI Agents in OIC.
