Skip to content

Fix condense_json dedup skipping prior turns with no fragments - #1531

Open
ikatyal2110 wants to merge 1 commit into
simonw:mainfrom
ikatyal2110:fix-condense-json-dedup-without-fragments
Open

Fix condense_json dedup skipping prior turns with no fragments#1531
ikatyal2110 wants to merge 1 commit into
simonw:mainfrom
ikatyal2110:fix-condense-json-dedup-without-fragments

Conversation

@ikatyal2110

Copy link
Copy Markdown
Contributor

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

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
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.

condense_json dedup in log_to_db skips fragment-less previous turns; inconsistent fragment marker keys

2 participants