Skip to content

agents: system/prompt not applied to model requests — model ignores agent identity #40395

Closed as not planned

Description

@gnh1996

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

  1. In project opencode.jsonc, define a custom primary agent with a distinct system prompt (tried both system and prompt field names):
{
  "agents": {
    "planner": {
      "mode": "primary",
      "prompt": "You are planner, the planning agent for this project. You must not make any code changes. ..."
    }
  }
}
  1. 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. ..."}
  1. 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."}'
  1. 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

Activity

  1. github-actions commented on Aug 4, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of an existing issue. Please check:

  2. opencode-agent commented on Aug 4, 2026

    @opencode-agent
    Contributor

    I tested this against the exact published Linux binary from @opencode-ai/[email protected], which was built from V2 commit 28d784b83a413c5d4c306de7ba1a229462e40a6b.

    I configured a primary planner agent with:

    {
      "mode": "primary",
      "system": "CUSTOM-AGENT-SYSTEM-40395"
    }

    I then routed the provider to a local capture server and reproduced both paths described here:

    1. opencode2 run --standalone --agent planner ...
    2. POST /api/session with agent: "planner", followed by POST /api/session/<id>/prompt

    In both cases, the first outbound model request contained this system message:

    CUSTOM-AGENT-SYSTEM-40395
    Here is some useful information about the environment you are running in:
    ...
    

    The source for that exact build also explicitly assembles the request from the selected agent system in packages/core/src/session/model-request.ts:

    const system = [agent.info.system ? agent.info.system : PROMPT_DEFAULT, input.context.initial]

    This behavior is covered by the test uses an explicitly selected non-build agent system in packages/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, system is the native V2 field; prompt is legacy syntax.

    There is a separate plan-mode parity gap: V2's built-in plan agent currently changes permissions but has no plan-specific system prompt, while the cited packages/opencode/src/session/reminders.ts and OPENCODE_EXPERIMENTAL_PLAN_MODE belong 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.

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

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions