# Simple Router - Agent builder tutorial

**URL:** <https://community.openai.com/t/simple-router-agent-builder-tutorial/1370154>\
**Category:** Community\
**Tags:** api, agents-sdk, agent-builder\
**Created:** [December 24, 2025, 8:27pm UTC](https://community.openai.com/t/simple-router-agent-builder-tutorial/1370154 "2025-12-24T20:27:58Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![aprendendo.next](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/aprendendo.next/32/721758_2.png) [@aprendendo.next](https://community.openai.com/u/aprendendo.next)\
**Post date:** [December 24, 2025, 8:27pm UTC](https://community.openai.com/t/simple-router-agent-builder-tutorial/1370154/1 "2025-12-24T20:27:58Z")

</div>

I haven’t heard much of [Agent Builder](https://platform.openai.com/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:

 ![image](https://us1.discourse-cdn.com/openai1/original/4X/1/e/6/1e66c1a3cfdfbb3f5bfadf904379ba53b0f735f4.png)

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`:
> 
> ![image](https://us1.discourse-cdn.com/openai1/original/4X/2/a/a/2aa1d93bcc76be9ffdd82c683eacf50db2156930.png)

> **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:
> 
> ```plaintext
> you are a trial agent, that will classify which agent is more appropriate for the task.
> 
> previous agent: {{state.selected_agent}}
> 
> ```
> 
> ![image](https://us1.discourse-cdn.com/openai1/original/4X/3/f/8/3f8bc82bd2e1c1e740c11aeca810223700d1b3b0.png)
> 
> - In the output format, choose `JSON` and define an enum property for each valid agent, plus `unknown`.  
> ![image](https://us1.discourse-cdn.com/openai1/original/4X/b/4/4/b44268ea0e52c8e771960ba54ac559fc239f2b7e.png)
> - You can choos the advanced mode and paste this JSON to replicate this example:
> 
> ```json
> {
> "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`:
> 
> ![image](https://us1.discourse-cdn.com/openai1/original/4X/0/0/e/00e27bfe0095e5a19e3611dca7e3d0ae89d72ff1.png)

> **Step 4 - If/else node**
>
> Next, comes the If/else node. This will route the flow towards the selected agent:
> 
> ![image](https://us1.discourse-cdn.com/openai1/original/4X/6/9/7/697ee244f1437a195a1f3905c0290eaf132fd4d1.png)

> **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:  
> ![image](https://us1.discourse-cdn.com/openai1/original/4X/f/2/e/f2e75c3790eb074063457e7921f5a6e04cfe7ee5.png)
> - Then you can fix your choice:  
> ![image](https://us1.discourse-cdn.com/openai1/original/4X/9/c/1/9c1da07f28b5acf7190b702a0cce5ecfcded6444.png)  
> ![image](https://us1.discourse-cdn.com/openai1/original/4X/1/d/6/1d6b62356ec10581af584c0b40456451c7a9ae80.png)
> - And you can switch to another agent, remembering the conversation  
> ![image](https://us1.discourse-cdn.com/openai1/original/4X/c/8/3/c8332dc3bc6c41a2c9074327c634f507cbbee988.png)

Well that’s it for today.

I wish everyone a Merry Christmas! 🎄 🎁 🎅

---

<div class="post-metadata">

**Author:** ![Distributed\_Systems](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/distributed_systems/32/514744_2.png) [@Distributed\_Systems](https://community.openai.com/u/Distributed_Systems)\
**Post date:** [January 7, 2026, 7:57am UTC](https://community.openai.com/t/simple-router-agent-builder-tutorial/1370154/2 "2026-01-07T07:57:07Z")

</div>

this saved me so much time, i couldnt get the state node to work foreverrr, thanks for posting
