Dodaios is an open-source agent OS for your desktop: it runs your coding agents, browser and apps by voice or chat, on your own machine. Formerly Personal Jarvis.
Python agent-orchestrationai-agentai-coding-assistantclaude-codecoding-agentcomputer-usedesktop-applocal-firstmcppersonal-jarvisvoice-assistantvoice-coding
fix(browser): route selected tools to the visible agent browser
rubenluetke10-beepe2e66cf1c044
diff --git a/jarvis/agent_chat/jarvis_harness.py b/jarvis/agent_chat/jarvis_harness.pyindex b8e2376298..113c854446 100644--- a/jarvis/agent_chat/jarvis_harness.py+++ b/jarvis/agent_chat/jarvis_harness.py@@ -84,6 +84,13 @@ SYSTEM_PREAMBLE: Final[str] = ("browser whenever the request is about the person's own apps, data or ""machine: those tools are already signed in and already permitted. Reach for ""your file and shell tools for code and for the filesystem.\n\n"+ "When the user selects Chrome / Browser, @browser, @browser-use or "+ "[tools: core:browser], use society_browser from the Jarvis MCP server. "+ "That is the persistent browser displayed live in this agent's Options rail. "+ "Use it for website interaction when no connected service tool can do the task. "+ "A browser request takes priority over the general plugin preference. "+ "Do not substitute your own browser, HTTP fetch or shell for this selection. "+ "If society_browser is unavailable, report that explicitly.\n\n""Two kinds of hands: your own file and shell tools are your hands in the ""working folder this chat is open in; `mcp__jarvis__run_shell` / ""`jarvis__run_shell` and their siblings are Jarvis' hands on the whole "@@ -179,12 +186,17 @@ def codex_config_args(session_id: str | None = None) -> list[str]:args += ["-c",f'mcp_servers.{_SERVER_NAME}.http_headers={{"{HEADER_NAME}"="{session_id}"}}',+ "-c",+ f"mcp_servers.{_SERVER_NAME}.required=true",+ # The entrypoint delegates actual actions to Jarvis' executor+ # and approval UI, including on the root chat's browser.+ "-c",+ f'mcp_servers.{_SERVER_NAME}.tools.society_browser.approval_mode="approve"',]if session_id.startswith("society:"):# A society seat cannot carry out its role without its owned# tools. Surface startup failures instead of a tools-free chat# that can only promise to configure the running app.- args += ["-c", f"mcp_servers.{_SERVER_NAME}.required=true"]# This local configuration tool already verifies the current# user request and routes permission changes to Jarvis' own# approval card. A second Codex write prompt cannot be answered@@ -192,11 +204,6 @@ def codex_config_args(session_id: str | None = None) -> list[str]:args += ["-c",f'mcp_servers.{_SERVER_NAME}.tools.society_propose_change.approval_mode="approve"',- # The browser entrypoint delegates each actual action to- # Jarvis' executor and its approval UI. Let it reach that- # boundary instead of asking exec for an unreadable prompt.- "-c",- f'mcp_servers.{_SERVER_NAME}.tools.society_browser.approval_mode="approve"',]return argsexcept Exception: # noqa: BLE001 — see mcp_config_jsondiff --git a/jarvis/agent_chat/runner_cli.py b/jarvis/agent_chat/runner_cli.pyindex 2632774093..cc3c8cec0b 100644--- a/jarvis/agent_chat/runner_cli.py+++ b/jarvis/agent_chat/runner_cli.py@@ -831,6 +831,13 @@ def plan_codex(# Jarvis' own tools over streamable-HTTP MCP, mounted for this run only —# the person's ~/.codex/config.toml is never touched.argv += jarvis_harness.codex_config_args(identity.session_id if identity else None)+ if identity is not None:+ # A Jarvis seat must use the browser and connections visible in Jarvis.+ # Inheriting the coding CLI's plugins gives it a second, unrelated+ # browser whose actions never appear in the agent's live viewer.+ argv += ["--ignore-user-config", "--ignore-rules"]+ for feature in ("browser_use", "plugins", "computer_use", "apps", "web_search_request"):+ argv += ["--disable", feature]# The TUI's presets, spelled out for ``exec`` (codex 0.149): Read only /# Auto (workspace-write) / Full access (``--yolo``), plus "approve for# me" — Codex's own reviewer model decides what would have asked you,diff --git a/jarvis/agent_chat/service.py b/jarvis/agent_chat/service.pyindex dd4f6bed93..32b9400fd5 100644--- a/jarvis/agent_chat/service.py+++ b/jarvis/agent_chat/service.py@@ -22,6 +22,7 @@ from __future__ import annotationsimport asyncioimport jsonimport logging+import reimport shutilimport uuidfrom collections.abc import Callable@@ -406,11 +407,17 @@ class AgentChatService:selection = worker_selection(getattr(manager, "_config", None))if selection is not None:provider, selected_runner = subscription_seat(selection.provider) or (- selection.provider, "brain"+ selection.provider,+ "brain",)if (session.provider, session.model) != (provider, selection.model or ""):- session = replace(session, provider=provider, model=selection.model or "",- vendor_session=None, effort=selection.reasoning_effort)+ session = replace(+ session,+ provider=provider,+ model=selection.model or "",+ vendor_session=None,+ effort=selection.reasoning_effort,+ )self.store.reseat_session(session_id, provider=provider, model=session.model)if (session.surface in ("jarvis", "society")@@ -418,8 +425,6 @@ class AgentChatService:and incoming is Noneand not control_owned):- import re-from .control_types import COMMANDScommand = re.match(r"^/([a-z]+)(?:\s|$)", text.strip())@@ -453,6 +458,13 @@ class AgentChatService:# What the turn receives; ``text`` stays what the person typed so the# timeline shows their sentence rather than a page of extracted PDF.prompt = chat_attachments.compose(text, attached)+ # Agent cards serialize Add selections as capability pins. Translate the+ # browser pin to the same validated receipt used by the root composer.+ if session.surface == "jarvis" and any(+ "core:browser" in {item.strip() for item in match.split(",")}+ for match in re.findall(r"(?m)^\[tools:\s*([^\]\r\n]+)\]\s*$", text)+ ):+ tool_choices = list(dict.fromkeys([*(tool_choices or []), "tool:society_browser"]))selected = []if tool_choices:if session.surface != "jarvis":@@ -499,7 +511,11 @@ class AgentChatService:),# What the person typed, when it differs from the prompt.# Absent on an ordinary message, so nothing changes there.- **({"typed": display_text if display_text is not None else text} if attached or display_text is not None else {}),+ **(+ {"typed": display_text if display_text is not None else text}+ if attached or display_text is not None+ else {}+ ),**({"attachments": [@@ -561,7 +577,11 @@ class AgentChatService:async def _body() -> None:origin = ChatTurn(- session_id, turn_id, display_text if display_text is not None else text, direct_user and incoming is None, str(handle.trace_id)+ session_id,+ turn_id,+ display_text if display_text is not None else text,+ direct_user and incoming is None,+ str(handle.trace_id),)origin_token = current_chat_turn.set(origin)try:@@ -579,6 +599,8 @@ class AgentChatService:**({"tool_choices": selected} if selected else {}),)elif supports_cli_runner(runner):+ from jarvis.agent_chat.tool_catalog import selection_briefing+# A CLI runs AS Jarvis — its own tools over MCP, its calls# answered by the chat's approval card — only where the# surface both is Jarvis and seats a CLI at all. The front@@ -589,7 +611,7 @@ class AgentChatService:as_jarvis = kit.brain_runner and kit.cli_seatsvendor = await run_cli_turn(handle,- prompt,+ prompt + selection_briefing(selected),runner,identity=as_jarvis,bridge=self._bridge_for(bus) if as_jarvis else None,diff --git a/jarvis/society/browser/bridge.py b/jarvis/society/browser/bridge.pyindex 33c4281b01..460460d36b 100644--- a/jarvis/society/browser/bridge.py+++ b/jarvis/society/browser/bridge.py@@ -109,7 +109,7 @@ async def execute_live(key = get_jarvis_agent_secret(provider)overrides = {provider: key} if key else {}with override_provider_secrets(overrides):- brain = live.model_resolver(caller)+ brain = await asyncio.to_thread(live.model_resolver, caller)if brain is None or not callable(getattr(brain, "complete", None)):return ToolResult(False, None, "This agent has no browser-capable model connection")usage_total = {"input_tokens": 0, "output_tokens": 0, "cache_hit_tokens": 0}@@ -256,7 +256,8 @@ async def execute_live(task = str(args.get("task") or "").strip()if read_only:task = (- "READ-ONLY: use navigation, reading and extraction only; no clicks, inputs, uploads or writes. "+ "READ-ONLY: use navigation, reading and extraction only; "+ "no clicks, inputs, uploads or writes. "+ task)workspace = (Path(runtime.data_dir) / "society" / caller.agent_id / "workspace").resolve()diff --git a/jarvis/society/browser/tool.py b/jarvis/society/browser/tool.pyindex e737bd6110..9f668b6ec7 100644--- a/jarvis/society/browser/tool.py+++ b/jarvis/society/browser/tool.py@@ -82,7 +82,10 @@ class BrowserTool:"Give one clear task (what to achieve, where, what to return) and optionally the ""URL to start at. The run is capped (max_steps); it returns the final result, the ""pages visited and any errors. Tasks that send, buy, delete or publish ask the user "- "first. Prefer a connected plugin or CLI when one exists for the service."+ "first. This is the live browser shown in your Options rail. Use this tool "+ "when the user selects Browser or asks to operate the visible browser, and "+ "for web tasks without a suitable connected API. Otherwise prefer a connected "+ "plugin or CLI when one exists for the service.")schema: dict[str, Any] = {"type": "object",@@ -120,7 +123,10 @@ class BrowserTool:if read_only:self.risk_tier = "safe"self.is_action_tool = False- self.description = "Read-only agent browser: navigate, inspect and extract website content. Form input, clicks, uploads and file writes are blocked in this mode."+ self.description = (+ "Read-only agent browser: navigate, inspect and extract website content. "+ "Form input, clicks, uploads and file writes are blocked in this mode."+ )def risk_tier_for_args(self, args: dict[str, Any]) -> str | None:if self._jobs._python is None:diff --git a/jarvis/society/surface.py b/jarvis/society/surface.pyindex edc46fa777..52b1e2b127 100644--- a/jarvis/society/surface.py+++ b/jarvis/society/surface.py@@ -236,7 +236,14 @@ async def _scoped_tool_for_session(session_id: str, capability: str) -> Tool | Nif capability == "core:browser":from .browser.tool import BrowserTool- tool = cast(Tool, BrowserTool(rt, agent_id, rt.browser, read_only=read_only))+ pick = (+ (session.provider, session.model)+ if service is not None and getattr(session, "surface", "") == "jarvis"+ else None+ )+ tool = cast(+ Tool, BrowserTool(rt, agent_id, rt.browser, model_pick=pick, read_only=read_only)+ )else:tool = cast(Tool, CodingSessionTool(rt, agent_id, session_id=session_id))picked = select_tools(diff --git a/jarvis/ui/web/frontend/src/components/society/card/BrowserPointer.tsx b/jarvis/ui/web/frontend/src/components/society/card/BrowserPointer.tsxindex 8d6d6a90fc..ae34eeb2d7 100644--- a/jarvis/ui/web/frontend/src/components/society/card/BrowserPointer.tsx+++ b/jarvis/ui/web/frontend/src/components/society/card/BrowserPointer.tsx@@ -35,12 +35,13 @@ export function BrowserPointer({ pointer }: { pointer?: BrowserPointerState }) {{pointer.click_id > 0 && <span key={pointer.click_id} className="jarvis-browser-click"style={point(pointer.click_x, pointer.click_y)} data-testid="browser-click-mark" />}<span className="jarvis-browser-pointer" style={point(pointer.x, pointer.y)} data-testid="browser-agent-pointer">- <svg width="23" height="28" viewBox="0 0 23 28" fill="none">- <path d="M3 2.5C2.1 1.8 1.3 2.4 1.5 3.5L4.7 23.1C4.9 24.4 6.1 24.7 6.9 23.6L11.1 17.7L18.4 16.7C19.8 16.5 20.2 15.4 19.1 14.5L3 2.5Z"- fill="var(--browser-pointer-fill)" stroke="var(--browser-pointer-edge)" strokeWidth="1.6" strokeLinejoin="round" />- <path d="M5 6.5L8 17" stroke="white" strokeOpacity=".45" strokeWidth="1.2" strokeLinecap="round" />+ <svg width="24" height="30" viewBox="0 0 24 30" fill="none">+ <path d="M3 3L20 15L12 17L8 25L3 3Z"+ fill="var(--browser-pointer-fill)" stroke="var(--browser-pointer-edge)" strokeWidth="2" strokeLinejoin="round" />+ <path d="M12 17L17 25" stroke="var(--browser-pointer-edge)" strokeWidth="5" strokeLinecap="round" />+ <path d="M12 17L17 25" stroke="var(--browser-pointer-fill)" strokeWidth="2.5" strokeLinecap="round" /></svg>- <span className="jarvis-browser-pointer-label">Jarvis</span>+ <span className="jarvis-browser-pointer-label"><span className="jarvis-browser-pointer-dot" />Jarvis</span></span></>}</div>;diff --git a/jarvis/ui/web/frontend/src/components/society/card/browserPointer.css b/jarvis/ui/web/frontend/src/components/society/card/browserPointer.cssindex 3236821601..d1b98517ea 100644--- a/jarvis/ui/web/frontend/src/components/society/card/browserPointer.css+++ b/jarvis/ui/web/frontend/src/components/society/card/browserPointer.css@@ -1,34 +1,40 @@.jarvis-browser-pointer-layer {- --browser-pointer-fill: #208678;- --browser-pointer-edge: #f7fffc;+ --browser-pointer-fill: hsl(var(--primary));+ --browser-pointer-edge: hsl(var(--background));position: absolute;inset: 0;pointer-events: none;overflow: hidden;}-.dark .jarvis-browser-pointer-layer {- --browser-pointer-fill: #4bb9a4;- --browser-pointer-edge: #e6fff6;-}.jarvis-browser-pointer {position: absolute;- width: 23px;- height: 28px;- transform: translate(-2px, -3px);+ width: 24px;+ height: 30px;+ transform: translate(-3px, -3px);filter: drop-shadow(0 2px 3px #0008);transition: left 80ms ease-out, top 80ms ease-out;}.jarvis-browser-pointer-label {position: absolute;- left: 20px;- top: 21px;- padding: 2px 6px;- border-radius: 6px;- color: var(--browser-pointer-edge);- background: var(--browser-pointer-fill);+ left: 22px;+ top: 22px;+ display: flex;+ align-items: center;+ gap: 4px;+ padding: 2px 7px;+ border: 1px solid hsl(var(--border));+ border-radius: 999px;+ color: hsl(var(--foreground));+ background: hsl(var(--background));font: 600 10px/14px system-ui, sans-serif;white-space: nowrap;}+.jarvis-browser-pointer-dot {+ width: 5px;+ height: 5px;+ border-radius: 50%;+ background: var(--browser-pointer-fill);+}.jarvis-browser-click {position: absolute;width: 24px;diff --git a/jarvis/ui/web/frontend/src/components/society/card/useBrowserView.test.tsx b/jarvis/ui/web/frontend/src/components/society/card/useBrowserView.test.tsxindex 0281feb7a2..98a35f6895 100644--- a/jarvis/ui/web/frontend/src/components/society/card/useBrowserView.test.tsx+++ b/jarvis/ui/web/frontend/src/components/society/card/useBrowserView.test.tsx@@ -2,8 +2,8 @@ import { act, cleanup, renderHook } from "@testing-library/react";import { afterEach, expect, test, vi } from "vitest";import { useBrowserView } from "./useBrowserView";-const { connect } = vi.hoisted(() => ({ connect: vi.fn() }));-vi.mock("@/lib/ws", () => ({ mintWsTicket: async () => "" }));+const { connect, ticket } = vi.hoisted(() => ({ connect: vi.fn(), ticket: vi.fn(async () => "fresh-ticket") }));+vi.mock("@/lib/ws", () => ({ mintWsTicket: ticket }));vi.mock("@/lib/connectBudget", () => ({requestConnect: connect, jitteredDelay: () => 1000,}));@@ -13,14 +13,14 @@ class Socket {static current: Socket;readyState = 1;onopen?: () => void;- onclose?: () => void;+ onclose?: (event: { code: number }) => void;onmessage?: (event: { data: string }) => void;send = vi.fn();- close = vi.fn(() => { this.readyState = 3; this.onclose?.(); });- constructor() { Socket.current = this; }+ close = vi.fn(() => { this.readyState = 3; this.onclose?.({ code: 1000 }); });+ constructor(public url: string) { Socket.current = this; }}-afterEach(() => { cleanup(); vi.useRealTimers(); vi.unstubAllGlobals(); connect.mockReset(); });+afterEach(() => { cleanup(); vi.useRealTimers(); vi.unstubAllGlobals(); connect.mockReset(); ticket.mockClear(); });async function mount() {vi.useFakeTimers();@@ -43,7 +43,7 @@ test("silent live connection becomes disconnected and pays the reconnect budget"expect(connect).toHaveBeenCalledTimes(2);});-test("static page heartbeats preserve a healthy connection without new images", async () => {+test("state heartbeats without first pixels recover instead of connecting forever", async () => {const hook = await mount();for (let n = 0; n < 4; n++) {act(() => {@@ -51,8 +51,8 @@ test("static page heartbeats preserve a healthy connection without new images",Socket.current.onmessage?.({ data: JSON.stringify({ kind: "state", url: "about:blank", tabs: [] }) });});}- expect(hook.result.current.state.connected).toBe(true);- expect(Socket.current.close).not.toHaveBeenCalled();+ expect(hook.result.current.state.connected).toBe(false);+ expect(Socket.current.close).toHaveBeenCalledOnce();});test("cold browser startup stays connected until pixels are available", async () => {@@ -107,4 +107,14 @@ test("denied control never replays queued input", async () => {test("connect does not wait for a separate HTTP setup request", async () => {await mount();expect(fetch).not.toHaveBeenCalled();+ expect(ticket).not.toHaveBeenCalled();+});++test("cookie rejection reconnects with a fresh ticket through the shared budget", async () => {+ await mount();+ act(() => Socket.current.onclose?.({ code: 4401 }));+ expect(connect).toHaveBeenCalledTimes(2);+ await act(async () => { connect.mock.calls[1][0](); });+ expect(ticket).toHaveBeenCalledOnce();+ expect(Socket.current.url).toContain("?ticket=fresh-ticket");});diff --git a/jarvis/ui/web/frontend/src/components/society/card/useBrowserView.ts b/jarvis/ui/web/frontend/src/components/society/card/useBrowserView.tsindex 4cf826bdc6..da4ae4655a 100644--- a/jarvis/ui/web/frontend/src/components/society/card/useBrowserView.ts+++ b/jarvis/ui/web/frontend/src/components/society/card/useBrowserView.ts@@ -33,6 +33,8 @@ export function useBrowserView(agentId: string) {useEffect(() => {let disposed = false;let attempt = 0;+ let needsTicket = false;+ let waitingForFrameSince = 0;let cancelConnect = () => {};let epoch = 0;let generation = "";@@ -80,15 +82,20 @@ export function useBrowserView(agentId: string) {const connect = async () => {if (disposed) return;try {- const ticket = await mintWsTicket();+ // Cookie-capable desktop engines can connect immediately. Only WebKit+ // needs the HTTP ticket fallback after an authenticated 4401 rejection.+ const ticket = needsTicket ? await mintWsTicket() : null;if (disposed) return;const protocol = location.protocol === "https:" ? "wss:" : "ws:";const path = "/api/society/agents/" + encodeURIComponent(agentId) + "/browser/live";const ws = new WebSocket(protocol + "//" + location.host + path +(ticket ? "?ticket=" + encodeURIComponent(ticket) : ""));+ let opened = false;socket.current = ws;ws.onopen = () => {+ opened = true;lastLiveEvent = Date.now();+ waitingForFrameSince = 0;setState((s) => ({ ...s, connected: true, ready: false }));};ws.onmessage = (message) => {@@ -99,6 +106,7 @@ export function useBrowserView(agentId: string) {if (typeof event.data !== "string" || typeof event.sequence !== "number") return;if (!Number.isFinite(event.timestamp)) return;lastLiveEvent = Date.now();+ waitingForFrameSince = 0;attempt = 0;if (typeof event.full_window === "boolean") {setState((s) => s.fullWindow === event.full_window ? s : { ...s, fullWindow: event.full_window });@@ -127,6 +135,7 @@ export function useBrowserView(agentId: string) {setState((s) => ({ ...s, ready: false, error: event.error }));} else if (event.kind === "state") {lastLiveEvent = Date.now();+ if (!renderedFrames && !waitingForFrameSince) waitingForFrameSince = Date.now();setState((s) => ({ ...s, manual: event.manual, running: event.running,url: event.url, target: event.target, tabs: event.tabs ?? [], fullWindow: Boolean(event.full_window) }));} else if (event.kind === "control") {@@ -157,9 +166,12 @@ export function useBrowserView(agentId: string) {setState((s) => ({ ...s, error: "Browser stream returned invalid data" }));}};- ws.onclose = () => {+ ws.onclose = (event) => {if (disposed || socket.current !== ws) return;+ // Rejection before accept is exposed as 1006 by browsers, not 4401.+ if (event.code === 4401 || !opened) needsTicket = true;epoch++;+ renderedFrames = 0;manual.current = false;claiming.current = false;inputs.current = [];@@ -179,7 +191,10 @@ export function useBrowserView(agentId: string) {cancelConnect = requestConnect(() => void connect());// Static pages still send state heartbeats. A silent transport is not Live.const watchdog = setInterval(() => {- if (socket.current?.readyState === WebSocket.OPEN && Date.now() - lastLiveEvent > 7500) {+ if (socket.current?.readyState === WebSocket.OPEN && (+ Date.now() - lastLiveEvent > 7500 ||+ (waitingForFrameSince > 0 && Date.now() - waitingForFrameSince > 7500)+ )) {setState((s) => ({ ...s, connected: false, manual: false, controlPending: false }));socket.current.close(); // onclose reconnects through the shared jittered budget.}diff --git a/tests/contract/test_browser_desktop_mcp.py b/tests/contract/test_browser_desktop_mcp.pyindex 72b9e0b541..1acf8c37df 100644--- a/tests/contract/test_browser_desktop_mcp.py+++ b/tests/contract/test_browser_desktop_mcp.py@@ -2,15 +2,17 @@from types import SimpleNamespacefrom uuid import uuid4+import pytest+from jarvis.brain.tool_gateway import BrainSupervisorToolGatewayfrom jarvis.core.protocols import SupervisorToolRequest, ToolResultasync def test_desktop_bootstrap_publishes_the_mcp_endpoint(monkeypatch):- from jarvis.ui.web.server import WebServer- from jarvis.core import runtime_refsfrom jarvis.agent_chat import jarvis_harness+ from jarvis.core import runtime_refs+ from jarvis.ui.web.server import WebServerurls = []monkeypatch.setattr(runtime_refs, "set_api_base_url", urls.append)@@ -99,8 +101,8 @@ async def test_plan_session_gets_readonly_browser_but_not_coding_control(tmp_pat@pytest.mark.parametrize("action_name", ["navigate", "input", "click", "upload_file"])async def test_readonly_browser_enforces_action_boundary(tmp_path, monkeypatch, action_name):- from jarvis.society.runtime import SocietyRuntimefrom jarvis.society.browser.bridge import execute_live+ from jarvis.society.runtime import SocietyRuntimemonkeypatch.setattr("jarvis.core.config.get_jarvis_agent_secret", lambda _: None)rt = SocietyRuntime(tmp_path, seed_starter_team=False)@@ -138,3 +140,68 @@ async def test_readonly_browser_enforces_action_boundary(tmp_path, monkeypatch,assert applied == (["navigate"] if action_name == "navigate" else [])finally:await rt.close()+++async def test_root_subscription_browser_uses_chat_model_without_changing_roster(+ tmp_path, monkeypatch+):+ from jarvis.society.runtime import SocietyRuntime+ from jarvis.society.surface import browser_tool_for_session++ rt = SocietyRuntime(tmp_path, seed_starter_team=False)+ await rt.ensure_started()+ seen = []+ session = SimpleNamespace(+ surface="jarvis", provider="openai-codex", model="picked-model", permission_mode="ask"+ )+ rt.chat_service = lambda: SimpleNamespace(store=SimpleNamespace(get_session=lambda _: session))++ async def execute(runtime, caller, jobs, args, ctx, *, read_only=False):+ seen.append((caller.agent_id, caller.provider, caller.model))+ return ToolResult(True, {}, None)++ monkeypatch.setattr("jarvis.society.browser.bridge.execute_live", execute)+ try:+ original = await rt.roster.get(rt.lead_id)+ browser = await browser_tool_for_session("root-chat")+ assert browser is not None+ result = await browser.execute({"task": "Read the page"}, SimpleNamespace())+ assert result.success+ assert seen == [(rt.lead_id, "openai-codex", "picked-model")]+ current = await rt.roster.get(rt.lead_id)+ assert (current.provider, current.model) == (original.provider, original.model)+ finally:+ await rt.close()++[email protected]("session_id", ["society:scout", "root-chat"])[email protected]("resume", [None, "existing-vendor-session"])+def test_jarvis_codex_seat_uses_owned_browser_not_inherited_plugins(+ tmp_path, monkeypatch, session_id, resume+):+ from jarvis.agent_chat import jarvis_harness, runner_cli++ monkeypatch.setattr(runner_cli, "codex_argv_prefix", lambda: ["codex"])+ monkeypatch.setattr(runner_cli, "_account_env", lambda _: {})+ monkeypatch.setattr(+ jarvis_harness, "endpoint", lambda: "http://127.0.0.1:47821/api/control/mcp/"+ )+ monkeypatch.setattr(jarvis_harness, "control_key", lambda: "test-placeholder")+ args = dict(+ prompt="Use the browser",+ cwd=tmp_path,+ model="",+ effort="low",+ permission_mode="ask",+ resume=resume,+ )+ identity = jarvis_harness.Identity(session_id, "identity", "identity")+ plan = runner_cli.plan_codex(**args, identity=identity)+ assert "--ignore-user-config" in plan.argv+ assert "--ignore-rules" in plan.argv+ assert "browser_use" in plan.argv and "plugins" in plan.argv+ assert 'mcp_servers.jarvis.tools.society_browser.approval_mode="approve"' in plan.argv+ assert "mcp_servers.jarvis.required=true" in plan.argv+ coding = runner_cli.plan_codex(**args)+ assert "--ignore-user-config" not in coding.argv+ assert "browser_use" not in coding.argvdiff --git a/tests/contract/test_chat_tool_choices.py b/tests/contract/test_chat_tool_choices.pyindex e235340e3a..49641d9456 100644--- a/tests/contract/test_chat_tool_choices.py+++ b/tests/contract/test_chat_tool_choices.py@@ -116,7 +116,7 @@ class Ranker:async def test_semantics_can_find_no_word_overlap_without_tools():_, rows = inventory()ranker = Ranker('{"plugin:gmail": 0.95, "fabricated-id": 1}')- found, mode = await search_catalog(rows, "Posteingang aufräumen", ranker) # i18n-allow+ found, mode = await search_catalog(rows, "Posteingang aufräumen", ranker) # i18n-allowassert mode == "semantic"assert [row.id for row in found] == ["plugin:gmail"]assert ranker.requests[0].tools == ()@@ -292,3 +292,60 @@ def test_discovery_route_serves_catalog_and_openapi_metadata(tmp_path, monkeypat)operation = app.openapi()["paths"]["/api/agent-chat/tools"]["get"]assert operation["tags"] and operation["summary"] and operation["x-jarvis-readonly"]++[email protected]("card_pin", [False, True])+async def test_subscription_turn_receives_browser_selection_only_for_current_turn(+ tmp_path, monkeypatch, card_pin+):+ from jarvis.agent_chat import service+ from jarvis.agent_chat.events import make_event++ rows = build_catalog({"society_browser": tool("society_browser")})+ monkeypatch.setattr(tool_catalog, "live_catalog", lambda *_a, **_k: rows)+ prompts = []++ async def run(handle, prompt, runner, **kwargs):+ prompts.append(prompt)+ await handle.emit(+ make_event("turn_finished", {"turn_id": handle.turn_id, "status": "done"})+ )+ return None++ monkeypatch.setattr(service, "run_cli_turn", run)+ svc = AgentChatService(AgentChatStore(":memory:"))+ session = svc.store.create_session(+ provider="openai-codex",+ model="picked",+ effort="low",+ cwd=str(tmp_path),+ surface="jarvis",+ permission_mode="ask",+ )+ queue = svc.subscribe(session.session_id)+ text = "Read the heading" + ("\n\n[tools: core:browser]" if card_pin else "")+ try:+ await svc.send(+ session.session_id, text, tool_choices=None if card_pin else ["tool:society_browser"]+ )+ async with asyncio.timeout(5):+ while (await queue.get())["kind"] != "turn_finished":+ pass+ assert "society_browser" in prompts[0]+ assert "explicitly selected" in prompts[0]+ await asyncio.sleep(0)+ await svc.send(session.session_id, "Another question")+ async with asyncio.timeout(5):+ while (await queue.get())["kind"] != "turn_finished":+ pass+ assert "society_browser" not in prompts[1]+ receipts = [+ e["payload"]+ for e in svc.store.list_events(session.session_id)+ if e["kind"] == "user_message"+ ]+ assert receipts[0]["text"] == text+ assert receipts[0]["tool_choices"][0]["id"] == "tool:society_browser"+ finally:+ await svc.cancel(session.session_id)+ svc.store.close()