Task tool truncation drops session_id metadata #8398

Open
opened 2026-02-16 18:09:51 -05:00 by yindo · 1 comment
Owner

Originally created by @HyunggyuJang on GitHub (Feb 3, 2026).

Originally assigned to: @thdxr on GitHub.

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

Originally created by @HyunggyuJang on GitHub (Feb 3, 2026). Originally assigned to: @thdxr on GitHub. ## 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
Author
Owner

@github-actions[bot] commented on GitHub (Feb 3, 2026):

This issue might be a duplicate of existing issues. Please check:

  • #6792: Task Tool Timeouts & Early Termination in Multi-Agent Conductor Pattern - discusses task tool returning only session_id for large outputs and subagent termination
  • #10634: Compaction overflow check doesn't account for large tool outputs until the next step, causing context overflow - related to tool output truncation issues

Feel free to ignore if none of these address your specific case.

@github-actions[bot] commented on GitHub (Feb 3, 2026): This issue might be a duplicate of existing issues. Please check: - #6792: Task Tool Timeouts & Early Termination in Multi-Agent Conductor Pattern - discusses task tool returning only session_id for large outputs and subagent termination - #10634: Compaction overflow check doesn't account for large tool outputs until the next step, causing context overflow - related to tool output truncation issues Feel free to ignore if none of these address your specific case.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#8398