Skip to main content

Agents & Tool Calling

Build AI agents that can use tools to accomplish complex tasks.

What You'll Learn​

Overview​

Agents are AI assistants that can use tools to complete tasks.

How Agents Work​

Agents follow a four-step process:

  1. Plan - LLM analyzes the task and selects appropriate tools
  2. Execute - Run selected tools with provided parameters
  3. Observe - Review tool results
  4. Synthesize - Combine results into final answer

Agents vs. Raw LLM​

FeatureRaw LLMAgents
Tool usageNoYes - Can call APIs, search, execute code
Multi-step tasksLimitedYes - Can iterate until task complete
Real-time dataNoYes - Can fetch current information
Complex workflowsManualYes - Automated tool chains

Use Cases​

Use CaseRecommended Tools
ResearchRAG search + web search
Data analysisCode execution
Customer supportRAG + CRM tools
AutomationCustom MCP tools

Quick Example​

Create an agent that uses RAG and web search:

import requests

# Create agent
response = requests.post(
"http://localhost/api/v1/agent/configs",
headers={"Authorization": "Bearer YOUR_API_KEY"},
json={
"name": "research_agent",
"system_prompt": "You are a research assistant. Use web search for current info and RAG for internal docs.",
"model": "gpt-4",
"builtin_tools": ["rag_search", "web_search"],
"tool_choice": "auto",
"max_iterations": 5
}
)

agent_id = response.json()["id"]

# Chat with agent
chat_response = requests.post(
"http://localhost/api/v1/agent/chat",
headers={"Authorization": "Bearer YOUR_API_KEY"},
json={
"agent_id": agent_id,
"message": "What are the latest developments in AI?"
}
)

print(f"Response: {chat_response.json()['response']}")
print(f"Tools used: {chat_response.json()['tool_calls']}")

Next Steps​