anomalyco / anomalyco/opencode
agents: current agent identity is not provided in model context
@nexxeln is already working on this.
Since Aug 12, 2026.
- 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
- Start a TUI session with the
planagent (Tab to switch or/agents). - Ask the model: "Do you know whether you are the plan or build agent?"
- Observe the model cannot tell from its own context.
- Run
opencode2 api get /api/sessionand 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/sessionreveals theagentfield,
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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.