[FEATURE] Enable Subagents to Pass Follow-up Commands to the Main Agent for Execution

Resolved 💬 6 comments Opened Sep 24, 2025 by coygeek Closed Jan 7, 2026

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

Currently, it's not possible to build a fully automated, single-prompt workflow where one subagent programmatically triggers another. The core issue is that subagents, when invoked via the Task tool, operate in a completely isolated context.

My workflow involves creating modular, specialized agents that can hand off tasks to one another. For example, I want an implementer agent to write code and then, as its final step, trigger a reviewer agent to check that code. I want to initiate this entire sequence with a single command.

While the new SlashCommand tool (v1.0.123) allows a subagent to generate a follow-up command, that command is effectively "trapped" within the subagent's isolated session. The main agent only receives the final text summary from the subagent's Task and is unaware of the follow-up command that was generated. This breaks the chain of automation and prevents true, agent-driven composition, forcing me to use less intuitive workarounds that centralize logic outside of the agents themselves.

Proposed Solution

I propose that the Task tool's result be enhanced to optionally return a "follow-up prompt" or "next command" string to the main agent.

When a subagent completes its execution, the Task tool result passed back to the main agent should be able to contain two fields:

  1. A final text summary (as it does now).
  2. An optional follow-up prompt string.

If the main agent receives a Task result with a follow-up prompt, it should:

  1. Display the text summary to the user.
  2. Immediately add the follow-up prompt to its own execution queue and run it as the very next step.

This would create a seamless and intuitive handoff mechanism. From a user's perspective, the interaction would be a single, uninterrupted flow. The subagent's final action (e.g., using SlashCommand) would directly and automatically trigger the main agent's next action.

Alternative Solutions

I have explored several workarounds, but none are as clean or as powerful as the proposed solution.

  1. The "Coordinator Slash Command" Pattern: This is the best current workaround. I create a master slash command that contains a multi-step plan telling the main agent to call Subagent A, then Subagent B.
  • Limitation: This centralizes the workflow logic in the slash command, making the agents themselves less autonomous. The implementer agent can't decide to call the reviewer; the sequence is pre-scripted. It prevents dynamic, conditional chaining based on the first agent's results.
  1. Manual Two-Step Process: I can run the first subagent, wait for it to complete, and then manually run the slash command to trigger the second subagent.
  • Limitation: This is not automated and defeats the purpose of creating an agentic workflow.
  1. Subagent Instructs the User: I can modify the first subagent's prompt to instruct me, the user, to run the next command.
  • Limitation: This still requires manual intervention (copying and pasting) and is prone to user error.

Priority

High - Significant impact on productivity

Feature Category

CLI commands and flags

Use Case Example

Here is a step-by-step walkthrough of the ideal experience for an "implement and review" workflow:

  1. Setup:
  • A subagent named implementer is defined. Its final instruction is to use the SlashCommand tool to run /review-file <file_path>.
  • A subagent named reviewer is defined.
  • A slash command /review-file exists, which prompts the main agent to use the reviewer subagent on a file.
  1. User Interaction (Single Prompt):

``
> Use the implementer agent to add a new function to 'utils.js'
``

  1. Execution Flow (Behind the Scenes):
  • The main agent invokes the implementer subagent.
  • The implementer subagent writes the new function to utils.js.
  • As its last action, the implementer uses the SlashCommand tool to execute /review-file utils.js.
  • The SlashCommand tool generates the prompt: "Please use the reviewer subagent to review the file at utils.js".
  • (Proposed Change) The Task tool for the implementer finishes, returning both its summary ("I have added the function.") and the follow_up_prompt to the main agent.
  • The main agent displays the summary to the user and immediately executes the follow-up prompt.
  • The main agent invokes the reviewer subagent on utils.js.
  1. Final Output:
  • The user sees the final, detailed code review from the reviewer subagent, completing the entire automated chain.

Additional Context

This feature would unlock the true potential of the recently added SlashCommand tool as a mechanism for inter-agent communication.

A potential technical implementation could involve changing the tool_result schema for the Task tool.

Current Task Tool Result (Simplified):

{
  "content": [
    {
      "type": "text",
      "text": "Final summary from subagent."
    }
  ]
}

Proposed Task Tool Result (Simplified):

{
  "content": [
    {
      "type": "text",
      "text": "Final summary from subagent."
    }
  ],
  "follow_up_prompt": "/review-file utils.js" // Optional field
}

This would provide a clean, structured way for subagents to chain actions without breaking their isolation, making Claude Code an even more powerful platform for building complex AI-driven automations.

View original on GitHub ↗

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