Skip to content

Task tool truncation drops session_id metadata #11903

Description

@HyunggyuJang

Summary

Task tool output can be truncated after it appends <task_metadata>. When output is large, the metadata block is removed, so callers cannot reuse session_id and a new subagent is spawned.

Steps to reproduce

  1. Call the task tool with a prompt that produces output exceeding truncation limits (e.g., >2000 lines or >50KB).
  2. Inspect the tool output. It ends with the truncation notice, but the <task_metadata> block is missing.
  3. Attempt to resume the same subagent: no session_id is available, so a new subagent is started.

Expected

The <task_metadata> block (including session_id) is always present, even when output is truncated.

Actual

Metadata is truncated away.

Root cause

Tool.define truncates tool output after execution. The task tool appends <task_metadata> before the wrapper truncates, so the metadata can be removed.

Proposed fix

Apply truncation to the task tool output before appending metadata, or mark the output as already truncated so the wrapper does not truncate, then append <task_metadata>.

Version

Observed on v1.1.49

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions