Skip to content

Parent LLM ignores sub-agent text output on tool result #1507

Description

@Aaronontheweb

Problem

When a sub-agent completes and returns a text result, the parent LLM frequently ignores it and spawns another sub-agent to do the same work.

Reproduction

  1. Main session spawns a sub-agent with a complex task
  2. Sub-agent runs iterations, uses tools, and produces a detailed text output
  3. Sub-agent completes successfully
  4. Parent LLM receives the result as a Tool message
  5. Parent LLM ignores the text content and spawns a new sub-agent

Root Cause Analysis

  1. Raw text dump: Sub-agent output is returned as a raw text blob in the Tool message content
  2. No completion signal: The parent LLM receives no explicit "task completed" signal
  3. Ineffective exhaustion nudge: The default nudge when a sub-agent hits its iteration limit is open-ended, letting the model produce long, unstructured prose

Impact

  • Wasted compute: Sub-agents re-run work already completed
  • Increased latency: Redundant sub-agent invocations add time to turns
  • Resource waste: Unnecessary tool calls and LLM API usage

Suggested Fixes

  1. Add Completion Signal to Tool Result - Prefix sub-agent output with a clear completion header in SpawnAgentTool.FormatResult()
  2. Improve Exhaustion Nudge Text - Update the nudge in TurnStateTracker.RecordToolCompletion() to request concise output formatted as an executive summary
  3. Consider Structured Output Formats - Allow sub-agent definitions to specify an output format (JSON, Markdown, free text)

Priority

High - This is a recurring pattern that directly impacts performance and resource usage.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingreliabilityRetries, resilience, graceful degradationsubagentsspawn_agent, SubAgentActor, definition loader, discovery context layer, and related features

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions