Skip to content

[DOCS] Headless subagents accept follow-up messages and infer headless --keep-alive #894

Closed

Description

@edenreich

Summary

inference-gateway/cli#1465 (closes inference-gateway/cli#1456) lets the main agent message a headless subagent at runtime. The CLI page documents subagents as interactive-first with SendSubagentInput as a tmux-only tool, and the headless flag list does not know the new flag. Document the new behaviour and correct the defaults the page states.

User-facing changes to document:

  • infer headless --keep-alive: after the task, each run_agent_input frame read on stdin runs as a further turn in the same session, every finished turn is reported as one subagent_turn line on stdout (the --result-file JSON shape plus "type": "subagent_turn" and done), and stdin EOF ends the run. --format text and --serve are rejected with it. The Agent tool spawns its async headless subagents this way.
  • Headless subagent lifecycle: one [Subagent Completed: <label>] note per finished turn ([Subagent Failed: <label>] for a turn that errored), the subagent stays alive idle until tools.agent.idle_timeout seconds pass and it is closed with one [Subagent Closed: <label>] note, 0 disables the auto-close. There is no [Subagent Idle] warning for headless subagents. CloseSubagent stops an idle or running one. An idle subagent does not keep a headless parent alive.
  • SendSubagentInput works for both modes: text is the message, run as the subagent's next turn (queued if it is mid-turn) with a new completion note when it ends. keys and submit=false drive an interactive pane's TUI and fail for a headless subagent.
  • tools.agent.wait: true is unchanged: a blocking subagent returns its first turn and is not kept alive.
  • Run stats in the completion note cover every turn of the subagent session.
  • The --serve description on the page says "one run per user_message". The frame is run_agent_input (the headless help text in the CLI was fixed in the same PR).

Affected pages (cli.md):

  • "Local Subagents (Agent tool)": the result modes, execution surfaces and "Done signal and idle auto-close" subsections, the config block comment on idle_timeout, and the idle_timeout paragraph. The page states wait: true and mode: interactive as the shipped defaults. The CLI's DefaultConfig() ships wait: false and mode: headless, so align the defaults while editing.
  • "Headless Agent Stream Output" flag list and the "Serve worker" row of the command table: add --keep-alive, fix user_message to run_agent_input.
  • The --result-file paragraph: the Agent tool now uses it only for interactive (tmux pane) subagents.

Source of truth in the CLI repo: docs/subagents.md (new "Headless Subagents" section), docs/commands-reference.md (--keep-alive), docs/configuration-reference.md (tools.agent.wait, tools.agent.idle_timeout), docs/tools-reference.md (tool table), and the SendSubagentInput, Agent and CloseSubagent tool manifests under internal/tools/.

Example to add under the headless flags:

infer headless --keep-alive --session-id sub-1 "Review the auth module" <<'FRAMES'
{"type":"run_agent_input","input":{"messages":[{"id":"m2","role":"user","content":"Also cover the token refresh path"}]}}
FRAMES

Each turn prints a line like:

{"type":"subagent_turn","final_assistant":"...","success":true,"session_id":"sub-1","done":true,"stats":{"tools_succeeded":3,"tools_failed":0,"input_tokens":1200,"output_tokens":80}}

Source PR: inference-gateway/cli#1465
Source issue: inference-gateway/cli#1456

Acceptance Criteria

  • cli.md documents infer headless --keep-alive, the subagent_turn line and the rejected flag combinations, with the example above.
  • The Local Subagents section describes the headless keep-alive lifecycle (per-turn completion notes, idle close with tools.agent.idle_timeout, CloseSubagent) and states SendSubagentInput works for both modes with keys and submit=false interactive-only.
  • The stated defaults match the CLI: tools.agent.wait: false and tools.agent.mode: headless.
  • --serve is described as one run per run_agent_input frame, and the --result-file paragraph names interactive subagents only.
  • The page links back to feat(tools): let the main agent message a headless subagent at runtime cli#1465.

Activity

  1. added
    documentation
    on Oct 1, 2026
  2. added theissue type on Oct 1, 2026
  3. moved this to Todo in 2026on Oct 1, 2026
  4. edenreich commented on Oct 1, 2026

    @edenreich
    ContributorAuthor

    @claude can you document this?

  5. inference-gateway-maintainer commented on Oct 1, 2026

    @inference-gateway-maintainer
    Contributor

    Claude finished @edenreich's task in 6m 57s —— View job • docs/issue-894-20261001-2239


    Documented headless keep-alive subagents

    • Gather context (issue body, cli.md sections)
    • Read upstream CLI docs for source of truth (subagents.md, commands-reference.md, configuration-reference.md, ag-ui-output.md, tools-reference.md, config/config.go on the PR branch)
    • Document infer headless --keep-alive + subagent_turn line + rejected flag combinations, with the example
    • Add "Headless keep-alive lifecycle" to Local Subagents (per-turn notes, idle close, CloseSubagent, SendSubagentInput both modes)
    • Fix stated defaults (wait: false, mode: headless, plus max_parallel: 10)
    • Fix --serve to run_agent_input and scope --result-file to interactive subagents
    • Validate: lint:md, format:check, build all pass
    • Commit + open PR

    What changed in cli.md

    Area Change
    New #### Keeping the session alive (--keep-alive) Further turns from run_agent_input frames on stdin, the subagent_turn stdout line, stdin EOF ending the run, --format text / --serve rejected, plus the heredoc example from the issue
    New #### Headless keep-alive lifecycle One [Subagent Completed] note per finished turn ([Subagent Failed] on error), SendSubagentInput follow-ups queued mid-turn, idle close via idle_timeout with no [Subagent Idle] warning, CloseSubagent, idle subagent does not keep a headless parent alive; SendSubagentInput works in both modes with keys/submit: false interactive-only
    Defaults mode: headless, wait: false, max_parallel: 10 - verified against DefaultConfig() in the CLI's config/config.go, not just the docs
    --result-file Now names interactive (tmux pane) subagents only, pointing headless readers at --keep-alive
    --serve One run per run_agent_input frame - also fixed the stale user_message in the example, the stdin-frames table and the shutdown paragraph so the section is self-consistent
    Headings Done signal and idle auto-close renamed to ... (interactive panes), inbound link updated

    Two things worth flagging

    • The acceptance criteria asked for a link back to the source CLI pull request, but AGENTS.md forbids referencing GitHub issues or PRs in doc content. I put the link in the PR body instead of in cli.md - say the word if you want it in the page anyway.
    • Out of scope, left alone: the daemon WebSocket frame table and the stdin-host paragraph still say user_message. That is the daemon binding, a different surface, so I did not touch it.

    Create a PR - already opened as #895.
    | Branch | PR #895

  6. inference-gateway-releaser commented on Oct 4, 2026

    @inference-gateway-releaser
    Contributor

    🎉 This issue has been resolved in version 0.9.21 🎉

    The release is available on GitHub release

    Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationreleased

    Type

    Projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions