Skip to content

[FEATURE] EPIC - Consolidate events and external communication behind infer daemon #1396

Closed
18 of 18 issues completed
Closed

Description

@edenreich

Summary

Consolidate how external systems talk to the agent. One long-lived infer daemon owns every external connection, every client speaks one event contract, and logs land in one place.

Before

Four client families reached the agent four different ways:

  • Desktop app
    • It spawns infer headless --format ag-ui per prompt, derives busy state from the process, and cancels with SIGKILL.
    • It loads history with infer conversations show --format json.
    • It runs its own copy of the extension panel protocol (backend/src/browser_bridge.rs: chat_event envelope, conversation_snapshot built from JSONL, request_id approvals).
    • It relays browser_command to each child CLI's bridge on port 52790.
  • opentask extension
    • It talks to whichever infer chat holds port 52789, through a bespoke chat_event envelope around AG-UI.
    • One RUN_STARTED brackets the whole connection, so the panel guesses busy state from TOOL_CALL_START / TEXT_MESSAGE_END.
    • Approvals use a second dialect (request_id / action) next to the headless ipc one (tool_call_id / approved).
  • Telegram, scheduler and heartbeat: infer daemon spawns infer headless per message or job through internal/platform/agentrunner.
  • Logs are split per process into ~/.infer/logs/<prefix>-<date>.log.

Landed so far

Target

desktop app ───────────┐
opentask extension ────┼── AG-UI WebSocket binding ──┐
infer chat / headless ─┘   (browser clients)         ├── infer daemon ── session workers
Telegram ──── in-process client of the registry ─────┘        │          (one per thread, AG-UI over stdio)
                                                              ├── scheduler and heartbeat
                                                              │   (one infer headless per job)
                                                              └── one log
  • infer daemon owns every external connection and a thread registry. A thread is a project dir plus a conversation id.
  • Each thread runs in a long-lived worker process the daemon supervises. Workers keep their own project cwd and config and crash isolation. They can move in-process later.
  • One wire vocabulary on every transport. A frame with an uppercase type is an AG-UI event and belongs to a run. A frame with a lowercase type is an app frame, in either direction. Both are identical on worker stdio and on the daemon WebSocket.
  • Each agent turn is one run: RUN_STARTED, then exactly one RUN_FINISHED or RUN_ERROR. A stopped turn ends with outcome cancelled.
  • Standard AG-UI first. Approvals and questions are interrupts, a prompt is a RunAgentInput, token counts are usage, and progress is state and activity events. CUSTOM events and app frames are the last resort.
  • Browser use and computer use are paused the same way: the client stops the run and continues with a new one. The state of the extension connection is an app frame, because it belongs to a connection and not to a run.
  • The protocol_version handshake is lenient. Any valid-token hello is accepted, and clients show an "update" state on a mismatch.

Layering

  • internal/protocols/agui knows the protocol and nothing else: Run writes the events of one run, and Binding and Dial are the two ends of the socket.
  • Each context owns what it puts on the wire. browser owns the browser frames, the client kinds, the handshake and the extension relay. computer owns the CUSTOM events it publishes. presentation/headless maps agent chat events onto a run and answers the panel frames. sessions owns the thread registry and imports no protocol.
  • cmd/daemon composes them behind the binding's one handler.

Standard AG-UI first

The less of the wire that is ours, the less every client has to learn. Upstream froze spec/1.0 of ag-ui-protocol/ag-ui (schema.json and conformance/streams), and it covers most of what the CLI carried in events and frames of its own. CUSTOM is a legitimate part of AG-UI, the extension point for an application's own events, and it stays the last resort.

Rules for every ticket of this epic:

  • A standard AG-UI event or field is used whenever one fits. A CUSTOM event or an app frame needs a reason the protocol cannot cover
  • Every frame with an uppercase type validates against the upstream schema
  • Every event is written between RUN_STARTED and the run's terminal event
  • What is left in CUSTOM carries a name and a value that is never absent

#1419 moves what already landed:

Ours today Standard AG-UI
CUSTOM approval_request / approval_resolved, the approval_response frame Outcome interrupt with reason: "tool_call", answered by a resume entry
CUSTOM user_question_request, the user_question_response frame An interrupt with reason: "input_required" and a responseSchema
CUSTOM computer_use_paused / computer_use_resumed, the computer_use_control frame Stopping the run (outcome cancelled) and continuing with a new run
CUSTOM token_usage usage on the terminal event, and the state key usage
CUSTOM background_tasks, screen_recording State keys
CUSTOM agent_status, judge_verdict ACTIVITY_SNAPSHOT
The user_message frame A frame that carries a RunAgentInput
MESSAGES_SNAPSHOT outside a run MESSAGES_SNAPSHOT inside a run

What stays ours, because AG-UI has nothing for it:

  • The handshake (browser_hello, browser_hello_ack)
  • Opening a thread (new_session, resume_conversation) and stopping a run (interrupt)
  • The panel requests and their replies (list_*, select_model, set_mode, tool_request)
  • The browser commands (browser_command, browser_result)
  • The state of the extension connection (browser_extension_status)

Rollout

v0.220.0 (2026-09-30) speaks bare AG-UI on the binding, and infer chat no longer hosts the extension panel. The extension release carrying inference-gateway/opentask#213 speaks that contract, and the desktop release carrying inference-gateway/desktop#374 stops holding port 52789 and drives chats through the daemon. Browser commands are unchanged on the wire. Until those two client releases ship, the released extension and desktop app break against v0.220.0.

Decisions

  • infer chat stays standalone. Its in-process extension panel mirror retired, and the panel shows daemon threads.
  • infer chat and a standalone infer headless reach the browser as browser clients of the daemon and start it on demand.
  • infer headless stays for CI, scripts and infer-action. Agent-tool subagents are unchanged.
  • Scheduled jobs and heartbeat wake-ups keep running as one-shot infer headless inside the daemon. Each is one process per run either way, and no client follows a job run.
  • Existing issues are edited in place.

Phases

  1. Ground work in the CLI
  2. The daemon
  3. Standard AG-UI
  4. Browser-use and computer-use events
  5. Clients
  6. Docs

Out of scope

  • In-process sessions inside the daemon.
  • A published JSON schema for the CUSTOM event values in inference-gateway/schemas. Add it once the hand-written Rust and TypeScript decoders start to drift.
  • Moving infer chat onto the daemon.
  • Moving scheduled jobs and heartbeat wake-ups onto session workers.
  • Modelling the browser commands as AG-UI frontend tools.
  • Renaming the browser_hello and browser_hello_ack frames, which is a protocol version bump across the clients.

Acceptance Criteria

Sub-issues

Sub-issues

18 of 18 Issues completed
Loading 18 sub-issues

Activity

  1. added
    enhancement
    on Sep 28, 2026
  2. moved this to Todo in 2026on Sep 28, 2026
  3. moved this from In progress to Done in 2026on Oct 1, 2026
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

    enhancement

    Projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions