fix(release): 0.1.4 — preserve cache_control on relocated system-instructions wrapper + hyphen-safe sanitize opt-in
The previous implementation pushed the relocated <system-instructions>
wrapper into messages[0] without cache_control, so every request re-billed
the full relocated prefix (skills list, MCP tool instructions, agent
prompts, AGENTS.md, etc.) as fresh input tokens on every turn — a major
cost regression vs. native Claude Code, which caches its system prompt
aggressively.
Why it matters: with long-lived sessions, ~150k of relocated content was
being re-billed at full input-token pricing on every single turn instead
of at cache_read pricing (~10% of fresh). After the fix, turn 1 pays
cache_creation and turn 2+ reads from cache.
What changed:
- src/request/body.ts: the wrapped block now carries
cache_control: { type: \"ephemeral\" }. String user-content is reshaped
into [wrapper, original_text] so the wrapper can actually carry
cache_control (strings have no slots for it). Original user text stays
as a second block with no cache_control so per-turn content does not
invalidate the cache key.
- src/request/body.history.test.ts: 3 existing tests updated to assert
the new block shape and cache_control presence. 112 expects across
43 tests, all passing.
Bundled alongside the already-staged relocation + sanitize-opt-in work:
- Sanitize default flipped from true to false. The default is now
byte-faithful mimicry via aggressive relocation, not in-place scrubbing.
- Sanitize regexes use negative lookarounds for [\\\\w\\\\-/] on both
sides, so hyphenated identifiers (opencode-anthropic-fix) and file
paths (/Users/.../opencode/dist) survive verbatim when the sanitizer
is opted in.
- New config field signature_emulation.sanitize_system_prompt, top-level
alias, and OPENCODE_ANTHROPIC_SANITIZE_SYSTEM_PROMPT env var.
- logTransformedSystemPrompt now detects title-generator requests after
relocation too (previously it only checked parsed.system and missed
relocated titles, violating the debug-log suppression contract).
Tests: 933/933 vitest pass. V
Vacbo committed
491e7b3dfbd40adad0d988088cde6b188b5325a0
Parent: f4a3850