Skip to content

fix(executor): recursively strip cache_control for non-Anthropic embedders - #214

Open
warelik wants to merge 2 commits into
kaitranntt:mainfrom
warelik:ao/airouters-18-plus-strip-cache
Open

fix(executor): recursively strip cache_control for non-Anthropic embedders#214
warelik wants to merge 2 commits into
kaitranntt:mainfrom
warelik:ao/airouters-18-plus-strip-cache

Conversation

@warelik

@warelik warelik commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

Summary

Mirror of router-for-me/CLIProxyAPI#5154.

stripCacheControls previously only deleted top-level cache_control fields in tools, system, and messages. A Claude tool_result with structured content blocks that themselves carry cache_control would still forward the Anthropic-only field to Kimi and cause rejection.

  • stripCacheControls now recursively traverses every array and object.
  • cacheControlPaths collects every JSON path ending in cache_control, including nested tool_result content blocks.
  • Delete deepest paths first so sibling indices do not shift.
  • Added TestStripCacheControls and TestStripCacheControls_NestedToolResultContent.

Test plan

  • go build -o cli-proxy-api ./cmd/server
  • go test ./internal/runtime/executor

Cross-links

…dders

stripCacheControls previously only deleted top-level cache_control fields
in tools, system, and messages. A Claude tool_result with structured
content blocks that themselves carry cache_control would still forward the
Anthropic-only field to Kimi and cause rejection.

- Make stripCacheControls only target protocol-level cache_control markers on
  system/tool/message blocks and nested content arrays (e.g. tool_result
  content). It leaves arbitrary JSON like tool input_schema properties named
  "cache_control" untouched.
- Add stripContentCacheControls to recurse into nested content arrays without
  wandering into sibling objects such as tool input_schema or tool_use input.
- Add TestStripCacheControls and TestStripCacheControls_NestedToolResultContent.

Refs: router-for-me/CLIProxyAPI#5154
@warelik
warelik force-pushed the ao/airouters-18-plus-strip-cache branch from 49650b4 to 5d070f0 Compare August 21, 2026 19:59
@warelik

warelik commented Aug 21, 2026

Copy link
Copy Markdown
Contributor Author

CI build failure is the known scheduling-sensitive flake TestAntigravityConcurrentRequestsReusePooledConnections (same as documented on #198); not related to this diff.

warelik added a commit to warelik/CLIProxyAPIPlus that referenced this pull request Aug 21, 2026
warelik added a commit to warelik/CLIProxyAPIPlus that referenced this pull request Aug 21, 2026
…dders

stripCacheControls previously only deleted top-level cache_control fields
in tools, system, and messages. A Claude tool_result with structured
content blocks that themselves carry cache_control would still forward the
Anthropic-only field to Kimi and cause rejection.

- Make stripCacheControls only target protocol-level cache_control markers on
  system/tool/message blocks and nested content arrays (e.g. tool_result
  content). It leaves arbitrary JSON like tool input_schema properties and
  tool_use input named "cache_control" untouched.
- Add stripContentCacheControls to recurse into nested content arrays without
  wandering into sibling objects such as tool input_schema or tool_use input.
- Add TestStripCacheControls and TestStripCacheControls_NestedToolResultContent.

Refs: router-for-me/CLIProxyAPI#5154
@warelik
warelik force-pushed the ao/airouters-18-plus-strip-cache branch from e2b4e6f to 3d3a89a Compare August 21, 2026 22:09
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