Agent tool: support structured return data from subagents

Resolved 💬 2 comments Opened Apr 6, 2026 by vmihalis Closed May 16, 2026

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:

  1. A gather agent collects data from multiple platforms
  2. The parent validates the data against business rules
  3. 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.

View original on GitHub ↗

This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗