Skip to content

Commit 086aca7

Browse files
feat(opencode): expose running version and model in the env 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). The model id is only injected as prose in the main system prompt, not as structured data, and subagents/custom agents may not receive the same prompt template. Add both to the structured <env> block: - opencode version: the build-time InstallationVersion (falls back to 'local' in dev builds) - model: providerID/modelID, already in scope of environment(model) Fixes anomalyco#51909
1 parent 7f964bb commit 086aca7

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

‎packages/opencode/src/session/system.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import { LocationServiceMap, locationServiceMapLayer } from "@opencode-ai/core/l
2424
import { Reference } from "@opencode-ai/core/reference"
2525
import { MCP } from "@/mcp"
2626
import { PermissionV1 } from "@opencode-ai/core/v1/permission"
27+
import { InstallationVersion } from "@opencode-ai/core/installation/version"
2728

2829
export function provider(model: Provider.Model) {
2930
if (model.api.id.includes("muse")) {
@@ -81,6 +82,8 @@ const layer = Layer.effect(
8182
` Is directory a git repo: ${ctx.project.vcs === "git" ? "yes" : "no"}`,
8283
` Platform: ${process.platform}`,
8384
` Today's date: ${new Date().toDateString()}`,
85+
` OpenCode version: ${InstallationVersion}`,
86+
` Model: ${model.providerID}/${model.api.id}`,
8487
`</env>`,
8588
].join("\n"),
8689
references.length === 0

0 commit comments

Comments
 (0)