Skip to content

fix: scrub OpenCode prompts routed through LiteLLM - #14

Merged
rynfar merged 1 commit into
mainfrom
codex/fix-litellm-passthrough-10
Sep 24, 2026
Merged

rynfar merged 1 commit into
mainfrom
codex/fix-litellm-passthrough-10

Conversation

@rynfar

@rynfar rynfar commented Sep 24, 2026

Copy link
Copy Markdown
Owner

Change

Fixes #10. Accept passthrough requests because LiteLLM removes the OpenCode client headers used for adapter detection. Before scrubbing passthrough traffic, require a distinct OpenCode or OhMyOpenCode marker. The shared <env> preamble alone is insufficient evidence; genuine Claude Code requests may contain it and must stay unchanged.

The existing direct opencode path keeps its behavior. Added regression tests for the LiteLLM classification, genuine Claude Code prompt bytes, incidental OpenCode mentions, and direct OpenCode requests.

Validation

  • On unchanged 0.2.1 main with the new tests, bun test src/__tests__/plugin.test.ts failed 3 of 4: missing passthrough adapter and two foreign prompts altered when the hook was invoked.
  • On this branch, npm ci, npm test (21 pass), npm run build, and npm pack --dry-run passed.
  • Live macOS path with actual OpenCode 1.18.32 → LiteLLM 1.81.10 → Meridian 1.76.3 → Claude Agent SDK / Opus 5.5. With unchanged 0.2.1 plugin, LiteLLM classified the request passthrough; the powered-by line and duplicate environment preamble reached the SDK, and OpenCode ended in the billing_error subscription gate. Control artifact: opencode-scrub-live-AEcLtt.
  • Same client, LiteLLM, Meridian, model, and fixture with the fix: the pre-plugin hook saw both markers, the post-plugin hook saw neither, the client working-directory field was retained, and OpenCode received a successful model answer. Candidate artifact: opencode-scrub-live-0tBBC7.
  • Haiku 4.5 also passed with the candidate (opencode-scrub-live-Olv8DN); unchanged plugin reproduced the billing gate on Haiku (opencode-scrub-live-v0rurN). The E2E harness is /tmp/opencode-scrub-live-e2e.mjs and keeps credentials/transcript content out of its summary.

@rynfar
rynfar merged commit c517a2c into main Sep 24, 2026
1 check passed
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.

Scrub never runs when opencode traffic arrives via LiteLLM (adapter=passthrough), requests 400 on Anthropic's extra-usage gate

1 participant