fix: exclude image bytes from compaction token estimates (#255) - #259
fix: exclude image bytes from compaction token estimates (#255)#259Zheng-Lu wants to merge 1 commit into
Conversation
Signed-off-by: Zheng Lu <Lz429671594@gmail.com>
|
AI-assisted integration check for merge sequencing, not a blocker for this PR against current main. I checked a3eabb1 alongside the signed core-session proposal #257 (51c3613) and typed-file validation #258 (fab52ff) in an isolated local stack. Two additional combination-only adaptations were needed in compaction.rs:
With #258's validation placed in the shared rehydrate_with_continuation path and both documentation sections retained, the stack passed 985 tests / 9 ignored, plus strict all-target/all-feature Clippy. This is a combined-stack result, not a claim about your standalone CI. Four extra session checks passed: image-preserving source/fork continuations; text-triggered compaction followed by durable promotion and fresh-session restoration; real serialized image bytes still exceeding the retention budget; and file rejection releasing the session before a valid image retry. These same cases fail with the original image-byte estimator. I had a separate local #255 prototype, but will not open a competing implementation. Happy to contribute the focused session regressions once the shared base is settled. Validation used SQLite/disabled storage and local HTTP substitutes; no live model/GPU or full PostgreSQL claim. |
Thanks for the thorough integration check and the positive feedback! It's great to hear that the estimator holds up well across those multi-turn session and image-continuation edge cases. The two adaptations for #257 and #258 look very straightforward. If either of those lands before this PR, I'm happy to rebase and add the InputFile arm and test fixture update. Looking forward to your session regression tests once the base lands! |
Summary
Fixes #255.
Replace whole-input JSON serialization in Responses compaction token estimation with a borrowed, typed traversal of the effective model-facing input.
The new estimator:
The Responses compaction guide now documents the heuristic and its model-specific limitations.
Test Plan
cargo fmt --all -- --checkcargo clippy --all-targets -- -D warningscargo testcargo test -p agentic-server-corecargo test -p agentic-server-core --test compaction_cassette_testAdded coverage verifies:
view_imagetool call outputs use the same image policy.