GeezerVison is showing github.com — add optional system prompt environment injection · Issue #1894 · anomalyco/opencode
add optional system prompt environment injection #1894DescriptionAgents can have their custom system prompt. Environment system prompt gets added regardless.
Making this optional would reduce tokens and increase prompt adherence if this info is not needed for the agent to fulfill its task.
if (process.env.OPENCODE_NO_ENV_PROMPT !== 'true') {
system.push(...(await SystemPrompt.environment()))
}
Or even better: per agent in config, as system prompts can be defined there anyways:
"agent": {
"build": {
"mode": "primary",
"model": "anthropic/claude-sonnet-4-20250514",
"prompt": "{file:./prompts/build.txt}",
"envinfo": false
...
}
}
Reacted by Arsham Shirvani, Yoav Farhi, Federico Simonetta, Calvin Alkan, Hamish M. Blair, Konstantinos Kalyfommatos, Vitaliy Stoliarov, Cogni AI and nguyendown Activitycalvinalkan commented on Oct 1, 2025 Yes, this is very important to keep a clean context window.
The environent information is injected AFTER a custom Agent prompt, which puts limits on how you can end it.
I think, what makes much more send is having a placerholder in the prompt that gets replaced if it's present. Similar to arguments with / commands. rekram1-node commented on Oct 1, 2025 that's an interesting idea, kinda like it taqtiqa-mark commented on Oct 14, 2025
The environent information is injected AFTER a custom Agent prompt
Still getting my bearings, but shouldn't any system prompt be added separately:
const result = await generateObject({
model: openai('gpt-4o'),
system: `You are a SQL (postgres) ...`, // SYSTEM PROMPT AS ABOVE - OMITTED FOR BREVITY
prompt: `Generate the query necessary to retrieve the data the user wants: ${input}`,
schema: z.object({
query: z.string(),
}),
});
Also rather than optionally inject a hardcoded system prompt wouldn't it be better to allow users to define a SYSTEM.md per agent, say for the hypothetical IDE agent:
agent/ide.md
agent/ide/SYSTEM.md
agent/ide/create-ticket.md
...
This suggests there are three prompt types: Primary, System and Sub-Agents calvinalkan commented on Oct 14, 2025
The environent information is injected AFTER a custom Agent prompt
Still getting my bearings, but shouldn't any system prompt be added separately:
const result = await generateObject({
model: openai('gpt-4o'),
system: `You are a SQL (postgres) ...`, // SYSTEM PROMPT AS ABOVE - OMITTED FOR BREVITY
prompt: `Generate the query necessary to retrieve the data the user wants: ${input}`,
schema: z.object({
query: z.string(),
}),
});
Also rather than optionally inject a hardcoded system prompt wouldn't it be better to allow users to define a SYSTEM.md per agent, say for the hypothetical IDE agent:
agent/ide.md
agent/ide/SYSTEM.md
agent/ide/create-ticket.md
...
This suggests there are three prompt types: Primary, System and Sub-Agents
AFAIK, the system prompt for an agent can be defined already and is used as it. The issue is how it's merged with environment specific stuff, which you have no control over. Reacted by Konstantinos Kalyfommatos taqtiqa-mark commented on Oct 14, 2025
AFAIK, the system prompt for an agent can be defined already and is used as it.
Thanks. I see that Modes is now deprecated in favor of an agent option mode, and a mode did have a prompt option (which was the system prompt). However, agent docs say that mode has one option:
https://opencode.ai/docs/agents#mode:
The mode option can be set to primary, subagent, or all. If no mode is specified, it defaults to all.
So no more mode#prompt? hmblair commented on Mar 2, 2026 +1 on this. My use case is a research-only agent (web search, no local tools) where the environment block is pure noise. A per-agent config field like context: false would be ideal — simple and backwards-compatible. Reacted by Konstantinos Kalyfommatos and scientificworld konstantinoskalyfommatos commented on Apr 4, 2026 Hi, any updates regarding this request? Would be super helpful. github-actions commented on Jun 4, 2026 To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.
MetadataMetadataDevelopmentNo branches or pull requestsIssue actions
|