Repository navigation
unexpected system prompt parts despite disabling default agent(s) #5005
Description
Description
Environment
- OpenCode version: v1.0.128
- Operating System: Linux (Debian Testing)
- Installation: Containerized setup via curl script
- Mode: TUI (no serve-attach)
- Configuration: Relevant agent settings as follows (with Plan, Build, and General agents disabled):
"agent": {
// Example agent:
"driven": {
"disable": false
},
"research": {
"disable": false
},
"knowledge-synthesizer": {
"disable": false
},
"plan": {
"disable": true
},
"build": {
"disable": true
},
"general": {
"disable": true
}
},- Note: The "driven" agent is a custom implementation that does not identify itself as "opencode."
Steps to Reproduce
- Configure OpenCode with the above agent settings, ensuring Plan, Build, and General agents are disabled.
- Start OpenCode in TUI mode.
- Initiate interaction with the LLM by entering a simple prompt, such as "Hello? Grok?" (or any initial query without specifying a custom prompt).
Expected Behavior
With the Plan, Build, and General agents disabled, the LLM should respond without any injected system prompts or self-identification as "opencode." Instead, it should provide the default response from the underlying LLM provider, free from any developer-imposed modifications or injections.
Actual Behavior
Upon initial interaction (e.g., "Hello? Grok?"), the LLM responds with:
Hello! I'm opencode, and AI coding assistant. How can I help with your software project? Type `/help` for usage info.
This indicates an unintended background prompt injection that overrides the configuration, forcing the LLM to identify as "opencode" despite the disabled agents intended to prevent such defaults.
Impact
This behavior undermines user control over the LLM's prompting, introducing unexpected modifications that could alter responses in unintended ways. It represents a potential security flaw, as users cannot reliably prevent developer-injected prompts from influencing their workflow, which may lead to privacy concerns, inconsistent outputs, or exposure to unconfigurable biases. In environments requiring strict prompt hygiene (e.g., custom agent integrations), this erodes trust in the tool's configurability.
Suggested Resolution
Ensure that disabling the Plan, Build, and General agents fully eliminates default prompt injections, allowing the LLM to revert to its provider's raw behavior. Consider adding explicit configuration options for system prompt overrides or a "raw mode" to give users granular control. This would enhance security and align with principles of user autonomy in AI tools.
OpenCode version
v1.0.128
Steps to reproduce
See above.
Screenshot and/or share link
NA
Operating System
Linux (Debian Testing)
Terminal
Alacritty+Zellij
Activity
github-actions commentedon Dec 3, 2025
This issue might be a duplicate of existing issues. Please check:
These issues all relate to the core problem: system prompts and agent identification are being injected despite configuration attempting to disable or override them. The root cause appears to be that the system prompt injection mechanism doesn't fully respect agent disable configurations.
Feel free to ignore if your specific case differs, but checking these would help determine if this is a known limitation or a related but distinct issue.
[-][Security] Prompt Injection (Attack Vector) Despite Disabling Relevant Agents[/-][+]unexpected system prompt parts despite disabling default agent(s)[/+]taqtiqa-mark commentedon Dec 3, 2025
@rekram1-node , can you clarify what would be a security issue?
In many contexts, prompt injection is a security breach. Example, a org (say bank) has it's own strict prompts that prohibit PII data being accessed, simulated or hypothesized.
Over riding those is a critical incident, generally you'd be expected to report the incident to the relevant authority/regulator...
rekram1-node commentedon Dec 3, 2025
I wouldn't classify this as a security issue because we intentionally include system prompts about opencode itself in many cases, this seems like it is either a bug or something isn't clear to the end user.
I don't think it's a security vulnerability that opencode includes a prompt informing an agent that it is opencode, now if there is some bug in terms of agent resolution maybe it could be classified under that but from what i read that didn't seem to be the case.
Can you share your agent definition? So we can get to the bottom of it?
taqtiqa-mark commentedon Dec 3, 2025
Understood. My understanding is that OC intends to give users full control over their prompt context. Of course you can make a different choice, no argument there.
With that understanding,
Agreed, if that is what happened in a default configuration... it would not be a bug/incident.
However, the bug, which is the security incident, is that default prompts were disabled. Yet still a OC developer prompt was injected into my workflow.
Sure. I've really struggled to work out the OC prompt heirachy. Can you tell me what log entries constitute the sequence of prompts that make up an "agent definition", and I can filter out that sequence of messages. Or what files make up that definition. For example there are AGENTS.md, at different levels, which can't be violated, etc. etc.
Perhaps this can be documented?
taqtiqa-mark commentedon Dec 3, 2025
Of course, if OC does NOT intend to give users full control over their workflow/prompt/context, then this is a non-issue and could be closed.
rekram1-node commentedon Dec 4, 2025
Yes we DO want to give full control for sure, I think the issue is currently there are things we inject regardless of your setup. Also note that AGENTS.md will always be included in prompts currently
And I totally agree we need better docs too
rekram1-node commentedon Dec 4, 2025
You are covering some of this ground before most so as you run into things such as this, we will fix them up, ideally anything basically should be entirely in your control. Rn that isn't the case but we wanna get there
rekram1-node commentedon Dec 4, 2025
Not docs but just to shed some light on how stuff works we have this system.ts file that resolves system prompts:
https://github.com/sst/opencode/blob/dev/packages/opencode/src/session/system.ts
And then this is where we build the finalized prompt:
https://github.com/sst/opencode/blob/32b5db754e948e010db8b010ba26d3331a747d77/packages/opencode/src/session/prompt.ts#L639
So if you have a custom agent prompt the only additional things being injected (unless you are using Anthropic) are:
system.push(...(await SystemPrompt.environment()))
system.push(...(await SystemPrompt.custom()))
custom is AGENTS.md files (and "instructions": [...] defined in your config if any)
environment is file tree, git dir, some other metadata about cwd
taqtiqa-mark commentedon Dec 4, 2025
Understood, but for a v1 release this is less cool. Give that v1 status, I'd argue again for this being a security issue and going to the top of the pile. But reasonable minds can disagree.
Would this be an accurate statement? If so, it can serve as i starting point for the documentation:
brendensuarez commentedon Feb 12, 2026
We need docs like this for the built-in agents, too and instructions on how to remove/replace them.
taqtiqa-mark commentedon Feb 12, 2026
In the spirit of calling out excellent engineering and design....
I've found that the Pi Coding Agent is more robust and, for me has none of the issues that I've encountered in OC, or has an elegant way to resolve them.... I'm dropping out of OC issues:
docs: add empty system prompt to codex command for speed (#1300)