Repository navigation
Description
Summary
In opencode2 next-16741, an agent's system/prompt field is parsed into the agent definition but never sent to the model request. A session created directly with a custom agent that has a strong system prompt still receives the default OpenCode base prompt — the model has no idea which agent it is running as. This also explains why the built-in plan-mode reminders never reach the model in this build.
Environment
- opencode version: opencode2 v0.0.0-next-16741 (
@opencode-ai/cli@next, bun global install) - OS: Linux 6.18.33.2-microsoft-standard-WSL2 (Debian 13, x86_64)
- Terminal: xterm-256color
- Shell: /bin/bash
- Install/channel: next
- Active plugins: none found
Reproduction
- In project
opencode.jsonc, define a custom primary agent with a distinct system prompt (tried bothsystemandpromptfield names):
{
"agents": {
"planner": {
"mode": "primary",
"prompt": "You are planner, the planning agent for this project. You must not make any code changes. ..."
}
}
}- Confirm the agent definition loaded the prompt:
$ opencode2 api get "/api/agent?location[directory]=<project>"
# response includes: {"id":"planner","system":"You are planner, the planning agent for this project. ..."}
- Create a session directly with that agent and send a trivial prompt:
$ opencode2 api post /api/session \
--data '{"agent":"planner","model":{"providerID":"opencode-go","id":"deepseek-v4-flash"},"location":{"directory":"<project>"}}'
$ opencode2 api post /api/session/<id>/prompt --data '{"text":"Which agent are you? In one sentence, state your identity and mode."}'
- Observe the assistant reply.
Expected Behavior
The model should answer from the perspective of the custom agent (e.g. "I am planner, the planning agent, I do not make changes"), because the agent's system/prompt should replace the default base prompt for that agent.
Actual Behavior
The model answers with the default identity:
I am opencode, currently running in Code Mode.
The agent's system prompt is present in the agent definition (visible via /api/agent) but is not included in the model request. Same result for mid-session agent switches and for sessions created directly with the agent. In this build the built-in plan-mode reminders (session/reminders.ts) also never appear in the model context, consistent with agent prompt material being dropped from model requests.
Additional Context
OPENCODE_EXPERIMENTAL_PLAN_MODE=truewas set (verified in the running service env via/proc/<pid>/environ), yet no plan-mode workflow reminder reached the model.- Both
system(documented V2 field) andprompt(read by devagent.ts) were tried for the agent config; neither reached the model, while permissions from the same config block ARE enforced (edits denied in the read-only agent). - Related: When the plan is approved, it does not automatically switch to Build mode. #15231, Opencode stuck in Plan mode #3241, "Switching from Plan mode" doesn't switch from plan mode #8537, 计划模式无法退出 #10821 (plan mode UX broken), [FEATURE]: Let custom primary agents participate in plan mode (plan file path + configurable plan_exit handoff target) #31868 (custom planning agents can't participate).
Activity
github-actions commentedon Aug 4, 2026
This issue might be a duplicate of an existing issue. Please check:
instructions/promptfields inopencode.jsoncnot resolved into the agent's system prompt — the root cause described there (config-levelsystem/promptfields not reaching model requests) appears to overlap significantly with this report.opencode-agent commentedon Aug 4, 2026
I tested this against the exact published Linux binary from
@opencode-ai/[email protected], which was built from V2 commit28d784b83a413c5d4c306de7ba1a229462e40a6b.I configured a primary
planneragent with:{ "mode": "primary", "system": "CUSTOM-AGENT-SYSTEM-40395" }I then routed the provider to a local capture server and reproduced both paths described here:
opencode2 run --standalone --agent planner ...POST /api/sessionwithagent: "planner", followed byPOST /api/session/<id>/promptIn both cases, the first outbound model request contained this system message:
The source for that exact build also explicitly assembles the request from the selected agent system in
packages/core/src/session/model-request.ts:This behavior is covered by the test
uses an explicitly selected non-build agent systeminpackages/core/test/session-runner.test.ts.The observed model response therefore does not show that the system prompt was omitted. A stale/mismatched background service or model behavior would need separate evidence from the actual outbound request. Also,
systemis the native V2 field;promptis legacy syntax.There is a separate plan-mode parity gap: V2's built-in
planagent currently changes permissions but has no plan-specific system prompt, while the citedpackages/opencode/src/session/reminders.tsandOPENCODE_EXPERIMENTAL_PLAN_MODEbelong to V1 and are not part of the V2 request path. That should be tracked independently from the disproven custom-agent claim.Closing as not reproducible with the exact reported build and request flow.