fix: scrub blocked URLs from system[] instead of relocating all content#198
fix: scrub blocked URLs from system[] instead of relocating all content#198s2bomb wants to merge 1 commit intogriffinmartin:mainfrom
Conversation
bvironn
left a comment
There was a problem hiding this comment.
Tested locally — 214/214 tests pass. The empirical probe table in the PR body is excellent: it isolates the server-side trigger to one substring.
Two follow-ups worth considering:
-
Empty replacement leaves text artifacts: replacing
github.com/anomalyco/opencodewith""can produce dangling phrases like"Visit for help"in the prompt. Consider replacing withopencode.ai(functionally equivalent project URL — passes the validator per your probe row 11) to keep the prompt grammatically intact. -
Blocklist extensibility: a single hardcoded string is fine today, but future Anthropic additions would force another release cycle. An optional
OPENCODE_CLAUDE_AUTH_BLOCKED_STRINGS(comma-separated) merged with the built-in list would let users self-mitigate. Not blocking.
Strict improvement over v1.4.8 either way. Resolves #154 and #210.
…list - Replace 'github.com/anomalyco/opencode' with 'opencode.ai' instead of empty string so surrounding prose stays grammatical (no double spaces or dangling phrases). - Add OPENCODE_CLAUDE_AUTH_BLOCKED_STRINGS env var (comma-separated, optional 'pattern=replacement' form) so users can self-mitigate future server-side additions without a release cycle. - Restate scrub-in-place comment for clarity. - Add tests for grammatical replacement, realistic concatenated prompt, and env-var parser. Fix lint formatting flagged by oxfmt --check. Addresses review feedback from @bvironn on griffinmartin#198.
9b897cb to
a10b2b6
Compare
|
Getting Force pushed your original commit, can bring mine back in if this is resolved. |
Problem
v1.4.8 moved ALL non-core system content to the first user message to avoid Anthropic's 400 rejection. This regresses instruction priority and prompt-cache efficiency — AGENTS.md, env blocks, skills all lose system[] attention priority.
Root cause
Server-side blocklist. One URL triggers rejection:
github.com/anomalyco/opencode.Reproduces with Claude Code itself:
Not a client fingerprint. Not an auth issue. Server-side content filter.
Probe results
15 targeted requests varying system[] content. Same OAuth, same billing, same model.
github.com/anomalyco/opencodeopencode.aiURLSingle URL. Nothing else.
Fix
Scrub blocked URL substring in-place. Entry stays in system[]. No content relocation.
OpenCode concatenates the full prompt (identity + agent prompt + env + AGENTS + skills) into one system[] entry. Old approach relocated the whole entry on match → frontloaded everything into user message. This fix removes only the URL string.
Wire dump verification
Before (v1.4.10):
"You are OpenCode, the best coding agent..."← frontloadedAfter:
"What tools do you have? List 3."← cleanTests
214 pass. No new deps.