Skip to content

fix: only scrub requests that target Claude models - #18

Open
Nowaker wants to merge 1 commit into
rynfar:mainfrom
Nowaker:fix/claude-models-only
Open

Nowaker wants to merge 1 commit into
rynfar:mainfrom
Nowaker:fix/claude-models-only

Conversation

@Nowaker

@Nowaker Nowaker commented Sep 27, 2026

Copy link
Copy Markdown

Change

Meridian is gaining providers other than Claude, for example an OpenAI GPT/Codex gateway. When OpenCode talks to those, its requests still arrive on the opencode adapter, so this plugin would rewrite the system prompt before it reaches OpenAI. That changes the instructions the user sent and does nothing useful, because the scrub only exists to make OpenCode traffic look like Claude Code to Anthropic.

With this change, onRequest only scrubs requests whose ctx.model names a Claude model. That means Meridian's resolved SDK aliases (opus, sonnet, haiku, fable, optionally with [1m]) or any id that contains claude. Other models, such as gpt-6-luna or gpt-5.3-codex, pass through with their prompt byte-for-byte unchanged. For Claude requests the output is identical to before. A context with no model keeps the current behaviour. The README behaviour table documents the new rule.

Validation

  • I added the new tests to unchanged 0.2.3 main first. The 9 Claude-model cases passed, and the 6 GPT/Codex cases (gpt-6-luna, gpt-5.3-codex, openai/gpt-5.5 on both the opencode and passthrough adapters) failed because their prompt was rewritten.
  • On this branch, npm ci, bun test (37 pass, 0 fail), npm run build, tsc --noEmit and npm pack --dry-run all passed.
  • The Claude cases check that output with the alias or claude-* model matches the output with no model, so Claude scrubbing stays identical.

This PR is AI generated, but under direct supervision and on request of @Nowaker.

Meridian can serve providers other than Claude (for example an OpenAI
GPT/Codex gateway), and OpenCode requests to those still arrive on the
`opencode` adapter. The scrub exists to make OpenCode prompts look like
Claude Code to Anthropic; rewriting a prompt headed to another provider
only changes what the user asked for.

onRequest now returns the context unchanged when `ctx.model` names a
non-Claude model. Claude requests are recognised by Meridian's resolved
SDK aliases (opus/sonnet/haiku/fable, optionally `[1m]`) or any id
containing `claude`, so their output is byte-identical to before. A
context without a model keeps the previous behaviour.

AI-Tool: opencode 1.18.32
AI-Model: anthropic/claude-opus-5-5
AI-Variant: high
AI-Platform: linux
AI-Harness: Vibeterm 34e58e5
AI-Session-ID: ses_f1b57aaacffe4FrhMdS1oqKXAG
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.

1 participant