Skip to content

add optional system prompt environment injection #1894

Closed as not planned
Closed as not planned

Description

@Jacubeit

Agents 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
      ...
   }
}

Activity

  1. calvinalkan commented on Oct 1, 2025

    @calvinalkan

    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.

  2. rekram1-node commented on Oct 1, 2025

    @rekram1-node
    Contributor

    that's an interesting idea, kinda like it

  3. taqtiqa-mark commented on Oct 14, 2025

    @taqtiqa-mark

    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

  4. calvinalkan commented on Oct 14, 2025

    @calvinalkan

    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.

  5. taqtiqa-mark commented on Oct 14, 2025

    @taqtiqa-mark

    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?

  6. hmblair commented on Mar 2, 2026

    @hmblair

    +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.

  7. konstantinoskalyfommatos commented on Apr 4, 2026

    @konstantinoskalyfommatos

    Hi, any updates regarding this request? Would be super helpful.

  8. github-actions commented on Jun 4, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions