Repository navigation
feat(opencode): expose running version, provider and model in the env block - #51911
PascalBourdier wants to merge 2 commits into
Conversation
|
Hey! Your PR title Please update it to start with one of:
Where See CONTRIBUTING.md for details. |
|
The following comment was made by an LLM, it may be inaccurate: |
8c7c515 to
086aca7
Compare
… block Agents operating under 'state your engine and version' conventions (AGENTS.md PR traceability rules) cannot reliably know their own harness version: it is absent from the model context, which invites hallucinated values (observed: an opencode 1.18.30 agent declared 'opencode 0.11.x', anchored on a stale doc example). Add to the structured <env> block: - OpenCode version: the build-time InstallationVersion (falls back to 'local' in dev builds) - Provider: the provider ID (the canonical, actionable form used in opencode.json provider/model references) - Model: the models.dev display name, with the exact API id in parentheses Also fix the adjacent prose line: it called the API id 'the model named', which is an identifier, not a name (e.g. openrouter z-ai/glm-5.3) — it now uses the display name, keeping the canonical providerID/api.id reference as the 'exact model ID'. Fixes anomalyco#51909
086aca7 to
c0df7a6
Compare
Assert that environment(model) exposes the OpenCode version, the provider and the model identity (display name + exact API id) in the <env> block, and that the adjacent prose line uses the display name. Runs through the testEffect instance scaffolding (withTmpdirInstance), which provides the InstanceState context environment() reads.
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
|
The Head Fork leaf kvnloo#189 recorded fail→pass on That locks those three fields in the env block. It does not cover other system-prompt sections. |
Issue for this PR
Closes #51909
Type of change
What does this PR do?
The model context never includes the running OpenCode version, so agents asked to "state your engine and version" (a common AGENTS.md traceability rule) tend to guess: an opencode 1.18.30 agent was observed writing
opencode 0.11.xin a PR description, anchored on a stale doc example. The model id only appears as prose in the main system prompt, which subagents and custom agents may not receive.This adds three lines to the structured
<env>block of the session system prompt:OpenCode version: ${InstallationVersion}— the build-time constantProvider: ${model.providerID}— the canonical form used in opencode.json referencesModel: ${model.name} (${model.api.id})— models.dev display name + exact API idThe adjacent prose line is also fixed: it called the API id "the model named" (an id, not a name — e.g.
z-ai/glm-5.3); it now uses the display name and keepsproviderID/api.idas the "exact model ID".All values are already in scope of
environment(model)— no new service dependency.Context: #9065 asked for the same (model identity + version); only the model part landed (88bcd04, prose line), then it was stale-closed with an invite to re-open. #51909 is that re-open.
How did you verify your code works?
environment(model)inpackages/opencode/test/session/system.test.ts(asserts the three env lines and the fixed prose line); it runs through thetestEffectinstance scaffolding, which provides theInstanceStatecontext the function reads.bun run typecheck(turbo, all 30 packages) — green.bun test test/session/system.test.ts— 7 pass, 0 fail (6 existing + the new test; no existing assertion touches the env block or the prose line).bun run lint(oxlint) — no new findings from this change (the reported error and warnings are pre-existing on untouched lines).Screenshots / recordings
N/A — not a UI change.
Checklist