fix: avoid duplicating cache_control when splitting identity system entry (#131)
## Summary
- When the identity prefix is split from a concatenated system entry,
`cache_control` was copied to **both** the identity block and the
remainder block
via the spread operator
- This causes the Anthropic API to reject with `"A maximum of 4 blocks
with cache_control may be provided"` when users already have context
files
(CLAUDE.md, project docs, etc.) using the 4 allowed cache_control slots
- Now only the remainder block preserves `cache_control`; the identity
block is sent without it
## Reproduction
1. Use OpenCode with `opencode-claude-auth` plugin
2. Load multiple context files with `cache_control` (e.g. CLAUDE.md +
project docs that fill all 4 slots)
3. Send any request → API returns 400: `"A maximum of 4 blocks with
cache_control may be provided. Found 5."`
## Fix
```diff
const { text: _text, ...entryProps } = entry
- splitSystem.push({ ...entryProps, text: SYSTEM_IDENTITY })
+ const { cache_control: _cc, ...identityProps } = entryProps
+ splitSystem.push({ ...identityProps, text: SYSTEM_IDENTITY })
```
## Test plan
- Updated existing test to verify identity block does NOT have cache_control
- Remainder block still preserves cache_control
- All 26 existing tests pass J
JaeHyeonKim committed
adcfd61b62401b82bc65bd34b7b2276ebd89ae2f
Parent: e13f0e1
Committed by GitHub <noreply@github.com>
on 4/4/2026, 6:20:28 PM