Repository navigation
fix(opencode): scope project agents to their workspace - #21532
juliusmarminge wants to merge 4 commits into
Conversation
ApprovabilityVerdict: Needs Human Approval Macroscope's review found this PR requires human approval — This change adds workspace-specific OpenCode agent discovery and selection across server, web, and mobile, including changing which agent executes prompts and native commands. It also introduces workspace-dependent agent defaults and new discovery timeout behavior, making the runtime and product-default impact broader than a routine bug fix. Notes:
No code changes detected at You can add or adjust custom eligibility rules. Learn more. |
Thread transfer impact✅ Thread transfer remains within every enforced ceiling.
Baseline: Scenario and decoded snapshot size10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.
Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to
|
3fbaeca to
5477dba
Compare
Project-local OpenCode agents are missing from workspace snapshots, and OpenCode 2 always starts the build agent even when another agent is selected.
Discover visible primary/all agents through each runtime's directory client and publish them as workspace options. Web/desktop and mobile resolve capabilities for the destination cwd and normalize stale choices before sending, while preserving reasoning, project visibility, hidden-model handling, and unavailable Antigravity selections. OpenCode 2 uses the selected agent for prompts and native commands; plan mode remains authoritative. Optional OpenCode 2 agent reads have a three-second budget so two reads plus scan settling stay within the workspace deadline. A failed agent lookup retains successful skills/commands; the registry retains the previous directory's options when available, otherwise clients use the machine catalog.
Upper layer of the replacement for @maria-rcks's #15637, based on #21531 for the workspace-options foundation. The original's agent discovery, filtering, shared projection, selected-agent execution and client intent are preserved in the current provider packages and mobile signatures. The old scan wait/cache churn is omitted; current main's scan lifecycle remains.
Verification: 375 distinct scoped feature tests pass across the implementation and targeted follow-up runs, including 146 focused driver/adapter/mobile cases (139 existing cases retained; one discovery case extended, five native execution rows, one mobile workspace scenario, and one stalled-discovery case). Without the feature implementation, four behavior assertions fail. The added stalled-discovery case independently fails at the actual production 20-second deadline before the timeout fix and passes afterward; the latest fix reran all 146 focused and 39 adjacent cases. Foundation has 87 passing cases; recovery coverage fails before last-known options are retained. Scoped lint, formatting and seven typechecks pass; existing baseline lint warnings are unchanged. Full-stack reviews found and fixed repeated-refresh option loss, optional discovery exhausting the workspace deadline, and three mobile React Compiler bailouts. Existing compiler coverage independently changed from three failures/two passes to five passes; two web compiler checks and all 34 mobile model-option cases also pass, with no added tests. The fourth full-stack review round ended with fresh Claude and Sol reviews finding no blockers at 7da6fe5. They independently passed 268 and 240 selected cases respectively, including the existing mobile/web compiler checks.
Live Linux proof: matching discovery screenshots and A/B switching were captured at 6db48fc828. After the registry-only recovery fix, native execution was repeated at 463c285: native OpenCode 1.18.18 lists Triage Reviewer only in project A; project B has Build only; returning to A restores the selection. Selecting Triage Reviewer and sending to free Big Pickle completed with WORKSPACE_AGENT_OK, then FINAL_WORKSPACE_AGENT_OK after restarting that revision and waiting for its directory inventory. A read-only native database check confirms session and user/assistant agent triage-reviewer, correct project directory and normal completion; the project remains clean. Native boundary output.
Before — actual foundation base d156601, same project, viewport and menu:

After — the same discovery UI, unchanged by the later registry recovery and OpenCode 2 timeout fixes:

Other workspace:

Native completed turn:

Workspace selection and switching recording
The headless browser needed a local DejaVu fallback font, loaded identically on base and head. After the live-proof revision, production changes only bound the OpenCode 2 timeout and hoist three mobile expressions without changing their behavior. OpenCode 1 and the web UI shown here are unchanged. OpenCode 2 is verified through real-client HTTP/SSE replay and a controlled clock regression, not a native account. macOS, Windows, iOS, Android, Electron desktop, remote/relay/tunnel clients, and a live mobile build were not verified. The separate scheduled-task model editor retains its existing machine-wide catalog. Before an initial workspace refresh or after snapshot eviction, clients still normalize a saved workspace-only agent to the visible machine default (Build); re-check the agent after reconnect, particularly when the custom agent is more restrictive. MCP capability listing and explicit delegated-option validation remain machine-wide. Removed/unknown native agent IDs surface provider errors rather than silently substituting Build. CI also exposed two missing exports in an existing permission-test mock. The fixture now provides no-worktree state and uses the real model resolver through a partial import; all five permission assertions are unchanged and pass (39 cases with model options). Fresh fifth-round Claude and Sol full-stack reviews found no blockers at 3fbaeca; the affected permission/model-option suites pass 39/39, and Claude independently passed 266 selected cases. All executed CI checks pass at final head 3fbaeca; the unrelated browser timing failures passed on rerun. The older cancelled native-fingerprint run is superseded by a successful run. Correctness and CodeRabbit checks pass with no unresolved threads. Macroscope's approval check is neutral and explicitly requires human review of agent-default/execution behavior.
Implementation: Codex gpt-6.1-sol (high); tests: Codex gpt-6-astra (high); review: Claude claude-opus-5-5 and Codex gpt-6-sol through T3 Code.
Fixes #11871