Skip to content

fix(opencode): scope project agents to their workspace - #21532

Open
juliusmarminge wants to merge 4 commits into
mainfrom
other-providers-14/opencode-workspace-agents
Open

juliusmarminge wants to merge 4 commits into
mainfrom
other-providers-14/opencode-workspace-agents

Conversation

@juliusmarminge

@juliusmarminge juliusmarminge commented Oct 19, 2026 •

Copy link
Copy Markdown
Member

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:
Before: project-local reviewer missing

After — the same discovery UI, unchanged by the later registry recovery and OpenCode 2 timeout fixes:
After: project-local reviewer available

Other workspace:
Project B: reviewer is absent

Native completed turn:
Triage Reviewer completed the requested 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

@juliusmarminge
juliusmarminge added this pull request to stack #21533 October 19, 2026 05:44
@juliusmarminge juliusmarminge changed the title other providers 14/opencode workspace agents fix(opencode): scope project agents to their workspace Oct 19, 2026
@github-actions github-actions Bot added vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. size:L 100-499 changed lines (additions + deletions). labels Oct 19, 2026
@juliusmarminge juliusmarminge added the macroscope-review Opt PRs made by unvouched contributors in for Macroscope review. Vouched contributors auto-reviews label Oct 19, 2026
@macroscopeapp

macroscopeapp Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Approvability

Verdict: 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 objects were reviewed. Approvability was decided on eligibility alone.

No code changes detected at 5477dba. Prior analysis still applies.

You can add or adjust custom eligibility rules. Learn more.

@github-actions

github-actions Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Thread transfer impact

✅ Thread transfer remains within every enforced ceiling.

Provider Metric Main baseline This PR Impact PR ceiling
Codex Total thread wire 5.0 KiB 5.0 KiB 0 B (0.0%) 6.8 KiB ✅
Codex Thread snapshot wire 3.8 KiB 3.8 KiB 0 B (0.0%) 4.9 KiB ✅
Codex Live turn WebSocket wire 1.2 KiB 1.2 KiB 0 B (0.0%) 2.0 KiB ✅
Codex Live turn WebSocket decoded 20.9 KiB 20.9 KiB 0 B (0.0%) 29.3 KiB ✅
Codex Live turn messages 2 2 0 (0.0%) 8 ✅
Claude Total thread wire 5.0 KiB 5.0 KiB +7 B (+0.1%) 6.8 KiB ✅
Claude Thread snapshot wire 3.8 KiB 3.8 KiB 0 B (0.0%) 4.9 KiB ✅
Claude Live turn WebSocket wire 1.2 KiB 1.2 KiB +7 B (+0.6%) 2.0 KiB ✅
Claude Live turn WebSocket decoded 21.2 KiB 21.2 KiB 0 B (0.0%) 29.3 KiB ✅
Claude Live turn messages 2 2 0 (0.0%) 8 ✅

Baseline: 7208335 · PR result: 5477dba · Source CI: success

Scenario and decoded snapshot size

10 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.

  • Codex decoded thread snapshot: 108.5 KiB
  • Claude decoded thread snapshot: 108.8 KiB

Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.

@coderabbitai

coderabbitai Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Path: .coderabbit.config.ts
  • Review profile: CHILL
  • Plan: Team
  • Run ID: e0900c4a-2365-46b1-9741-ff41f3573ec9
📥 Commits

Reviewing files that changed from the base of the PR and between 3fbaeca and 5477dba.

📒 Files selected for processing: 10
  • apps/mobile/src/features/threads/NewTaskDraftScreen.tsx
  • apps/mobile/src/features/threads/ThreadComposer.tsx
  • apps/mobile/src/features/threads/ThreadSettingsSheet.tsx
  • apps/mobile/src/state/use-thread-composer-state.ts
  • apps/server/src/orchestration-v2/Adapters/OpenCode2AdapterV2.test.ts
  • apps/web/src/components/ChatView.tsx
  • apps/web/src/components/chat/ChatComposer.tsx
  • packages/provider-opencode/src/server/status.test.ts
  • packages/provider-opencode/src/server/status.ts
  • packages/provider-opencode/src/server/v2/adapter.ts

Limit details: You’ve used all 10 included reviews currently available.

📝 Walkthrough

The changes add working-directory-aware model selection across mobile and web chat flows. OpenCode workspace scans discover agents and expose eligible agents as model options. OpenCode turn handling uses the selected agent, with plan mode selecting the plan agent.

Changes: Workspace-scoped model and agent selection

Layer / File(s) Summary
OpenCode agent discovery and options
packages/provider-opencode/src/server/..., packages/provider-opencode/src/server/*test.ts
Workspace scans load agents with bounded waits and add available agent options to snapshots. Tests cover workspace-specific results, failures, timeouts, and fixtures.
Working-directory model resolution
apps/mobile/src/lib/..., apps/mobile/src/features/threads/..., apps/mobile/src/state/...
Model-option helpers and mobile thread flows resolve providers and selections using the active working directory.
Web provider resolution
apps/web/src/components/...
Web chat resolves provider entries against the active project and worktree directory before deriving provider selection.
OpenCode turn agent selection
packages/provider-opencode/src/server/v2/adapter.ts, apps/server/src/orchestration-v2/Adapters/OpenCode2AdapterV2.test.ts
Turn handling uses the selected agent outside plan mode and selects the plan agent in plan mode. Tests cover prompts, native commands, and completion.

Priority: ➖ Normal

Estimated code review effort: 3 (Moderate) | ~30 minutes

Change: Bug fix

Possibly related PRs

  • pingdotgg/t3code#15637: Introduced related workspace option descriptors, CWD-based provider resolution, and selected-agent execution.

Suggested reviewers: maria-rcks

Merge Risk: ⚪ Minimal · up to 5477d

The change scopes OpenCode project agents to their workspace and uses the selected agent for turns. No actionable merge-blocking issue was identified.

Pre-merge checks: Passed 4
Check name Status Explanation
Title check Passed The title clearly and concisely describes the main change: limiting OpenCode project agents to their workspace.
Description check Passed The description covers the problem, implementation, scope, linked issue, verification results, screenshots, recording, limitations, and agent attribution. It does not use the template headings, but th…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Description check

Explanation

The description covers the problem, implementation, scope, linked issue, verification results, screenshots, recording, limitations, and agent attribution. It does not use the template headings, but the required information is present and the verification details are comprehensive.

✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Usage-based review receipt

Note

This review was completed with usage-based billing: files reviewed beyond your plan's included limits are billed at $0.25/file. View usage-based billing.

Comment @coderabbitai help to get the list of available commands.

Base automatically changed from other-providers-14/workspace-options to main October 19, 2026 23:28
@juliusmarminge
juliusmarminge force-pushed the other-providers-14/opencode-workspace-agents branch from 3fbaeca to 5477dba Compare October 19, 2026 23:28

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

macroscope-review Opt PRs made by unvouched contributors in for Macroscope review. Vouched contributors auto-reviews size:L 100-499 changed lines (additions + deletions). vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: OpenCode project-local agents are missing from the agent picker

1 participant