Skip to content

fix: route browser-use through the infer daemon and make agui a general-purpose protocol - #1413

Merged
edenreich merged 13 commits into
mainfrom
fix/issue-1400
Sep 29, 2026
Merged

edenreich merged 13 commits into
mainfrom
fix/issue-1400

Conversation

@inference-gateway-maintainer

@inference-gateway-maintainer inference-gateway-maintainer Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Resolves #1400

Summary

Browser-use on the extension backend now reaches the browser only through the infer daemon's extension connection. Only the daemon binds the binding port. infer chat and a standalone infer headless dial the binding as browser clients (client: "browser" in the hello) and start infer daemon on the first browser call when nothing is listening.

This PR also reverses a dependency that pointed the wrong way. internal/protocols/agui used to know its users: it named the extension, desktop and browser clients, owned the browser relay and the daemon client, imported the sessions ports, mapped the agent's chat events, answered the panel frames and published the computer context's events. It is now a general-purpose protocol package that names no client, no context and no host. Its only internal import is the logger. Everything else imports it.

Architecture

cmd/daemon ─────► agui.Binding                 generic socket server
    │      ─────► browserinfra.ExtensionRelay ──► agui   (browser RPC, host end)
    │      ─────► sessions.Registry                       (imports no protocol)
    └ bindingHandler: the relay claims browser frames, the registry gets the rest

internal/container ─► browserinfra.ExtensionClient ──► agui.Dial
                                   ▲ EnsureHost hook ◄── daemon.EnsureRunning

presentation/headless ─► RunEncoder ──► agui.Run      (agent events onto a run)
                      ─► Panel      ──► agui.Run      (panel frames of a serve worker)
                      ─► computer.PublishedEvent ──► agui.CustomEvent

Changes

agui, general purpose

  • Binding owns the listener, the Origin check, the token handshake, the connections and their pings, and hands every frame to a Handler (Attach, Handle, Detach). Dial is the client end over the same Handler.
  • The handshake frame names and the accepted origins come in through BindingConfig and DialConfig. A Conn carries the client kind its hello declared as an opaque string.
  • Run writes the events of one run from plain values: text and reasoning framing, tool calls, snapshots and CUSTOM events. It guarantees exactly one terminal RUN_FINISHED or RUN_ERROR, and CustomEvent.Resumes discards the failure an interruption left.
  • The AG-UI SDK stays confined to agui, which exposes Message, Role, ToolCall and FunctionCall for a MESSAGES_SNAPSHOT.
  • The /artifacts/ route is removed from the binding. The daemon never served it, and the protocol doc already says it answers 404 until [FEATURE] Serve generated artifacts per project from the infer daemon's AG-UI binding #1414 serves it per project.

browser, on top of agui

  • extension_wire.go owns the wire vocabulary: frame names, client kinds, BindingHandshake and AllowExtensionOrigin.
  • ExtensionRelay is the host end. It keeps the one extension connection, replaces it when the extension reconnects, and drives every browser_command through it one at a time. It always answers with a browser_result that carries a failure in its error.
  • ExtensionClient is the client end and the ExtensionRequest of infer chat and a standalone headless. Dialing and writes are serialized, so parallel Browser calls share one socket. Its EnsureHost hook runs before each dial.

headless, on top of agui

  • RunEncoder maps agent chat events onto a Run. It takes Publish functions and renders any event it does not map as the CUSTOM event its owner returns.
  • Panel answers the panel frames of a --serve worker. The container builds it.

computer, on top of agui

  • computer.PublishedEvent owns computer_use_paused, computer_use_resumed and screen_recording.

daemon and sessions

  • internal/daemon holds EnsureRunning, the on-demand daemon boot. It starts infer daemon in the background with plain os/exec and waits for the port.
  • sessions drops the EnsureDaemon and Threads ports, which had no consumer left. It keeps Client, Worker, LaunchWorker and BrowserRelay.
  • sessions.Registry.RouteBrowser routes session workers' browser_command stdout lines through the relay and writes the browser_result back to the worker's stdin by id, so workers bind no port.
  • cmd/daemon wires the relay and the registry behind the binding's one handler. A binding port held by another process fails the daemon's boot.

Enforcement

  • depguard replaces browser-does-not-import-agui with agui-imports-are-closed, a strict allow-list. agui may import the standard library, the AG-UI SDK's events and types, google/uuid, gorilla/websocket and platform/logger. Its tests may also import the package under test and the generated Handler fake. Every other import is rejected. The agui README records the list.

Cross-platform process handling

  • Session workers stop with an interrupt frame and stdin EOF instead of SIGTERM, which Windows does not support.
  • Custom tools kill their whole process tree on timeout or cancel through gopsutil on Linux, macOS and Windows.
  • utils.ProcessAlive checks liveness through gopsutil's PidExists on every platform.

Removed

  • ServiceContainer.StartExtensionBridge, the bridge's port takeover and the daemon's listen retry.

Behaviour notes

  • The wire is unchanged. Frame names, the handshake, error wording and CUSTOM event payloads are the same, so opentask and the desktop app need no release.
  • The binding no longer logs a client's extension_version. It logs the client kind and the protocol version.
  • An auto-started daemon runs in the background and outlives the infer process that started it. It shares that process's terminal, so closing the terminal stops it too, and the next Browser call starts another.
  • The TUI's browser indicator updates when a Browser tool runs.
  • A command whose sender gave up still runs to its own deadline and holds the one-browser gate until then.

Docs

Not in this PR

  • Renaming the wire frames browser_hello and browser_hello_ack. That is a protocol version bump across opentask and the desktop app.

Tests

  • Test doubles are counterfeiter output: FakeHandler in tests/mocks/agui and FakeShellHistoryStorage in tests/mocks/storage, both registered in mocks:generate.

  • agui run: message framing, tool calls, snapshots, one event per write, and the one terminal event for success, failure, cancellation and resume.

  • agui binding: handshake, bad hello, empty token, the Origin policy, frames reaching the handler, detach on close, overflow of a stalled client, and Dial against a binding.

  • browser relay: round trip, extension replacement, disconnect failing pending commands, client commands answered on the posting connection only, serialization, and the no-extension wording.

  • browser client: routing by id, concurrent first calls sharing one socket, the boot-failure wording, and a driver call through client, binding and relay.

  • headless: the encoder and panel tests moved with the code and assert the same AG-UI output.

  • computer: the three CUSTOM events on the AG-UI stream and the resume clearing a cancellation.

  • daemon.EnsureRunning: a listening daemon is left alone, and a failed start names its cause.

  • Registry: two workers' commands routed by id, each answered on its own stdin.

  • Manual: a real infer daemon with a scripted extension peer. The client got the no-extension error before the extension connected and the navigate result after.

@edenreich

Copy link
Copy Markdown
Contributor

@infer can you finalise this PR? it's not ready for a review - please finish the existing todos.

@inference-gateway-maintainer

inference-gateway-maintainer Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor Author

Model: ollama_cloud/glm-5.3-flash · View Job

Todos

Pull Request

#1413

✅ Infer Result: Success

The PR is finalized. Here is the state of PR #1413:

Summary

The salvage run's feature work (routing browser-use through the infer daemon's extension connection, resolving #1400) was already complete on the branch; this run finished the remaining todos:

Fixed this session (commit a858152, pushed):

  • Lint failure (the one red CI check): errcheck on defer conn.Close() in internal/protocols/agui/daemon_client_test.go - now acks the close with _ =.
  • Refreshed the ExtensionDriver.ExtensionRequest doc comment, which the change made stale (the container now injects the daemon client's Request, not the bridge's).
  • Included the README trailing-whitespace normalization the repo's own markdownlint --fix precommit step applied.

Acceptance criteria of #1400 - all verified against the code and tests:

  • Worker browser_command routing by id back to the worker's stdin: sessions.Registry.RouteBrowser + relayBrowserCommand; covered by TestRegistryRoutesWorkerBrowserCommands (two workers, failed relay reported as the result's error, clients never see browser frames).
  • Serialization across threads: one-browser gate in Relay; covered by TestExtensionBridgeSerializesClientCommands.
  • infer chat / standalone infer headless as daemon clients through the ExtensionRequest seam with on-demand daemon start: NewDaemonClient in the container, detached spawn infer daemon; covered by TestDaemonClientRoutesCommandsByIdOverTheSocket and TestDaemonClientReportsWhyNoDaemonStarted.
  • Only the daemon binds the port: StartExtensionBridge, retryStart and the daemon's listenBinding retry removed (port takeover test removed too).
  • Error wording kept: timed out waiting for the browser extension to <action> and no browser extension connected on port <port> both surface through the driver unchanged.

Checks: full unit suite (go test -tags purego ./...) passes, task vet passes, task precommit:run (mod tidy, fmt, lint incl. golangci-lint: 0 issues) passes. The earlier lint CI failure is fixed.

PR bookkeeping: replaced the auto-salvage body with a real description, retitled to "fix: route browser-use through the infer daemon's extension connection", and marked ready for review. Since this is a user-facing protocol/behavior change, I filed the docs follow-up: inference-gateway/docs#864. No release actions taken (semantic-release handles versioning from the Conventional Commits on merge).

Model: ollama_cloud/glm-5.3-flash · Exit Code: 0 · Duration: 7m 45s

Tokens: 2,866,325 in · 17,035 out · 2,883,360 total (39 requests)

Tool calls: 53 total · 100% success rate

Traces
Session: 1790707561-48303cf8

session (headless, success)                                                                        7m38s
├── chat ollama_cloud/glm-5.3-flash                                                                 4.4s
│   ╰── POST /v1/chat/completions [inference-gateway, server]                                       4.4s
│       ╰── POST 127.0.0.1:8080/proxy/ollama_cloud/chat/completions [inference-gateway, client]     4.4s
│           ╰── POST /proxy/:provider/*path [inference-gateway, server]                             4.4s
│               ╰── POST ollama.com/v1/chat/completions [inference-gateway, client]                 4.4s
├── execute_tool TodoWrite call_3cxkjaaf                                                            68µs
├── chat ollama_cloud/glm-5.3-flash                                                                 3.8s
│   ╰── POST /v1/chat/completions [inference-gateway, server]                                       3.8s
│       ╰── POST 127.0.0.1:8080/proxy/ollama_cloud/chat/completions [inference-gateway, client]     3.8s
│           ╰── POST /proxy/:provider/*path [inference-gateway, server]                             3.8s
│               ╰── POST ollama.com/v1/chat/completions [inference-gateway, client]                 3.8s
├── execute_tool Bash call_r40owt23                                                                  5ms
├── execute_tool Bash call_lhmcu0a2                                                                  8ms
├── execute_tool Bash call_jj9blyix                                                                859ms
├── chat ollama_cloud/glm-5.3-flash                                                                 3.2s
│   ╰── POST /v1/chat/completions [inference-gateway, server]                                       3.2s
│       ╰── POST 127.0.0.1:8080/proxy/ollama_cloud/chat/completions [inference-gateway, client]     3.2s
│           ╰── POST /proxy/:provider/*path [inference-gateway, server]                             3.2s
│               ╰── POST ollama.com/v1/chat/completions [inference-gateway, client]                 3.2s
├── execute_tool Bash call_tjo8kefy                                                                501ms
├── execute_tool Bash call_2fh827h6                                                                 1.6s [error: tool_error]
├── chat ollama_cloud/glm-5.3-flash                                                                 3.0s
│   ╰── POST /v1/chat/completions [inference-gateway, server]                                       3.0s
│       ╰── POST 127.0.0.1:8080/proxy/ollama_cloud/chat/completions [inference-gateway, client]     3.0s
│           ╰── POST /proxy/:provider/*path [inference-gateway, server]                             3.0s
│               ╰── POST ollama.com/v1/chat/completions [inference-gateway, client]                 3.0s
├── execute_tool Bash call_dl6mx2uk                                                                 1.4s
├── chat ollama_cloud/glm-5.3-flash                                                                 3.9s
│   ╰── POST /v1/chat/completions [inference-gateway, server]                                       3.9s
│       ╰── POST 127.0.0.1:8080/proxy/ollama_cloud/chat/completions [inference-gateway, client]     3.9s
│           ╰── POST /proxy/:provider/*path [inference-gateway, server]                             3.8s
│               ╰── POST ollama.com/v1/chat/completions [inference-gateway, client]                 3.8s
├── execute_tool Bash call_gpzspyqf                                                                  6ms
├── execute_tool Read call_jhhn4g1w                                                                625µs
├── chat ollama_cloud/glm-5.3-flash                                                                 3.2s
│   ╰── POST /v1/chat/completions [inference-gateway, server]                                       3.2s
│       ╰── POST 127.0.0.1:8080/proxy/ollama_cloud/chat/completions [inference-gateway, client]     3.2s
│           ╰── POST /proxy/:provider/*path [inference-gateway, server]                             3.2s
│               ╰── POST ollama.com/v1/chat/completions [inference-gateway, client]                 3.2s
├── execute_tool Bash call_tgbfk3lm                                                                  6ms
├── chat ollama_cloud/glm-5.3-flash                                                                 1.9s
│   ╰── POST /v1/chat/completions [inference-gateway, server]                                       1.9s
│       ╰── POST 127.0.0.1:8080/proxy/ollama_cloud/chat/completions [inference-gateway, client]     1.9s
│           ╰── POST /proxy/:provider/*path [inference-gateway, server]                             1.9s
│               ╰── POST ollama.com/v1/chat/completions [inference-gateway, client]                 1.9s
├── execute_tool Bash call_n4sq8c4f                                                                  9ms
├── chat ollama_cloud/glm-5.3-flash                                                                 6.5s
│   ╰── POST /v1/chat/completions [inference-gateway, server]                                       6.4s
│       ╰── POST 127.0.0.1:8080/proxy/ollama_cloud/chat/completions [inference-gateway, client]     6.4s
│           ╰── POST /proxy/:provider/*path [inference-gateway, server]                             6.4s
│               ╰── POST ollama.com/v1/chat/completions [inference-gateway, client]                 6.4s
├── execute_tool Bash call_h18mug57                                                                  9ms
├── execute_tool Read call_19jfj4nj                                                                589µs
├── chat ollama_cloud/glm-5.3-flash                                                                 2.4s
│   ╰── POST /v1/chat/completions [inference-gateway, server]                                       2.4s
│       ╰── POST 127.0.0.1:8080/proxy/ollama_cloud/chat/completions [inference-gateway, client]     2.4s
│           ╰── POST /proxy/:provider/*path [inference-gateway, server]                             2.4s
│               ╰── POST ollama.com/v1/chat/completions [inference-gateway, client]                 2.4s
├── execute_tool Read call_37sitdc0                                                                761µs
├── execute_tool Read call_cc86oa6f                                                                688µs
├── execute_tool Bash call_ikzpdgvt                                                                  6ms
├── chat ollama_cloud/glm-5.3-flash                                                                 8.6s
│   ╰── POST /v1/chat/completions [inference-gateway, server]                                       8.6s
│       ╰── POST 127.0.0.1:8080/proxy/ollama_cloud/chat/completions [inference-gateway, client]     8.6s
│           ╰── POST /proxy/:provider/*path [inference-gateway, server]                             8.6s
│               ╰── POST ollama.com/v1/chat/completions [inference-gateway, client]                 8.6s
├── execute_tool Bash call_33kmg1hb                                                                  7ms
├── execute_tool Grep call_s19wtb61                                                                862ms
├── chat ollama_cloud/glm-5.3-flash                                                                 8.5s
│   ╰── POST /v1/chat/completions [inference-gateway, server]                                       8.5s
│       ╰── POST 127.0.0.1:8080/proxy/ollama_cloud/chat/completions [inference-gateway, client]     8.5s
│           ╰── POST /proxy/:provider/*path [inference-gateway, server]                             8.5s
│               ╰── POST ollama.com/v1/chat/completions [inference-gateway, client]                 8.5s
├── execute_tool Read call_ab30c3er                                                                523µs
├── chat ollama_cloud/glm-5.3-flash                                                                14.9s
│   ╰── POST /v1/chat/completions [inference-gateway, server]                                      14.8s
│       ╰── POST 127.0.0.1:8080/proxy/ollama_cloud/chat/completions [inference-gateway, client]    14.8s
│           ╰── POST /proxy/:provider/*path [inference-gateway, server]                            14.8s
│               ╰── POST ollama.com/v1/chat/completions [inference-gateway, client]                14.8s
├── execute_tool Grep call_6iqvwy2f                                                                656ms
├── execute_tool Grep call_6sl66uyn                                                                  1ms
├── chat ollama_cloud/glm-5.3-flash                                                                 5.4s
│   ╰── POST /v1/chat/completions [inference-gateway, server]                                       5.4s
│       ╰── POST 127.0.0.1:8080/proxy/ollama_cloud/chat/completions [inference-gateway, client]     5.4s
│           ╰── POST /proxy/:provider/*path [inference-gateway, server]                             5.4s
│               ╰── POST ollama.com/v1/chat/completions [inference-gateway, client]                 5.4s
├── execute_tool TodoWrite call_1b2222b0                                                            81µs
├── chat ollama_cloud/glm-5.3-flash                                                                 2.3s
│   ╰── POST /v1/chat/completions [inference-gateway, server]                                       2.2s
│       ╰── POST 127.0.0.1:8080/proxy/ollama_cloud/chat/completions [inference-gateway, client]     2.2s
│           ╰── POST /proxy/:provider/*path [inference-gateway, server]                             2.2s
│               ╰── POST ollama.com/v1/chat/completions [inference-gateway, client]                 2.2s
├── execute_tool Edit call_nlswot8n                                                                840µs
├── chat ollama_cloud/glm-5.3-flash                                                                10.0s
│   ╰── POST /v1/chat/completions [inference-gateway, server]                                      10.0s
│       ╰── POST 127.0.0.1:8080/proxy/ollama_cloud/chat/completions [inference-gateway, client]     9.9s
│           ╰── POST /proxy/:provider/*path [inference-gateway, server]                             9.9s
│               ╰── POST ollama.com/v1/chat/completions [inference-gateway, client]                 9.9s
├── execute_tool Edit call_emkqedho                                                                900µs
├── chat ollama_cloud/glm-5.3-flash                                                                 3.4s
│   ╰── POST /v1/chat/completions [inference-gateway, server]                                       3.4s
│       ╰── POST 127.0.0.1:8080/proxy/ollama_cloud/chat/completions [inference-gateway, client]     3.4s
│           ╰── POST /proxy/:provider/*path [inference-gateway, server]                             3.4s
│               ╰── POST ollama.com/v1/chat/completions [inference-gateway, client]                 3.4s
├── execute_tool Bash call_yyq6rbz7                                                                2m50s
├── chat ollama_cloud/glm-5.3-flash                                                                 4.6s
│   ╰── POST /v1/chat/completions [inference-gateway, server]                                       4.6s
│       ╰── POST 127.0.0.1:8080/proxy/ollama_cloud/chat/completions [inference-gateway, client]     4.6s
│           ╰── POST /proxy/:provider/*path [inference-gateway, server]                             4.6s
│               ╰── POST ollama.com/v1/chat/completions [inference-gateway, client]                 4.6s
├── execute_tool TodoWrite call_fvjg6045                                                            57µs
├── execute_tool Bash call_1l34bx92                                                                  1ms
├── chat ollama_cloud/glm-5.3-flash                                                                23.4s
│   ╰── POST /v1/chat/completions [inference-gateway, server]                                      23.4s
│       ╰── POST 127.0.0.1:8080/proxy/ollama_cloud/chat/completions [inference-gateway, client]    23.3s
│           ╰── POST /proxy/:provider/*path [inference-gateway, server]                            23.3s
│               ╰── POST ollama.com/v1/chat/completions [inference-gateway, client]                23.3s
├── execute_tool Write call_ou2hdio7                                                                 2ms
├── chat ollama_cloud/glm-5.3-flash                                                                 1.7s
│   ╰── POST /v1/chat/completions [inference-gateway, server]                                       1.6s
│       ╰── POST 127.0.0.1:8080/proxy/ollama_cloud/chat/completions [inference-gateway, client]     1.6s
│           ╰── POST /proxy/:provider/*path [inference-gateway, server]                             1.6s
│               ╰── POST ollama.com/v1/chat/completions [inference-gateway, client]                 1.6s
├── chat ollama_cloud/glm-5.3-flash                                                                 3.3s
│   ╰── POST /v1/chat/completions [inference-gateway, server]                                       3.3s
│       ╰── POST 127.0.0.1:8080/proxy/ollama_cloud/chat/completions [inference-gateway, client]     3.2s
│           ╰── POST /proxy/:provider/*path [inference-gateway, server]                             3.2s
│               ╰── POST ollama.com/v1/chat/completions [inference-gateway, client]                 3.2s
├── execute_tool Wait call_qe8uge8h                                                                 8.5s
├── chat ollama_cloud/glm-5.3-flash                                                                 5.8s
│   ╰── POST /v1/chat/completions [inference-gateway, server]                                       5.8s
│       ╰── POST 127.0.0.1:8080/proxy/ollama_cloud/chat/completions [inference-gateway, client]     5.8s
│           ╰── POST /proxy/:provider/*path [inference-gateway, server]                             5.8s
│               ╰── POST ollama.com/v1/chat/completions [inference-gateway, client]                 5.8s
├── execute_tool Bash call_lrg04y2c                                                                16.8s
├── execute_tool Bash call_4rp65kpg                                                                  9ms
├── chat ollama_cloud/glm-5.3-flash                                                                 4.8s
│   ╰── POST /v1/chat/completions [inference-gateway, server]                                       4.7s
│       ╰── POST 127.0.0.1:8080/proxy/ollama_cloud/chat/completions [inference-gateway, client]     4.7s
│           ╰── POST /proxy/:provider/*path [inference-gateway, server]                             4.7s
│               ╰── POST ollama.com/v1/chat/completions [inference-gateway, client]                 4.7s
├── execute_tool Bash call_oolsk3cu                                                                  6ms
├── chat ollama_cloud/glm-5.3-flash                                                                13.7s
│   ╰── POST /v1/chat/completions [inference-gateway, server]                                      13.7s
│       ╰── POST 127.0.0.1:8080/proxy/ollama_cloud/chat/completions [inference-gateway, client]    13.7s
│           ╰── POST /proxy/:provider/*path [inference-gateway, server]                            13.7s
│               ╰── POST ollama.com/v1/chat/completions [inference-gateway, client]                13.7s
├── execute_tool Bash call_1fopy2t8                                                                 11ms
├── chat ollama_cloud/glm-5.3-flash                                                                 1.4s
│   ╰── POST /v1/chat/completions [inference-gateway, server]                                       1.3s
│       ╰── POST 127.0.0.1:8080/proxy/ollama_cloud/chat/completions [inference-gateway, client]     1.3s
│           ╰── POST /proxy/:provider/*path [inference-gateway, server]                             1.3s
│               ╰── POST ollama.com/v1/chat/completions [inference-gateway, client]                 1.3s
├── execute_tool Bash call_gcgvkbaj                                                                17.6s
├── chat ollama_cloud/glm-5.3-flash                                                                 1.5s
│   ╰── POST /v1/chat/completions [inference-gateway, server]                                       1.4s
│       ╰── POST 127.0.0.1:8080/proxy/ollama_cloud/chat/completions [inference-gateway, client]     1.4s
│           ╰── POST /proxy/:provider/*path [inference-gateway, server]                             1.4s
│               ╰── POST ollama.com/v1/chat/completions [inference-gateway, client]                 1.4s
├── execute_tool Bash call_iu4ek8pa                                                                 2.3s
├── chat ollama_cloud/glm-5.3-flash                                                                 5.8s
│   ╰── POST /v1/chat/completions [inference-gateway, server]                                       5.8s
│       ╰── POST 127.0.0.1:8080/proxy/ollama_cloud/chat/completions [inference-gateway, client]     5.7s
│           ╰── POST /proxy/:provider/*path [inference-gateway, server]                             5.7s
│               ╰── POST ollama.com/v1/chat/completions [inference-gateway, client]                 5.7s
├── execute_tool TodoWrite call_mns9habx                                                            75µs
├── execute_tool Bash call_9qy5bh8m                                                                 1.6s
├── chat ollama_cloud/glm-5.3-flash                                                                 1.7s
│   ╰── POST /v1/chat/completions [inference-gateway, server]                                       1.7s
│       ╰── POST 127.0.0.1:8080/proxy/ollama_cloud/chat/completions [inference-gateway, client]     1.6s
│           ╰── POST /proxy/:provider/*path [inference-gateway, server]                             1.6s
│               ╰── POST ollama.com/v1/chat/completions [inference-gateway, client]                 1.6s
├── execute_tool Bash call_saujclh0                                                                 1.4s
├── chat ollama_cloud/glm-5.3-flash                                                                 1.7s
│   ╰── POST /v1/chat/completions [inference-gateway, server]                                       1.7s
│       ╰── POST 127.0.0.1:8080/proxy/ollama_cloud/chat/completions [inference-gateway, client]     1.7s
│           ╰── POST /proxy/:provider/*path [inference-gateway, server]                             1.7s
│               ╰── POST ollama.com/v1/chat/completions [inference-gateway, client]                 1.7s
├── execute_tool Bash call_9udqkjxq                                                                893ms
├── chat ollama_cloud/glm-5.3-flash                                                                 3.0s
│   ╰── POST /v1/chat/completions [inference-gateway, server]                                       3.0s
│       ╰── POST 127.0.0.1:8080/proxy/ollama_cloud/chat/completions [inference-gateway, client]     2.9s
│           ╰── POST /proxy/:provider/*path [inference-gateway, server]                             2.9s
│               ╰── POST ollama.com/v1/chat/completions [inference-gateway, client]                 2.9s
├── chat ollama_cloud/glm-5.3-flash                                                                 5.3s
│   ╰── POST /v1/chat/completions [inference-gateway, server]                                       5.2s
│       ╰── POST 127.0.0.1:8080/proxy/ollama_cloud/chat/completions [inference-gateway, client]     5.2s
│           ╰── POST /proxy/:provider/*path [inference-gateway, server]                             5.2s
│               ╰── POST ollama.com/v1/chat/completions [inference-gateway, client]                 5.2s
├── execute_tool WebFetch call_sznchu21                                                            123ms
├── chat ollama_cloud/glm-5.3-flash                                                                10.9s
│   ╰── POST /v1/chat/completions [inference-gateway, server]                                      10.9s
│       ╰── POST 127.0.0.1:8080/proxy/ollama_cloud/chat/completions [inference-gateway, client]    10.9s
│           ╰── POST /proxy/:provider/*path [inference-gateway, server]                            10.9s
│               ╰── POST ollama.com/v1/chat/completions [inference-gateway, client]                10.9s
├── execute_tool Bash call_hd3ewapk                                                                271ms [error: tool_error]
├── chat ollama_cloud/glm-5.3-flash                                                                 4.5s
│   ╰── POST /v1/chat/completions [inference-gateway, server]                                       4.5s
│       ╰── POST 127.0.0.1:8080/proxy/ollama_cloud/chat/completions [inference-gateway, client]     4.5s
│           ╰── POST /proxy/:provider/*path [inference-gateway, server]                             4.5s
│               ╰── POST ollama.com/v1/chat/completions [inference-gateway, client]                 4.5s
├── execute_tool Bash call_c5xjqymn                                                                503ms
├── chat ollama_cloud/glm-5.3-flash                                                                 2.3s
│   ╰── POST /v1/chat/completions [inference-gateway, server]                                       2.3s
│       ╰── POST 127.0.0.1:8080/proxy/ollama_cloud/chat/completions [inference-gateway, client]     2.3s
│           ╰── POST /proxy/:provider/*path [inference-gateway, server]                             2.3s
│               ╰── POST ollama.com/v1/chat/completions [inference-gateway, client]                 2.3s
├── execute_tool WebFetch call_m90sj5dd                                                            224ms
├── chat ollama_cloud/glm-5.3-flash                                                                10.8s
│   ╰── POST /v1/chat/completions [inference-gateway, server]                                      10.8s
│       ╰── POST 127.0.0.1:8080/proxy/ollama_cloud/chat/completions [inference-gateway, client]    10.7s
│           ╰── POST /proxy/:provider/*path [inference-gateway, server]                            10.7s
│               ╰── POST ollama.com/v1/chat/completions [inference-gateway, client]                10.7s
├── execute_tool Write call_prz22yrp                                                                 1ms
├── chat ollama_cloud/glm-5.3-flash                                                                 3.3s
│   ╰── POST /v1/chat/completions [inference-gateway, server]                                       3.3s
│       ╰── POST 127.0.0.1:8080/proxy/ollama_cloud/chat/completions [inference-gateway, client]     3.3s
│           ╰── POST /proxy/:provider/*path [inference-gateway, server]                             3.3s
│               ╰── POST ollama.com/v1/chat/completions [inference-gateway, client]                 3.3s
├── execute_tool Bash call_ghxmgo9k                                                                 1.6s
├── chat ollama_cloud/glm-5.3-flash                                                                 6.8s
│   ╰── POST /v1/chat/completions [inference-gateway, server]                                       6.8s
│       ╰── POST 127.0.0.1:8080/proxy/ollama_cloud/chat/completions [inference-gateway, client]     6.8s
│           ╰── POST /proxy/:provider/*path [inference-gateway, server]                             6.8s
│               ╰── POST ollama.com/v1/chat/completions [inference-gateway, client]                 6.8s
├── execute_tool TodoWrite call_uzd8o1hq                                                            70µs
├── execute_tool Bash call_xralqa44                                                                  9ms
├── execute_tool Bash call_3dh1a28i                                                                281ms
├── chat ollama_cloud/glm-5.3-flash                                                                 7.2s
│   ╰── POST /v1/chat/completions [inference-gateway, server]                                       7.2s
│       ╰── POST 127.0.0.1:8080/proxy/ollama_cloud/chat/completions [inference-gateway, client]     7.1s
│           ╰── POST /proxy/:provider/*path [inference-gateway, server]                             7.1s
│               ╰── POST ollama.com/v1/chat/completions [inference-gateway, client]                 7.1s
├── execute_tool Memory call_azflzhtl                                                               2.0s
├── chat ollama_cloud/glm-5.3-flash                                                                 3.6s
│   ╰── POST /v1/chat/completions [inference-gateway, server]                                       3.6s
│       ╰── POST 127.0.0.1:8080/proxy/ollama_cloud/chat/completions [inference-gateway, client]     3.6s
│           ╰── POST /proxy/:provider/*path [inference-gateway, server]                             3.6s
│               ╰── POST ollama.com/v1/chat/completions [inference-gateway, client]                 3.6s
├── execute_tool TodoWrite call_fxuv18s1                                                            56µs
╰── chat ollama_cloud/glm-5.3-flash                                                                 9.3s
    ╰── POST /v1/chat/completions [inference-gateway, server]                                       9.3s
        ╰── POST 127.0.0.1:8080/proxy/ollama_cloud/chat/completions [inference-gateway, client]     9.2s
            ╰── POST /proxy/:provider/*path [inference-gateway, server]                             9.2s
                ╰── POST ollama.com/v1/chat/completions [inference-gateway, client]                 9.2s
Stats
Tool Calls

╭───────────┬───────┬───────┬────────╮
│ Tool      │ Calls │ Fail% │ Avg    │
├───────────┼───────┼───────┼────────┤
│ Bash      │ 28    │ 7%    │ 7784ms │
│ TodoWrite │ 6     │ 0%    │ 69µs   │
│ Read      │ 5     │ 0%    │ 614µs  │
│ Grep      │ 3     │ 0%    │ 507ms  │
│ Edit      │ 2     │ 0%    │ 868µs  │
│ WebFetch  │ 2     │ 0%    │ 174ms  │
│ Write     │ 2     │ 0%    │ 2ms    │
│ Wait      │ 1     │ 0%    │ 8500ms │
│ Memory    │ 1     │ 0%    │ 1975ms │
╰───────────┴───────┴───────┴────────╯

Token Usage

╭────────────────────────────┬─────────┬─────────┬────────────┬─────────┬──────╮
│ Model                      │ Prompt  │ Cached  │ Completion │ Total   │ Cost │
├────────────────────────────┼─────────┼─────────┼────────────┼─────────┼──────┤
│ ollama_cloud/glm-5.3-flash │ 2866325 │ 2347520 │ 17035      │ 2883360 │ -    │
╰────────────────────────────┴─────────┴─────────┴────────────┴─────────┴──────╯

Sessions

╭───────────┬──────────┬──────────╮
│ Execution │ Mode     │ Sessions │
├───────────┼──────────┼──────────┤
│ headless  │ headless │ 1        │
╰───────────┴──────────┴──────────╯

Triggered by edenreich · Infer Action · OSS

@inference-gateway-maintainer inference-gateway-maintainer Bot changed the title fix: resolve #1400 (salvaged) fix: route browser-use through the infer daemon's extension connection Sep 29, 2026
@inference-gateway-maintainer
inference-gateway-maintainer Bot marked this pull request as ready for review September 29, 2026 18:52
@inference-gateway-maintainer
inference-gateway-maintainer Bot requested a review from a team as a code owner September 29, 2026 18:52
…restore the status indicator

- DaemonClient serializes dialing and writes, so parallel Browser calls share one socket instead of racing to dial and leaking the loser's socket.
- The TUI's browser indicator follows each daemon answer, since chat no longer hosts the bridge that notified it.
- An unreachable port always starts the daemon. Its pid lock makes a redundant start exit, so a daemon that stopped is started again instead of timing out every call.
- Relay always answers with a browser_result, so the sessions context no longer encodes the browser wire format.
- Docs cover the auto-started daemon and note that the /artifacts/ route is not served under the daemon yet.
- The sessions domain declares EnsureDaemon next to LaunchWorker, and sessions/infrastructure implements it with the port probe, the start and the wait for the port.
- The container injects it into the agui DaemonClient, which now only speaks the binding's socket protocol.
- The daemon starts with plain os/exec and no raw syscall attributes, so the build-tagged spawn files are gone. It shares the caller's terminal, so closing that terminal stops it and the next Browser call starts another.
…tead of SIGTERM

Process.Signal(SIGTERM) is not supported on Windows, so a stopped worker waited out the grace period and was killed without its cleanup. The worker is now stopped the way its stdin contract already allows on every platform. An interrupt frame ends the running turn and stdin EOF makes it run its own cleanup and exit. The grace period's kill still covers a worker that does not.
…ut raw syscalls

The Unix-only process group (Setpgid plus a raw kill of the group) is replaced with a gopsutil process-tree kill. It lists each process's children before killing it and then kills their trees the same way, so a script's children die on timeout or cancel on Linux, macOS and Windows alike. gopsutil was already linked in through robotgo and is now a direct dependency.
ProcessAlive drops its build-tagged pair (a raw signal-0 kill on Unix and os.FindProcess elsewhere) for gopsutil's PidExists. On Windows it now lists pids instead of trusting OpenProcess, which can succeed for a pid that does not exist. A pid that is not positive is never alive, where the Unix probe used to signal the caller's process group for pid 0.
edenreich and others added 2 commits September 29, 2026 23:15
… between integer types'

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
The AG-UI package knew its users. It named the extension, desktop and browser
clients, owned the browser command relay and the daemon client, imported the
sessions ports, and published the computer context's events. A depguard rule
kept the browser context from importing it, which enforced the inversion.

agui is now general purpose. Binding is a WebSocket server that owns the
listener, the Origin check, the token handshake and the connections, and hands
every frame to a Handler. Dial is its client end. The handshake frame names and
the accepted origins come in as configuration, and a connection carries its
client kind as an opaque string. The run encoder takes Publish functions and
renders any event it does not map as the CUSTOM event its owner returns.

The contexts import agui:

- browser owns the wire contract, the ExtensionRelay that keeps the one
  extension connection and serializes commands, and the ExtensionClient that
  dials the binding from infer chat and a standalone headless
- computer owns computer_use_paused, computer_use_resumed and
  screen_recording in computer.PublishedEvent
- internal/daemon holds the on-demand daemon boot, which left sessions
- sessions drops the EnsureDaemon and Threads ports, which had no consumer
  left, and imports no protocol
- cmd/daemon puts the browser relay and the thread registry behind the
  binding's one handler

The wire is unchanged: frame names, handshake, error wording and CUSTOM event
payloads are the same. The /artifacts/ route is removed from the binding. The
daemon never served it and the protocol doc already says it answers 404.

depguard replaces browser-does-not-import-agui with agui-names-no-context,
which denies agui every internal import except the shared kernel, the
conversation and scheduler domains and platform.
@edenreich edenreich changed the title fix: route browser-use through the infer daemon's extension connection fix: route browser-use through the infer daemon and make agui a general-purpose protocol Sep 29, 2026
agui still mapped agent chat events to AG-UI events and answered the panel
frames of a serve worker, so it imported the agent, conversation and scheduler
domains and the storage, ipc, models and render packages.

agui now offers Run, a writer for the events of one run. It frames text and
reasoning messages, writes tool calls, snapshots and CUSTOM events from plain
values, and guarantees exactly one terminal RUN_FINISHED or RUN_ERROR. The
AG-UI SDK stays confined to agui, which exposes the message types a caller
builds a MESSAGES_SNAPSHOT from.

presentation/headless owns what it alone consumes:

- RunEncoder maps agent chat events onto a Run
- Panel answers the panel frames of a serve worker
- the container builds the headless Panel

The AG-UI output is unchanged. agui's only internal import is the logger, and
the agui-names-no-context depguard rule now allows nothing else and denies the
config package too.
The depguard rule for agui denied internal packages but let any external
dependency in, so nothing kept the protocol package from growing new ones.

agui-imports-are-closed replaces agui-names-no-context and runs in strict
mode. It allows the standard library and the five packages agui imports today,
and rejects every other import in the package and its tests. The agui README
records the same list and what each import is used for.
The binding, relay and client tests each carried their own implementation of
the agui Handler, and the panel test its own shell history store.

counterfeiter now generates FakeHandler in tests/mocks/agui and
FakeShellHistoryStorage in tests/mocks/storage, and the tests stub those. The
binding test moved to the external agui_test package, since the fake imports
agui, and reads two unexported constants through export_test.go.

The closed import list of agui allows the fake and the package under test for
its tests, and the agui README records both.
The protocol doc still described the /artifacts/ route as loopback-only with
path traversal blocked by http.Dir, which read as a description of a route
that exists. The binding has no such route.

The section now states that the route answers 404 and why, and what that
means for a panel user. A comment in render pointed at the agui package for
the AG-UI RUN_ERROR writer, which lives in the headless presentation.
@inference-gateway-releaser

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 0.219.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@inference-gateway-releaser inference-gateway-releaser Bot added the released Shipped in a release label Sep 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

released Shipped in a release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] Route browser-use through the infer daemon's extension connection

2 participants