Skip to content

[DOCS] headless --serve worker: one AG-UI run per user_message over stdio #862

Closed

Description

@edenreich

Summary

inference-gateway/cli PR #1410 (issue inference-gateway/cli#1398, part of inference-gateway/cli#1396) adds infer headless --serve, a long-lived worker that keeps one process per thread instead of one infer headless process per prompt:

  • infer headless --serve --session-id <id> takes no task and implies --format ag-ui. It runs one agent turn per user_message frame read on stdin and writes each turn to stdout as one AG-UI run: RUN_STARTED with threadId set to the conversation id, then exactly one RUN_FINISHED or RUN_ERROR.
  • Stdin carries app frames (lowercase type) and stdout carries AG-UI events (uppercase type), the same vocabulary the daemon WebSocket binding speaks, so a host relays lines without translating them.
  • A user_message sent mid-turn is queued and drained into the running turn. Anything still queued when a turn ends starts the next turn.
  • A new {"type":"interrupt"} stdin frame cancels the running turn, which ends with RUN_FINISHED outcome cancelled.
  • approval_response, user_question_response and computer_use_control keep their shapes and behaviour.
  • With browser_use.backend: extension the worker binds no port. A browser tool writes a browser_command line on stdout and waits for the browser_result line with the same id on stdin, so the host relays both to the extension.
  • Only the first run of a resumed session opens with MESSAGES_SNAPSHOT.
  • Stdin EOF lets the running turn and any queued messages finish, then shuts the worker down together with the gateway, MCP servers and containers it started. A host sends interrupt first for a faster stop.

The CLI's own reference pages docs/ag-ui-output.md (new "Serve worker" section) and docs/commands-reference.md (--serve flag) were updated inside the PR. Affected org documentation: wherever infer headless, its flags, the AG-UI headless output or the desktop sidecar wiring are described, and any page on the browser extension bridge that says browser tools always reach the extension over the local WebSocket port.

Acceptance Criteria

  • The headless command reference documents --serve: no task argument, implied --format ag-ui, one AG-UI run per user_message, and an example with --session-id
  • The AG-UI headless output reference documents the serve worker stdin frames (user_message, interrupt, browser_result, and the unchanged approval_response, user_question_response and computer_use_control) and the one-run-per-turn contract with threadId set to the conversation id
  • The docs describe the interrupt frame ending the running turn with RUN_FINISHED outcome cancelled
  • The browser extension docs explain that a serve worker binds no port and relays browser_command / browser_result frames over stdout and stdin
  • The docs describe the stdin EOF shutdown behaviour (queued turns finish, then the gateway, MCP servers and containers stop) and recommend sending interrupt first for a fast stop
  • The new sections link back to feat(headless): add a --serve worker that runs one AG-UI run per user_message cli#1410

Activity

  1. added
    documentation
    on Sep 29, 2026
  2. added theissue type on Sep 29, 2026
  3. edenreich commented on Sep 29, 2026

    @edenreich
    ContributorAuthor

    @claude can you work on this?

  4. inference-gateway-maintainer commented on Sep 29, 2026

    @inference-gateway-maintainer
    Contributor

    Claude finished @edenreich's task in 2m 41s —— View job • docs/issue-862-20260929-1049 • [Create PR ➔](https://github.com/inference-gateway/docs/compare/main...docs/issue-862-20260929-1049?quick_pull=1&title=Issue%20%23862%3A%20Changes%20from%20Claude&body=This%20PR%20addresses%20issue%20%23862%0A%0AGenerated%20with%20%5BClaude%20Code%5D(https%3A%2F%2Fclaude.ai%2Fcode)


    Done - PR #863 opened

    • Gather context (locate headless / AG-UI / browser extension sections)
    • Document --serve in the headless command reference
    • Document serve-worker stdin frames + one-run-per-turn contract
    • Document interrupt -> RUN_FINISHED outcome cancelled
    • Document extension-backend port-less relay over stdout/stdin
    • Document stdin EOF shutdown
    • Validate (lint:md, format:check, build) and open PR
    • Link the new sections back to inference-gateway/cli#1410 - not done, see below

    What changed

    cli.md gets a new Serve worker (--serve) section at the end of Headless Agent Stream Output: no task argument, implied --format ag-ui, a --session-id example, a sample stdin/stdout exchange, and the one-run-per-turn contract with threadId set to the conversation id. It carries a stdin frame table (user_message queued mid-turn and drained into the running turn, interrupt ending the turn cancelled, browser_result, plus the unchanged approval_response / user_question_response / computer_use_control), a Browser tools without a port subsection, and a Shutdown subsection for the stdin-EOF behaviour with the interrupt-first fast stop. Also: the first-run-only MESSAGES_SNAPSHOT note, a core-commands row, the daemon's Session workers row now pointing at the serve worker, and the ag-ui format bullet noting --serve implies it.

    opentask.md bridge protocol now states a standalone serve worker binds no port and relays browser_command / browser_result over stdio.

    The one item left out

    The repo's AGENTS.md forbids referencing GitHub issues or pull requests in doc content ("provenance belongs in the generated CHANGELOG.md"), so I did not add the cli#1410 link. The PR body records it instead. Say the word if you want the convention overridden here.

    Validated: bun run lint:md, bun run format:check, bun run build all pass.
    | Branch | PR #863

  5. inference-gateway-releaser commented on Sep 30, 2026

    @inference-gateway-releaser
    Contributor

    🎉 This issue has been resolved in version 0.9.19 🎉

    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