Skip to content

[FEATURE]: expose the running OpenCode version, provider and model in the agent env block #51909

Description

@PascalBourdier

Feature hasn't been suggested before.

  • I have verified this feature I'm about to request hasn't been suggested before.

Note

After creation, a related prior request surfaced (#9065 — model identity only, partially implemented in 88bcd04, stale-closed with an invitation to re-open). It is fully disclosed in Related below; this request completes it (version never implemented + structured env block).

Problem

The agent's model context does not include the running opencode version, and the model identity is only injected in the main system prompt — not in the structured <env> block. The model cannot reliably know its own harness version without running opencode --version — and it doesn't know that it doesn't know.

Many projects' agent conventions (AGENTS.md files) require PR descriptions to declare which AI engine and version produced the changes, including the underlying model, for traceability. Faced with that requirement, the model has three options: run opencode --version (only if it thinks to — it usually doesn't), ask the user (rare), or guess.

Option 3 is an observed failure mode: LLMs confidently fill in missing facts, especially when a plausible-looking value sits nearby. Real case today: an agent running opencode 1.18.30 wrote opencode 0.11.x in a PR description, anchored on a stale opencode 0.x.y example in the project's AGENTS.md. The declared version was silently wrong, defeating the traceability rule — and no CI check can catch it, since the checker doesn't know the true version either.

Proposal

Inject the running version, the provider and the model identity into the existing <env> block:

<env>
Working directory: /Users/x/project
Platform: darwin
Today's date: Mon Sep 28 2026
OpenCode version: 1.18.30   ← proposed
Provider: openrouter         ← proposed (providerID, the canonical form used in opencode.json provider/model references)
Model: GLM 5.3 (z-ai/glm-5.3) ← proposed (models.dev display name + exact API id)
</env>
  • Cheap: a few tokens, always accurate.
  • Removes an entire class of hallucinated-version errors for projects with "state your engine and version" conventions (the same convention exists for Copilot CLI / Claude Code).
  • The model identity is currently injected as prose only ("You are powered by the model named ${model.api.id}") in the main system prompt — which misuses the API id as a name — and subagents / custom agents may not receive that prompt template at all. Including version, provider and model in the structured env block makes agent self-knowledge uniform and guaranteed for every agent mode — which is exactly what these conventions assume (their "when known" hedges exist because this self-knowledge is not guaranteed today).

Alternatives considered

  • A tool the agent can call to get the version: strictly worse — requires the agent to remember to verify, which is exactly what failed in the observed case.
  • Documentation telling agents to run opencode --version: unreliable for the same reason (the model doesn't know that it doesn't know).

Related

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions