Agent tool: support structured return data from subagents
Problem
The Agent tool returns a single text blob from the subagent. There's no structured data channel — if the parent needs to parse results programmatically, it has to rely on text conventions like --- JSON_OUTPUT --- markers embedded in the response.
Current Behavior
Agent({name: "gather", prompt: "Collect hours and sessions for 2026-04-03"})
→ Returns: "Found 8.5 hours from Rippling and 12 sessions from Checkfront. Hours: 8.5, Sessions: 12. [flags: none]"
The parent then has to regex or string-parse this to extract hours=8.5, sessions=12.
Proposed Solution
Allow agents to return structured data alongside their text response:
{
"text": "Found 8.5 hours and 12 sessions.",
"data": {
"hours": 8.5,
"sessions": 12,
"flags": [],
"source_dates": ["2026-04-03"]
}
}
This could be via a ReturnData tool available to subagents, or a structured field in the agent's final response that the parent can access.
Use Case
I run multi-phase workflows where:
- A gather agent collects data from multiple platforms
- The parent validates the data against business rules
- An entry agent writes validated data to a spreadsheet
Today the gather agent has to format results as parseable text, and the parent has to string-match. With structured returns, the gather agent returns a typed object and the parent passes it directly to the entry agent.
Other use cases:
- Verification agents returning pass/fail with details
- Analysis agents returning metrics the parent aggregates
- Any pipeline where agents hand off data
Impact
Anyone building multi-agent pipelines or orchestration patterns where agents need to pass data, not just summaries.
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗