Repository navigation
fix(tools): signal done and auto-close idle interactive subagents - #1429
Merged
Merged
Conversation
Interactive subagents had no way to say their task finished, so the monitor reported every completed turn as a completion, left the pane open at the prompt, and the main agent had to guess when to close them. The subagent chat now marks its result-file write done on its task turn (and on a failed terminal turn). The monitor treats a fresh done write as terminal: it emits exactly one completion note with any error, kills the pane, removes the temp files and records the terminal status inline, then returns. A new tools.agent.interactive.idle_timeout (seconds, default 300, 0 disables) closes a pane that never reports done after inactivity - no harvested turn, no screen change, no pending approval - with one close note carrying the last harvested message. The old idle-by-stability fallback no longer masquerades as a completion and warns as [Subagent Idle] with the pending auto-close instead.
4 tasks
inference-gateway-maintainer
Bot
marked this pull request as ready for review
September 30, 2026 10:58
inference-gateway-maintainer
Bot
requested a review
from a team
as a code owner
September 30, 2026 10:58
…idle timeout config A failed first request writes a done result with no assistant text. The monitor only checked done behind a non-empty answer, so the error was dropped and the pane waited for the idle timeout. Done is now checked first. A cancelled monitor now tears down too, so the result and approval files no longer leak when CloseSubagent or a supervisor stop winds the job. The tools.agent.interactive block is gone. Panes always open as a vertical split and always fall back to headless outside tmux, which removes the layout and fallback keys. The timeout is now tools.agent.idle_timeout. The subagent mode is a typed SubagentMode instead of a commented string. The monitor tests use a blank pane id so teardown never reaches the host tmux.
Contributor
|
🎉 This PR is included in version 0.220.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.
Resolves #1422
Summary
Interactive subagents (each a live
infer chatin a tmux pane) can now signal completion explicitly and their panes close themselves. The subagent chat marks its result-file write withdone: trueon its task turn (and on a failed terminal turn), and the parent monitor treats that as terminal: it delivers exactly one completion note, kills the pane, removes the temp files, and records the terminal status inline, then returns. A newtools.agent.idle_timeout(seconds, default 300,0disables) is the safety net that closes a pane whose subagent never reports done, and the old idle-by-stability fallback stops masquerading as a completion.Changes
SubagentResultFilegains aDonefield (written by the chat TUI's result-file writer on every fully completed turn and by the error path), soINFER_SUBAGENT_RESULT_FILEbecomes the subagent's explicit terminal signal, not just a per-turn transcript.PaneObservationgainsDone,HarvestFailedandHarvestError, andNewPaneInspectorpopulates them from the result file, so the monitor can decide on terminal turns without scraping the pane.interactiveSubagentJob.Runnow returns on the first terminal outcome: adonewrite (completed or failed, with or without assistant text), the pane closing, the idle timeout expiring, or monitor cancellation. On done/failed it emits exactly one[Subagent Completed: <label>]note with the harvested message and error, then tears the subagent down inline (kills the pane, removes the result and approval files, sets the tracker status completed/failed) instead of waiting for the retention-window reap, since the supervisor only callsCloseon eviction or reap. A cancelled monitor runs the same teardown, soCloseSubagentand a supervisor stop leave no temp files behind. Reap'sClosenow just drops the tracker entry.tools.agent.idle_timeoutonAgentToolConfig(default300,0disables, env overrideINFER_TOOLS_AGENT_IDLE_TIMEOUT). Inactivity means no new result-file write, no change in the pane's screen tail, and no pending approval for the full window. A harvested turn, a screen change (including viaSendSubagentInput), or an approval pauses the clock. On expiry the monitor emits one[Subagent Closed: <label>]note ("closed after 5m0s of inactivity without a done signal" plus the last harvested message) and tears the subagent down through the same teardown path.[Subagent Idle: <label>](ended its turn without output or is waiting for input, and names the pending auto-close) instead of faking a[Subagent Completed]. Writes from an older binary without thedonefield keep the previous per-turn harvest behavior and are eventually closed by the timeout.AgentInteractiveConfig. Panes always open as a vertical split and always fall back to headless outside tmux. The subagent mode is a typedscheddomain.SubagentModeused by the config andSubagentState.tools.agent.interactive.layoutandtools.agent.interactive.fallbackare removed and ignored if still set.AgentandCloseSubagenttool descriptions (and the regeneratedtool_definitions.golden.json) to match: panes close themselves on done/failure/idle timeout,CloseSubagentis only for stopping one early, a finished turn closes the pane even when it ends with a question, andSendSubagentInputonly reaches a pane that is still working or stuck.docs/configuration-reference.md(Tool Settings + Tools Configuration env vars) anddocs/subagents.md(new "Interactive Subagents" section).0disable, plus updated idle-fallback and monitor tests.Downstream impact