Fix condense_json dedup skipping prior turns with no fragments - #1531
Open
ikatyal2110 wants to merge 1 commit into
Open
Fix condense_json dedup skipping prior turns with no fragments#1531ikatyal2110 wants to merge 1 commit into
ikatyal2110 wants to merge 1 commit into
Conversation
When log_to_db condensed multi-turn prompt_json, it only registered a
previous turn's response text as a replacement if that turn used at
least one fragment. For the common case of a plain-text turn, the
replacements[r:{id}] line was never reached (it was inside the inner
for-fragment loop), so the full text appeared verbatim in the next
turn's prompt_json instead of being condensed to a marker.
Also standardise the fragment marker key format: current-turn fragments
were keyed f"{id}" (no colon) while prior-turn fragments used f":{id}"
(with colon), causing the same fragment to get different markers depending
on which turn logged it. Both now use f":{id}".
Fixes simonw#1530
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.
In log_to_db, the line that registers a prior turn's response text as a condense_json replacement was inside the inner for-fragment loop. Any previous turn with no fragments — the common case for plain-text exchanges — never had its response text added to the replacements dict, so the full text was stored verbatim in the next turn's prompt_json rather than being condensed to a compact marker.
Also standardises the fragment marker key format: current-turn fragments were keyed f"{id}" (no colon) while prior-turn fragments used f":{id}" (with colon), causing the same fragment to receive different marker keys depending on which turn logged it. Both now use the f":{id}" form already used for response markers.
Fixes #1530
Generated by Claude Code