[FEATURE] Add output_mode parameter to Agent tool — control how background agent results enter main context

Open 💬 2 comments Opened Jun 15, 2026 by lg320531124

Preflight Checklist

  • [x] I have searched existing requests and this feature hasn't been requested yet
  • [x] This is a single feature request (not multiple features)

Problem Statement

The Agent tool currently injects the full text output of background agents into the main conversation context with no size control. There is no way to limit how much of the agent's output is included. This makes multi-agent orchestration impractical — when running 5-10+ parallel agents, their combined outputs easily overflow the context window (see companion bugs #68582 and #68584).

Previous request #17208 proposed output_mode for the Task tool and was closed as "not planned." Since then, the Agent tool has become the primary sub-agent mechanism, and the problem has only worsened as users run more parallel agents in workflows.

Proposed Solution

Add an output_mode parameter to the Agent tool:

interface AgentToolInput {
  prompt: string;
  subagent_type?: string;
  run_in_background?: boolean;
  output_mode?: 'full' | 'summary' | 'result_only';  // NEW
}

| Mode | Behavior | Use Case |
|------|----------|----------|
| full (default) | Current behavior — full agent output injected | Need the complete reasoning chain |
| summary | Agent generates a concise summary; only summary is injected | Most orchestration scenarios |
| result_only | Only the agent's final response text (no tool call trace) | Only need the conclusion |

For summary and result_only modes, the full output is still saved to the .output file for on-demand reading.

Implementation note: The summary mode could be implemented by adding a system prompt instruction to the sub-agent: "After completing your work, provide a concise summary (max 500 words) of what you did and found." This requires no model changes — only a prompt addition and output extraction.

Alternative Solutions

  1. Never launch more than 1 background agent at a time (severely limits orchestration)
  2. 2. Have agents write status files to disk and poll via Bash instead of using TaskOutput
  3. 3. Use headroom_compress MCP tool to manually compress after each agent result

All workarounds require significant orchestrator complexity and don't address the root cause.

Priority

Critical - Blocking my work

Feature Category

CLI commands and flags

Use Case Example

  1. Orchestrator receives task: "Analyze these repos and extract API patterns"
  2. 2. Launch 5 parallel Explore agents with output_mode: 'summary'
  3. 3. Each agent returns ~500 words of summary instead of ~50K of full transcript
  4. 4. Total injection: ~2.5K tokens instead of ~250K tokens
  5. 5. Context stays manageable, pipeline continues

Additional Context

Companion bug reports: #68582 (context overflow from concurrent agents), #68584 (compaction timing gap)
Related: #17208 (original output_mode request, closed), #52390, #53065

View original on GitHub ↗

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