Building Agents
This page walks through configuring an agent for good results.
Write Clear Instructions
Instructions are the agent's system prompt. Describe the role, the desired output format, and any constraints. Be explicit about what "done" looks like — the planner uses this to decide when the task is complete.
Tip
Xagent can help refine a prompt. The optimize-instructions endpoint rewrites a draft into clearer, more actionable instructions.
Choose an Execution Mode
The execution mode controls the trade-off between speed, cost, and thoroughness. A balanced mode suits most tasks; heavier modes plan more deeply and spend more compute on complex, multi-step goals.
Attach Knowledge & Tools
- Knowledge bases ground the agent in your documents via RAG. See Knowledge Bases.
- Tool categories determine which actions the agent can take — web access, file generation, MCP servers, and custom APIs.
- Skills add packaged capabilities like presentation or report generation.
Create an Agent via API
You can create agents from the UI or programmatically:
POST /api/agents
{
"name": "Market Research Assistant",
"instructions": "Produce concise competitor analysis reports.",
"execution_mode": "balanced",
"knowledge_bases": ["kb_market"],
"skills": ["evidence-based-rag"],
"tool_categories": ["basic", "file"],
"suggested_prompts": ["Summarize the top 3 competitors"]
}Preview, Publish & Embed
POST /api/agents/preview # dry-run a configuration
POST /api/agents/{agent_id}/publish
POST /api/agents/{agent_id}/unpublish
POST /api/agents/{agent_id}/logo
POST /api/agents/{agent_id}/api-key # mint a runtime keyPublished agents can be embedded as a chat widget. Restrict where the widget runs with allowed_domains.