Skip to content

Feat/heuristic strip fold fixes - #13

Merged
varchanaiyer merged 3 commits into
mainfrom
feat/heuristic-strip-fold-fixes
Oct 14, 2026
Merged

varchanaiyer merged 3 commits into
mainfrom
feat/heuristic-strip-fold-fixes

Conversation

@soham96

@soham96 soham96 commented Oct 14, 2026

Copy link
Copy Markdown
Contributor

No description provided.

soham96 and others added 3 commits September 8, 2026 16:18
…ic strip

- pipeUpstream forwarded a stale content-encoding header on responses that
  undici's fetch had already decompressed, causing Claude Code's own fetch
  client to throw BrotliDecompressionError on every proxied request. Strip
  content-encoding/content-length from the forwarded response headers.

- transformRequest netted ScaleDown's summarize-call cost against Anthropic's
  savings as raw token counts (1:1), but the two are priced very differently
  (~$0.05/M vs Anthropic's cache read/write rates) — a cheap ScaleDown call
  could wipe out a real, substantial Anthropic-side saving. Net in dollars
  instead and expose both netSavingsUsd and a token-equivalent savedTokens.

- client.summarize() now optionally sends structured message blocks alongside
  the flattened text, so ScaleDown can run a heuristic tool-result-stripping
  pass server-side (x-source: kode) instead of a model call for DietCode's
  traffic specifically.

- foldEveryTurns default lowered 10 -> 5, closer to the point where the token
  safety net alone would otherwise trigger, based on real-session analysis.

Verified end-to-end against a real multi-prompt conversation: fold fires
correctly, heuristic strip runs server-side, and net savings are now reported
correctly instead of clamping to 0.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This repo is open source; comments describing exactly how the backend
decides to run its cheaper tool-result-stripping path (naming a private
file, and spelling out the client-identification header that gates it)
shouldn't be public here. Describe only what this client sends and why,
not how the backend routes on it.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@varchanaiyer
varchanaiyer merged commit e86ba25 into main Oct 14, 2026
3 of 6 checks 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.

2 participants