Skip to content

merge opencode's original system prompt (including AGENTS.md) into system prompt#17

Open
kikoreis wants to merge 4 commits into
dotCipher:mainfrom
kikoreis:fix/merge-agents-md-into-system-prompt
Open

merge opencode's original system prompt (including AGENTS.md) into system prompt#17
kikoreis wants to merge 4 commits into
dotCipher:mainfrom
kikoreis:fix/merge-agents-md-into-system-prompt

Conversation

@kikoreis

Copy link
Copy Markdown

I was surprised that my global AGENTS.md file was being ignored, and inspecting that led me here.

Previously the bridge code would replace opencode's entire system prompt (including AGENTS.md content) with the Claude Code identity blocks. This PR implements merging billingHeader, opencodeSystem and claudeCodeIdentity.

kikoreis added 4 commits May 13, 2026 20:51
Previously the bridge would replace opencode's entire system prompt
(including AGENTS.md content) with the Claude Code identity blocks.
Now we merge them: [billingHeader, ...opencodeSystem, ...claudeCodeIdentity]
Fix indentation
Previously the bridge would replace opencode's entire system prompt
(including AGENTS.md content) with the Claude Code identity blocks.
Now we merge them: [billingHeader, ...opencodeSystem, ...claudeCodeIdentity]
@0xsimulacra

Copy link
Copy Markdown

What if your Claude Code exiting prompt and Opencode "AGENTS.md" are actually the same ? will we send redundant ones or am I not understanding the problem well ?

Thanks taking notice btw, I imaging this will be a problem for people who have different "AGENTS.md" for both tools.

@0xsimulacra 0xsimulacra mentioned this pull request Jun 9, 2026
@dotCipher

Copy link
Copy Markdown
Owner

Thanks for this, @kikoreis — you found a real one. Dropping AGENTS.md because the bridge replaced opencode's whole system prompt is exactly the kind of silent behavior worth fixing, and splicing parsed.system back in is the right shape.

One bug to fix before merge: by the time this runs, the billing header has already been unshifted onto parsed.system a few lines up (src/index.ts:739-748), so parsed.system[0] is the billing block. Spreading ...parsed.system then re-includes it, and every request ends up with two x-anthropic-billing-header: blocks. Filtering it out first fixes it:

const opencodeSystem = parsed.system.filter(
  (s) => !s.text?.startsWith("x-anthropic-billing-header:")
);
parsed.system = [
  { type: "text", text: billingHeader },
  ...opencodeSystem,
  ...rewritten,
];

Two more things:

  • A quick unit test asserting exactly one billing header + AGENTS.md presence would lock this down (the repo's test setup makes this easy).
  • Heads up: fix: strip cache_control from Anthropic system blocks #24 (strip cache_control from system blocks) just merged conceptually alongside this — since you're adding system blocks, please rebase on latest main so you inherit the 4-block cache_control budget handling. To @0xsimulacra's question: identical prompts will produce some redundant text, which is wasteful but not breaking — the billing duplication above is the redundancy that actually matters.

Really nice catch overall. Fix the dup + add a test and I think this is good to go.

@dotCipher dotCipher left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requesting changes, see notes above for suggestions

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants