Repository navigation
feat(agent): drive chats through infer daemon threads and retire the browser bridge - #374
Merged
Merged
Conversation
…browser bridge The app spawned infer headless per prompt, read busy state off the process, stopped a run with SIGKILL, loaded history with infer conversations show, and ran a second copy of the extension panel protocol in browser_bridge.rs that held port 52789 and relayed browser commands to each child on port 52790. Since cli v0.220.0 only infer daemon binds the port and the released app breaks against it. Every chat is now a daemon thread. The app makes sure a daemon listens on the binding, reusing one that already runs and otherwise starting infer daemon with its env and the binding switched on, and opens one WebSocket per chat with a desktop hello on protocol version 2. The per-run env the app set becomes the thread options of resume_conversation, a prompt is a run_agent_input with images as content parts, stop is an interrupt, and busy state follows the run's terminal event. Approvals and questions arrive as the interrupt outcome and are answered with one resume covering every open interrupt. Token usage, background tasks and the recording state are read from the standard usage and state keys. Opening a chat renders the thread's MESSAGES_SNAPSHOT. Pausing computer use stops the run and resuming continues the thread with a new run. The browser bridge is gone with its chat_event wrapping, user echo, JSONL snapshot and request_id approvals. The extension's state comes from the browser_extension_status frame the daemon sends, and browser tools from a chat reach the extension through the daemon. Closes #367 Closes #369
21 of 23 tasks
edenreich
added a commit
to inference-gateway/cli
that referenced
this pull request
Oct 1, 2026
…urn (#1443) ## Summary Part of #1396. Found by the desktop e2e suite against inference-gateway/desktop#374. A one-shot `infer headless "!cmd"` runs the command through the tool service with no model, and so does the TUI, but the serve worker fed the same text to the agent as an ordinary prompt. A daemon client (the desktop app's bash mode) therefore got a model turn instead of the command's output. `runServeTurn` now takes a lone `!cmd` or `!!Tool(...)` input off the queue and renders it as its own run: the tool call and its result, or the parse error the task failed on. A turn carrying several messages still goes to the agent untouched. ## Verification - `TestQueuedDirectCall` covers the lone command, a malformed tool call, and a multi-message turn. - `task precommit:run` passes. - The desktop e2e `bash-mode` and `queued-prompt` scenarios pass against this build through the daemon.
Contributor
|
🎉 This PR is included in version 0.51.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #367 and #369. Part of inference-gateway/cli#1396. Builds on #373. Needs cli v0.220.0 and the opentask release carrying inference-gateway/opentask#213.
#367 — chats run as daemon threads
daemon.rs: the binding comes from~/.infer/daemon.yaml(binding.{port,token}), falling back tobrowser_use.yaml, and is seeded with a token when neither has one.ensure_runningreuses a listening daemon and otherwise startsinfer daemonwith the app's env plusINFER_DAEMON_BINDING_*. The app starts it at launch, and a saved auth change or browser-use toggle restarts the one the app owns.thread.rs: one WebSocket per chat.browser_hellowithclient: "desktop"andprotocol_version: 2, a mismatch on the ack is reported as "update infer".resume_conversationcarries the thread options (model, mode, system prompt, custom instructions, sandbox directories, max turns), the app spawns noinfer headless.run_agent_inputwith attached images as content parts. Stop sendsinterruptand the run ends with outcomecancelled. Busy state followsRUN_STARTEDto the terminal event, which the thread turns into theDone/Cancelledevents the UI already keys on.RUN_FINISHEDoutcomeinterrupt, mapped by the parser onto the existingApprovalRequest/UserQuestionRequestevents (the question form's questions come from theAskUserQuestioncall's args). The answer is one resume covering every open interrupt. ARUN_STARTEDclears the open interrupts. The worker always runs with the approval broker and the thread'smodecarries auto mode, so fix(agent): ask before a path outside the sandbox in auto mode #366's sandbox prompt in auto mode still reaches the user.usageand the state keyusage(the last request's input is the delta between patches), background tasks frombackgroundTasks.computer_use_controlis gone, the monitor's pause stops the run and resume continues with a new one.RUN_ERRORwithout arunIdis shown and ends no run.open_thread, which returns theMESSAGES_SNAPSHOT, instead ofinfer conversations show.#369 — browser bridge retired
browser_bridge.rsis deleted: no listener on 52789, no relay on 52790, noINFER_BROWSER_USE_EXTENSION_PORT, nochat_event, user echo, JSONL snapshot orrequest_idapprovals.browser_extension_statusframe every thread connection receives, surfaced through the existingbrowser-bridgeevent, so the status-bar globe and the Settings dot keep working.Known gaps
Verification
cargo test: 171 passed.thread.rstests drive a fake daemon over a real socket: hello and options, the version refusal, a streamed run with an interrupt, a cancelled run, a routing error, and a resume that waits for every open interrupt.bun test: 175 passed, with the history loader tests rewritten onto the snapshot shape.bun run build,cargo fmt --check,cargo clippy -D warnings, andcargo checkof the e2e crate are clean.task e2eagainstinferbuilt from cli main: 28 of 29 pass. The one failure,bash-mode, is a CLI gap (the serve worker sent!cmdto the model) fixed in fix(headless): run direct tasks in the serve worker without a model turn cli#1443, against whichbash-modeandqueued-promptpass. The driver stops the mock daemon by its pid file between runs.