I haven’t heard much of Agent Builder lately, so here is a small Christmas gift to help get people started on this.
I’ve seem more than once people struggle with routing or trying to use agents as a tool. Right now agent builder doesn’t support it, but there is a trick to achive something closer.
So here is the use case:
- Suppose you have a support chat, with several specialists.
- You want to route the user, but you also need a persistent conversation. You don’t want the user explaining every time who he wants to talk to.
The solution: set a variable to remember the last router recommendation.
The overall setup look like this:
Now, lets get into more details about each step. Click on the steps to see more details:
Step 1 - start node
At the start node, you set a variable selected_agent as a string, with default value being unknown:
Step 2 - agent node: trial agent
In the next node, place an Agent node trial, that will be the classifier agent.
- Add the instructions below:
you are a trial agent, that will classify which agent is more appropriate for the task.
previous agent: {{state.selected_agent}}
- In the output format, choose
JSONand define an enum property for each valid agent, plusunknown.
- You can choos the advanced mode and paste this JSON to replicate this example:
{
"type": "object",
"properties": {
"suggested_agent": {
"type": "string",
"enum": [
"pirate",
"dog",
"unknown"
],
"description": "agent recommendation. if you are not confident in the answer, return 'unknown'",
"default": ""
}
},
"additionalProperties": false,
"required": [
"suggested_agent"
],
"title": "response_schema"
}
Step 3 - Set state node
Next, you will need a Set state node. This will keep a persistent setting on the last choosen agent, storing the response of the classifier in the variable selected_agent:
Step 4 - If/else node
Next, comes the If/else node. This will route the flow towards the selected agent:
Step 5 - Specialized agents
Finally, we set an Agent node for each one of our specialists, plus a last one that will handle things when no agent matches the request.
-
Pirate Agent:
-
Dog Agent:
-
Not found agent:
Step 6 - Examples
How it works
- If you ask something that doesn’t match any agents, it will refuse:
- Then you can fix your choice:
- And you can switch to another agent, remembering the conversation
Well that’s it for today.
I wish everyone a Merry Christmas!
![]()












