What is Structured Output?
Structured Output means:- ✅ Agent returns complete response at once (not streamed)
- ✅ Response is formatted as JSON (not raw text)
- ✅ Can be used as a tool in other agents
- ✅ Can be used in workflows
- ✅ Can be called via API
Three Ways to Use Structured Output Agents
1. As a Tool in Other Agents
Use one agent as a tool that another agent can call: Scenario: Sales Agent needs help with lead scoring.- Sales Agent receives lead info
- Calls “Lead Scorer” agent as a tool
- Gets structured score & analysis back
- Uses the score to prioritize the lead
- Main Agent: Has “Lead Scorer” as a tool
- Lead Scorer: Non-streaming agent returning score JSON
2. In Workflows
Use agent in workflows for multi-step automation: Scenario: Daily data processing workflow.- Extract Data (API → Raw data)
- Validate Agent (Non-streaming) →
{ valid: true, ... } - Transform Agent (Non-streaming) →
{ normalized: {...} } - Load to Database (API call)
- Result: Clean data loaded
- Data validation and cleaning
- Content analysis and categorization
- Document extraction
- Quality assurance checks
3. Via API
Call agent directly through REST API:Configuring Structured Output
In Agent Settings
- Go to agent configuration
- Find Streaming setting
- Disable streaming
- Optionally define response schema (JSON structure)
Response Schema (Optional)
Define the expected JSON structure:- ✅ Agent response always matches schema
- ✅ Easier to parse in code
- ✅ Better tool integration
- ✅ API contracts clearly defined
Using as a Tool
Adding Agent as Tool to Another Agent
1
Go to Main Agent Settings
Open the agent that will call other agents
2
Open Tools Tab
Navigate to Tools configuration
3
Add New Tool
Select “Agent” as tool type
4
Select Agent
Choose which agent to use as tool
5
Configure Parameters
Define what input to pass and how to use output
6
Save
Agent now available as tool
Example: Agent Calling Agent
Scenario: Support Bot needs Lead Scoring Agent.- Support Bot Config:
- Name: Support Bot
- Tools:
- Help Desk API (for creating tickets)
- Email Tool (for sending emails)
- Lead Scorer Agent (for evaluating customers)
- Prompt: “If customer mentions a sales opportunity, use the Lead Scorer agent to evaluate whether they’re a good sales lead”
- User: “I’m interested in your enterprise plan”
- Support Bot thinks: “This is a sales opportunity”
- Support Bot calls Lead Scorer Agent
- Input: “Customer details and interest”
- Output:
{ lead_score: 9, category: "hot", rec: "route_to_sales" }
- Support Bot responds: “Great! I’m connecting you with our sales team”
Using in Workflows
Workflow Integration
Example workflow: Customer Feedback Analysis- Receive Feedback
- Input: Customer feedback text
- Variable:
customer_feedback
- Analyze with Agent
- Agent: “Feedback Analyzer” (non-streaming)
- Input:
customer_feedback - Output:
{ sentiment, topics, action_needed }
- Route Based on Analysis
- If
action_needed == true— create ticket in Help Desk - If
sentiment == "negative"— alert support team - Else — archive
- If
- Notify Stakeholders
- Send report with analysis
- Done
Conditional Routing with Agent Output
Agent returns:- If
priority == "high"ANDneeds_escalation— escalate to manager - Elif
category == "billing"— route to billing team - Else — route to general support
API Usage
REST API Endpoint
Example: Node.js
Example: Python
Response Handling
Successful Response
Error Response
Best Practices
Define Clear Schema
Specify response format so consumers know what to expect
Handle Errors
Always check status and error fields in responses
Use Context
Pass user_id, session_id, or other context for better tracking
Monitor Usage
Track API calls and token usage in project monitoring
API Security
- ✅ Use API keys with appropriate permissions
- ✅ Rotate keys regularly
- ✅ Don’t embed keys in frontend code
- ✅ Use environment variables or secrets manager
- ✅ Monitor for unusual API usage
Comparing with Chat Mode
🔗 Learn about Chat Mode: Conversational Chat
Troubleshooting
Agent returns empty response
Agent returns empty response
Check:
- Input format correct
- Agent has proper datasources/tools
- Response schema doesn’t reject valid data
Schema validation fails
Schema validation fails
Solutions:
- Review expected schema
- Check agent prompt includes format instructions
- Adjust schema to be less restrictive
API call times out
API call times out
Causes:
- Agent processing complex request
- Tool calls taking too long
- External API delays
Tool call from another agent fails
Tool call from another agent fails
Check:
- Tool agent is non-streaming
- Tool agent is in same project
- Tool agent has required datasources
- Input format matches tool expectations
Next Steps
- Configure Agent - Set up structured output
- Workflows, Jobs & Triggers - Use in workflows
- Use as Tool - Agent calling agent
- API Documentation - Full API reference