Skip to content

[FEATURE] Long-lived headless session worker that runs one AG-UI run per user_message #1398

Description

@edenreich

Part of #1396

Depends on #1395, #1397

Summary

The daemon runs each thread in a long-lived worker process instead of one infer headless process per prompt. The worker is headless in a serve mode: it stays alive, runs one agent turn per user_message it reads on stdin, and writes one AG-UI run per turn on stdout. It builds on the stdin control loop headless already has (internal/presentation/headless/control.go: approval_response, user_question_response, user_message, computer_use_control).

Stdout carries AG-UI events (uppercase type) and stdin carries app frames (lowercase type). That is the same vocabulary the daemon WebSocket binding speaks, so the daemon relays lines without translating them.

Browser tools reach the extension through the ExtensionRequest seam from #1395. In the worker it writes a browser_command line on stdout and waits for the matching browser_result line on stdin, so no worker binds a port.

Acceptance Criteria

  • infer headless --serve --session-id <id> starts without a task and waits for user_message on stdin
  • Each user_message runs one turn, emitted as RUN_STARTED then exactly one RUN_FINISHED or RUN_ERROR, with threadId set to the conversation id
  • A user_message that arrives while a turn runs is queued and drained as today
  • A new stdin frame {"type":"interrupt"} cancels the running turn, which ends with outcome cancelled
  • approval_response, user_question_response and computer_use_control keep their shapes and behaviour
  • With browser_use.backend: extension, browser tools write browser_command frames on stdout and read browser_result frames on stdin, and the worker binds no port
  • The first run of a resumed session starts with MESSAGES_SNAPSHOT (from [TASK] Refactor the AG-UI encoder into a per-run type shared by stdout and the WebSocket binding #1397)
  • stdin EOF shuts the worker down cleanly, including the gateway, MCP servers and containers it started
  • A test drives a worker through scripted stdin under INFER_GATEWAY_MOCK=true and asserts one run per turn, a cancelled turn and a browser command round trip

Activity

  1. added
    enhancement
    on Sep 28, 2026
  2. moved this to Todo in 2026on Sep 28, 2026
  3. inference-gateway-releaser commented on Sep 30, 2026

    @inference-gateway-releaser
    Contributor

    🎉 This issue has been resolved in version 0.219.0 🎉

    The release is available on:

    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

    enhancementreleased

    Projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions