Repository navigation
fix(opencode): load agents before the first workspace snapshot - #1
Merged
soares-daniel merged 2 commits intoNov 16, 2026
Conversation
soares-daniel
merged commit Nov 16, 2026
4870edd
into
soares-daniel:opencode2-agent-selection
5 checks passed
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.
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-selectionbranch 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
a7d7373ab280d6a4b72169dac875efcd25260f15; head:4870edd5544e26d54ab3d046b38f611bc1129393.[]instead of discovered agents), then passes with this fix.vp run check:changed a7d7373ab280d6a4b72169dac875efcd25260f15passes format, lint, both knip stages, typechecking of 10 affected packages, and 44 tests in 2 files.zai-directturn 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):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.