Skip to content

Commit c0df7a6

Browse files
feat(opencode): expose running version, provider 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). 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
1 parent 7f964bb commit c0df7a6

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

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

Lines changed: 5 additions & 1 deletion
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")) {
@@ -73,14 +74,17 @@ const layer = Layer.effect(
7374
}).pipe(Effect.provide(locations.get(Location.Ref.make({ directory: AbsolutePath.make(ctx.directory) }))))
7475
return [
7576
[
76-
`You are powered by the model named ${model.api.id}. The exact model ID is ${model.providerID}/${model.api.id}`,
77+
`You are powered by the model named ${model.name}. The exact model ID is ${model.providerID}/${model.api.id}`,
7778
`Here is some useful information about the environment you are running in:`,
7879
`<env>`,
7980
` Working directory: ${ctx.directory}`,
8081
` Workspace root folder: ${ctx.worktree}`,
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+
` Provider: ${model.providerID}`,
87+
` Model: ${model.name} (${model.api.id})`,
8488
`</env>`,
8589
].join("\n"),
8690
references.length === 0

0 commit comments

Comments
 (0)