Repository navigation
feat(tools): let the main agent message a headless subagent at runtime - #1465
Merged
Merged
Conversation
SendSubagentInput only reached interactive (tmux) subagents. A headless subagent, the default, got /dev/null as stdin and exited after its first turn, so the main agent could only wait for its result or kill it. infer headless gains --keep-alive: after the task it runs each run_agent_input frame read on stdin as a further turn in the same session, reports every finished turn as one subagent_turn line on stdout and exits when stdin closes. The Agent tool spawns async headless subagents this way over an os.Pipe it keeps the write end of. The keep-alive job reports each turn as its own [Subagent Completed] note, closes an idle child after tools.agent.idle_timeout with one [Subagent Closed] note and reports itself idle between turns so a headless parent does not wait for it. SendSubagentInput writes a text message to a headless subagent as its next turn. keys and submit=false stay interactive-only. tools.agent.wait: true is unchanged. Closes #1456
5 tasks
A keep-alive subagent emitted its turn notes while holding its mutex. The supervisor hands a note to the UI, whose render reads the job back through Idle and Stats under the same mutex, so the chat TUI deadlocked the moment a headless subagent finished its first turn. Notes are now built under the lock and emitted after it. The task views also read an idle keep-alive subagent as completed, the way its note says, and as running again once a follow-up is sent.
Contributor
|
🎉 This PR is included in version 0.222.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1456
What
SendSubagentInputonly reached interactive (tmux) subagents. A headless subagent, the default, got/dev/nullas stdin and exited after its first turn, so the main agent could only wait for its result or kill it.infer headless --keep-alive: after the task it runs eachrun_agent_inputframe read on stdin as a further turn in the same session, reports every finished turn as onesubagent_turnline on stdout and exits when stdin closes.--result-filekeeps its once-on-exit semantics.os.Pipewhose write end it keeps. The job reports each turn as its own[Subagent Completed: <label>]note, closes an idle child aftertools.agent.idle_timeoutwith one[Subagent Closed: <label>]note, and reports itself idle between turns (JobIdleReporter) so a headless parent does not wait for it. The composer list and/tasksshow an idle subagent as completed and flip it back to running on a follow-up.SendSubagentInputwithtextwrites a message to a headless subagent as its next turn.keysandsubmit=falsestay interactive-only and fail for a headless target.tools.agent.wait: trueis unchanged: a blocking subagent returns its first turn and is not kept alive.AskUserQuestionis not offered to a keep-alive subagent: with stdin held open nobody would answer, so it would hang until the idle timeout. Today it is auto-dismissed on EOF, so this only removes a dead tool.Deviation from the issue's sketch: the child reports turns on stdout instead of rewriting the result file for the parent to poll, since the parent already owns the stdout pipe. The acceptance criteria are unchanged.
Tests
go test -race ./...andtask precommit:runpass.SendSubagentInputheadless cases,agentrunnerstdin pass-through,validateOptionskeep-alive rows,HasPendingskips idle jobs (counterfeiterFakeJobIdleReporter), and an e2eTestHeadlessKeepAliveagainst the built binary and the mock gateway.Docs
docs/subagents.mdgains a Headless Subagents section.docs/tools-reference.md,docs/configuration-reference.mdanddocs/commands-reference.mdare updated. Tool manifests and the golden file are regenerated.Impacted repos:
inference-gateway/docs, tracked in inference-gateway/docs#894 for the new--keep-aliveflag and the headless subagent lifecycle.