Background
User queries include both simple information retrieval and tool invocation, so a mature, reusable, and general system architecture is needed.
Architecture
User Query
↓
1️⃣ Intent Router
↓
┌───────────────┬──────────────────┐
│ Simple QA │ Tool Required │
│ (LLM only) │ (ReAct loop) │
└───────────────┴──────────────────┘
↓
2️⃣ ReAct Tool Loop
↓
3️⃣ Structured Tool Layer
↓
4️⃣ Guardrails & Policies
↓
Final Output
1. Layer One: Intent Router
The router needs to determine whether to invoke tools.
Router Prompt:
prompt = ‘
You are a task classifier.
User query: {query}
Classify the user query into one of:
1. simple_qa
2. retrieval
3. tool_call
4. multi_step
Return JSON:
{
"type": "..."
}
’
2. Layer Two: ReAct Tool Core
1. simple_qa ==> LLM answers directly
2. retrieval ==> Call vector database for direct retrieval / call Browser for retrieval
3. tool_call ==> Enter ReAct loop
4. multi_step ==> Enter ReAct loop
Architecture of the ReAct loop:
LLM decides next action
↓
Call one tool
↓
Append tool result
↓
Repeat
Sample Code:
while True:
response = llm(messages, tools=tool_schema)
if response.tool_calls:
result = execute_tool(...)
messages.append(tool_result)
else:
break
3. Layer Three: Structured Tool Layer
This layer adopts ChatGPT’s Function Calling concept, connecting the LLM and tools invocation by defining “Tools Schema”.
Enterprise-grade AI Agent: ReAct + Function Calling:
https://strictfrog.com/en/2026-02-17-enterprise-level-ai-agent-react-function-calling/
4. Layer Four: Guardrails & Policies
Maximum Step Limit:
max_steps = 15
Disallow Sending Sensitive Emails:
if tool = send_mail:
require confirmation
Evaluation: (Router + ReAct Framework + Function Calling Recommendation: 🌟🌟🌟🌟🌟)
Advantages:
1. Generality Very High
2. Controllability High
3. Extensibility Very High
4. Complex Tasks Very High
5. Simple Task Efficiency Very High