anomalyco / anomalyco/opencode

agents: current agent identity is not provided in model context

Open
#42,125 1 comment 0 reactions 1 assignee View on GitHub

@nexxeln is already working on this.

Since Aug 12, 2026.

2.0
Dominant language
TypeScript
Stars
209k
Forks
27.5k
PR merge metrics
PR metrics pending

Description

Summary

The model does not know which agent (plan, build, or custom) it is running as,
because the current agent identity is not included in the model's system
prompt/context. It is only discoverable by querying the server API
(GET /api/session returns an "agent" field per session).

Environment

  • opencode version: v0.0.0-next-17163
  • OS: Windows_NT 10.0.26100.9168 (win32 x64)
  • Terminal: Unavailable (TERM_PROGRAM not set; TERM=xterm-256color)
  • Shell: cmd.exe (COMSPEC=C:\Windows\system32\cmd.exe)
  • Install/channel: beta (next)
  • Active plugins: none found in config

Reproduction

  1. Start a TUI session with the plan agent (Tab to switch or /agents).
  2. Ask the model: "Do you know whether you are the plan or build agent?"
  3. Observe the model cannot tell from its own context.
  4. Run opencode2 api get /api/session and find the current session's
    "agent" field (e.g. "agent":"plan").

Expected Behavior

The model should know its current agent identity directly from its context,
since the harness already stores this in session metadata.

Actual Behavior

The model's system prompt contains session ID, working directory, platform,
and other environment info, but no agent identity. The model must work around
this by querying the HTTP API, or it answers that it cannot know.

Additional Context

  • Reproducible consistently.
  • Workaround: opencode2 api get /api/session reveals the agent field,
    but this is awkward and requires the model to use the shell tool.
  • Suggest including the active agent in the injected context/system prompt.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.