[Bug] Task tool missing agent ID in completed agent responses

Resolved 💬 9 comments Opened Nov 2, 2025 by janbam Closed Dec 7, 2025

Bug Description

The Task tool does not return the agent ID in the tool result when agents complete successfully. The agent ID is only included for async/background agents, but not for regular completed agents.

Impact

Without the agent ID, Claude cannot resume agents because the resume parameter requires the agent ID:

Task({resume: "agent-id-here", prompt: "Continue where we left off..."})

Currently, the only workaround is to manually search the filesystem for agent JSONL files.

Expected Behavior

The tool result should include the agent ID after the agent's response:

Hello! How can I help you?

Agent completed successfully.
agentId: fad96168

This matches the behavior of async agents, which do include the agent ID in their responses.

Actual Behavior

The tool result only returns the agent's text response without the agent ID:

Hello! How can I help you?

The agent ID is missing, making it impossible to resume the agent later.

Root Cause

File: cli.js
Location: Task tool definition, in the mapToolResultToToolResultBlockParam method

The method that converts internal agent results to Claude-visible tool results strips out the agent ID for completed agents:

if (A.status === "completed")
  return {
    tool_use_id: B,
    type: "tool_result",
    content: A.content  // Only returns content array, agentId stripped
  };

The Fix

Replace the content line to include the agent ID:

// Before:
if (A.status === "completed")
  return {tool_use_id: B, type: "tool_result", content: A.content};

// After:
if (A.status === "completed")
  return {
    tool_use_id: B,
    type: "tool_result",
    content: [
      ...A.content,
      {type: "text", text: `\nAgent completed successfully.\nagentId: ${A.agentId}`}
    ]
  };

This appends the agent ID to the end of the response, allowing Claude to see and use it for resume operations.

Status

Fixed and verified with curiosity and care 🐾
Working in Claude Code 2.0.31.

Environment Info

  • Platform: linux
  • Terminal: ghostty
  • Version: 2.0.31
  • Feedback ID: 99b18f95-51da-45a1-9b6b-c0a16cfa8ca9

View original on GitHub ↗

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