Repository navigation
Description
Summary
The main agent can delegate work with the Agent tool, but once a subagent is running the only way to talk to it is SendSubagentInput, and that tool only works for interactive (tmux pane) subagents. For a headless subagent it fails with Subagent <label> is headless and has no TUI to send input to. Headless is the default (tools.agent.mode: headless in DefaultConfig()), and it is the only mode outside tmux, so in the common case the main agent cannot steer a subagent after spawning it: it can only wait for the [Subagent Completed] note or kill it with CloseSubagent and start over.
This issue asks for a runtime message channel to a running or just-finished subagent in both modes, so the main agent can hand it new information ("the user changed the requirement, also cover X"), correct its course ("stop editing that file, the schema lives in Y"), or ask a follow-up on its result without respawning and losing its context.
Current behaviour
- Interactive mode:
SendSubagentInputtypes into the pane and re-arms the completion watcher whensubmit=true. Text typed mid-turn is queued by the subagent's chat and runs as its next turn. This already covers the ask for tmux users. - Headless mode:
AgentTool.executeOneruns the child throughagentrunner.Run, which opens a stdin pipe only whenRequireApproval && Approval != nil. The Agent tool passes neither, so the child's stdin is/dev/null. The child'sheadlessControlreads EOF at once,awaitTurnreturns false after the first turn, and the process exits. There is nowhere to write a message.
What already exists to build on
infer headless(any non-text format) already reads newline-delimited control frames on stdin inheadlessControl.dispatchLine. Arun_agent_inputframe enqueues its messages on the session message queue, andawaitTurnpicks them up as the next turn while stdin stays open. This is the same frame the daemon sends toinfer headless --serveworkers, so no new protocol is needed.- The interactive job already has the per-turn result file with
done: true, the completion watcher,[Subagent Idle],tools.agent.idle_timeoutauto-close andSendSubagentInput's re-arm. The headless job needs the same lifecycle once the child can outlive its first turn.
Proposed shape
- Keep
SendSubagentInputas the single tool the model calls, and make it work for headless subagents too.textis the message.keysandsubmit=falsestay interactive-only and return a clear error for a headless target, since there is no TUI to drive. - For a headless subagent,
agentrunner.Runkeeps a stdin pipe open for the subagent's lifetime and exposes a writer to the job.SendSubagentInputwrites onerun_agent_inputframe with a single user message on it. - A headless subagent that has finished its turn stays alive and idle until the parent sends a follow-up, the idle timeout closes it, or
CloseSubagentstops it. Lifecycle mirrors the interactive job: the child writes the result file withdone: trueat the end of every turn (--result-filetoday writes it once on exit), the job delivers one[Subagent Completed: <label>]note per turn, re-arms when a message is sent, and[Subagent Idle]and[Subagent Closed]apply unchanged. tools.agent.wait: true(blocking fan-in) is unaffected: a blocking subagent returns its first turn and is closed, the way it works today. Only async headless subagents become addressable.- The subagent's run stats keep accumulating across turns so the stats line stays meaningful.
Open question for the implementer: whether an idle headless subagent should hold a slot against tools.agent.max_parallel. Interactive panes do today. Holding the slot is the simplest consistent answer and the idle timeout already bounds the cost.
Out of scope
- Streaming the subagent's partial output back to the parent mid-turn (
ReadSubagentScreenstays interactive-only). - Subagent to parent messages other than the existing completion, idle and approval notes.
- Messaging A2A tasks.
A2A_SubmitTaskalready resumesinput-requiredtasks and has its own follow-up path.
Acceptance Criteria
- With
tools.agent.mode: headless, after the[Subagent Completed: <label>]note arrives,SendSubagentInputwithtextruns a second turn in the same subagent session, and the parent receives a second[Subagent Completed: <label>]note carrying that turn's final message. -
SendSubagentInputsent while a headless subagent is mid-turn is queued and runs as its next turn, with no message lost and no duplicate completion note. -
SendSubagentInputwithkeysorsubmit=falseagainst a headless subagent fails with an error that says these are interactive-only, without affecting the subagent. - An idle headless subagent is closed after
tools.agent.idle_timeoutseconds with one[Subagent Closed: <label>]note, and0disables the auto-close, matching the interactive behaviour. -
CloseSubagentstops an idle or running headless subagent and releases its slot. -
tools.agent.wait: truebehaviour is unchanged: the blocking call returns after the first turn and the subagent is not kept alive. - The stats line in the completion note and in the job list reflects all turns of the subagent, not only the last one.
-
docs/subagents.mdanddocs/tools-reference.mddescribeSendSubagentInputas working for both modes and document the keep-alive lifecycle for headless subagents. The tool definition golden file is updated. -
go test -race ./...andtask precommit:runpass.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
inference-gateway-releaser commentedon Oct 2, 2026
🎉 This issue has been resolved in version 0.222.0 🎉
The release is available on:
Your semantic-release bot 📦🚀