Repository navigation
fix(compression): RTK compresses Anthropic-shape tool_result blocks - #4468
Merged
diegosouzapw merged 1 commit intoJun 21, 2026
Merged
Conversation
RTK only compressed OpenAI-shape tool results (role:"tool"); Anthropic-shape tool_result content blocks inside (typically role:"user") messages were skipped entirely, so coding agents speaking the Anthropic Messages format saw zero RTK savings — e.g. a `git status` tool result was never filtered. caveman/aggressive already handle this shape (B-AGG-ANTHROPIC-TR via compressAnthropicToolResultBlock); RTK was the only engine that didn't. - shouldCompressMessage: messages whose content has a tool_result block are eligible (gated by applyToToolResults), same as OpenAI tool messages - toolCallLookup also captures Anthropic assistant tool_use blocks (id -> name/command) - new processToolResultBlocks compresses the inner text of each tool_result block (string or nested text-block array), preserving block type + tool_use_id exactly; resolves command/skipFilters per block via tool_use_id - extract SHELL_TOOL_NAME_RE + resolveToolMeta, shared by the OpenAI and Anthropic paths TDD: tests/unit/compression/rtk-anthropic-tool-result.test.ts (red -> green). Full compression suite 774/774.
Contributor
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Merged
tkgo11
pushed a commit
to tkgo11/OmniRoute
that referenced
this pull request
Sep 23, 2026
…heaper-inference#4468) Integrated into release/v3.8.32
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
A user reported: "I set compression mode to only RTK, but it's not working — I ran
git statusvia my agent and the RTK stats stayed the same." (community-escalatedcmqmf7d29).Root cause
applyRtkCompressiononly compressed OpenAI-shape tool results (role:"tool"). Anthropic-shape tool results — which arrive astool_resultcontent blocks inside a (typicallyrole:"user") message — were skipped entirely. So coding agents speaking the Anthropic Messages format (/v1/messages, "Claude format — auto convert via handleChat") got zero RTK savings, even though RTK's command-aware filters (e.g.git-status) would have compressed the output.caveman/aggressivealready handle this shape (B-AGG-ANTHROPIC-TRviacompressAnthropicToolResultBlockintoolResultCompressor.ts); RTK was the only engine that didn't.Fix (
open-sse/services/compression/engines/rtk/index.ts)shouldCompressMessage: a message whose content array contains atool_resultblock is now eligible (gated byapplyToToolResults), same as an OpenAI tool message.toolCallLookup: now also captures Anthropic assistanttool_useblocks (id → name / input.command), so the shell command resolves exactly like the OpenAItool_call_idpath. (Removed the earlycontinuethat skipped the content scan.)processToolResultBlocks: compresses the inner text of eachtool_resultblock (string or nested text-block array), preserving blocktype+tool_use_idexactly; resolves command/skipFiltersper block.SHELL_TOOL_NAME_RE+resolveToolMeta, shared by the OpenAI and Anthropic paths (reuses the existingisAnthropicToolResultBlockdetector — DRY).Legacy/OpenAI behavior is unchanged: non-
tool_resultcontent androle:"tool"messages take the exact same path as before.Tests (TDD)
New
tests/unit/compression/rtk-anthropic-tool-result.test.ts— red→green:tool_resultinside a user message → compressed,tool_use_id/structure preserved,(use ...)noise dropped, branch/changed-file lines kepttool_result(nested text blocks) → inner text compressedtool_resultuser content → untouched (control)Validation: full compression suite 774/774 ·
typecheck:coreclean ·lint0 new warnings ·check:file-sizeOK ·check:any-budget:t11PASS.