fix: enable thinking block pruning — reasoning/message hash visibility#17
Merged
tuanhung303 merged 4 commits intomasterfrom Feb 7, 2026
Merged
fix: enable thinking block pruning — reasoning/message hash visibility#17tuanhung303 merged 4 commits intomasterfrom
tuanhung303 merged 4 commits intomasterfrom
Conversation
- Consolidate 3 duplicate stableStringify/deterministicStringify into single export - Remove duplicate INPUT_METADATA_KEYS, stripHashTags, applyPatternReplacements from prune.ts - Wire applyPatternReplacements into message transform pipeline (was defined but never called) - Fix persistence bug: saveSessionState now includes cursors, todos, discardHistory - Delete dead lib/config-cache.ts (113 lines, 0 imports) - Extract 6 supersede strategies from 405-line syncToolCache into named functions - Replace extractParameterKey if-else chain with lookup map - Fix circular dependency in shared-utils.ts import
…lity Reasoning and message hashes were injected into text parts then stripped by stripAllHashTagsFromMessages before the LLM could see them. Now: - Primary channel: inject into last completed tool output (never stripped) - Fallback: text parts with selective stripping (preserves reasoning/message hashes) - Last resort: synthetic text part for reasoning-only messages Partial fix: message_hash now visible, reasoning_hash still not appearing when no tool calls exist in the response. Further investigation needed.
injectHashesIntoAssistantMessages was calling stripHashTags() on text parts for idempotency, which destroyed reasoning_hash tags injected by the prior pipeline step. Now uses stripHashTagsSelective() to preserve reasoning hashes while still stripping other tag types.
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.
Summary
stripAllHashTagsFromMessagesnow preservesreasoning_hashandmessage_hashin text parts for LLM visibilityinjectHashesIntoAssistantMessagesno longer destroysreasoning_hashtags injected by the prior pipeline stepRoot Cause
Result: agents could never see reasoning hashes → could never prune their own thinking blocks.
Changes
lib/state/hash-registry.tsstripHashTagsSelective()— strips by type, preserves specified typeslib/messages/prune.tslib/prompts/context-spec.tstests/e2e/thinking-blocks.test.tstests/fixtures/mock-client.tsVerified
reasoning_hashandmessage_hashacross all providers