Skip to content

fix(opencode): load agents before the first workspace snapshot - #1

Merged
soares-daniel merged 2 commits into
soares-daniel:opencode2-agent-selectionfrom
ooaklee:bug/opencode-v2-agent-discovery-startup
Nov 16, 2026
Merged

soares-daniel merged 2 commits into
soares-daniel:opencode2-agent-selectionfrom
ooaklee:bug/opencode-v2-agent-discovery-startup

Conversation

@ooaklee

@ooaklee ooaklee commented Nov 16, 2026 •

Copy link
Copy Markdown

Problem

A cold workspace scan can read an empty agent cache before OpenCode 2's first status probe completes. The workspace then caches models without the Agent option, overriding the later global catalog even though custom primary agents exist. This gap was found while validating pingdotgg/t3code#37153 for the global-agent problem reported in #11871.

Change

Initialize the agent cache when the first workspace requests it and serialize discovery reads. Reuse successful results, including an empty list, and retain the last successful list when a refresh fails.

Extend the existing discovery regression to exercise a workspace-first read and add an in-flight-read case. Include the web scenario used to validate global-agent visibility, filtering, and selection through the real T3 server and web client.

Scope

Targets this fork's opencode2-agent-selection branch so these additions can become part of the existing upstream PR. The diff is limited to three files: the loader, its tests, and the browser scenario. Agent eligibility, Plan precedence, and project-local discovery behavior are unchanged.

Verification

  • Base: a7d7373ab280d6a4b72169dac875efcd25260f15; head: 4870edd5544e26d54ab3d046b38f611bc1129393.
  • Cold-start unit regression fails on the target loader ([] instead of discovered agents), then passes with this fix.
  • vp run check:changed a7d7373ab280d6a4b72169dac875efcd25260f15 passes format, lint, both knip stages, typechecking of 10 affected packages, and 44 tests in 2 files.
  • Browser scenario on this branch: 1 test passed. The scenario covers the combined agent-selection behavior and uses deterministic OpenCode discovery responses.
  • Earlier live validation of the same implementation with OpenCode 2.3.0 completed a zai-direct turn using GLM 5.3/Low. The validation report includes the original before/after evidence; that run used the separate latest-main-based review branch.

Fresh browser capture on 4870edd5544e26d54ab3d046b38f611bc1129393 (real T3 server/web client, deterministic OpenCode discovery responses):

Global agents on the focused follow-up branch

AI assistance: Codex, GPT-6 Astra (ultra), with OpenCode OmniRoute GLM 5.3 and Codex Astra xhigh peer review. Both reviews approved with no required corrections. Checks were run by the implementing agent; reviewers inspected their results and the focused diff.

@github-actions github-actions Bot added the vouch:unvouched PR author is not yet trusted in the VOUCHED list. label Nov 16, 2026
@soares-daniel
soares-daniel merged commit 4870edd into soares-daniel:opencode2-agent-selection Nov 16, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants