fix(compaction): preserve usr txt query to prevent Jinja template crash#1704
fix(compaction): preserve usr txt query to prevent Jinja template crash#1704krisclarkdev wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Code Review
This pull request updates the message compaction logic in crates/tui/src/compaction.rs to ensure that at least one user text query is always preserved, preventing potential crashes in backends like vLLM when a context consists solely of tool interactions. A new unit test was added to verify that the oldest user query is correctly pinned. The review feedback suggests refactoring the logic for identifying user text queries into a closure to eliminate code duplication and improve maintainability.
…rash When auto compaction runs on a session where recent history is dominated by tool calls and results, all original user text queries could be dropped from the pinned context. This causes backend inference servers (e.g. vLLM/SGLang hosting DeepSeek V4) that rely on Jinja chat templates to throw a "No user query found in messages" exception. This fix forces `plan_compaction` to scan backwards and pin at least one user text query if the recent pinned context lacks one.
b075ece to
72310ba
Compare
Bump workspace, inter-crate, and npm package versions 0.8.38 -> 0.8.39. Roll CHANGELOG [Unreleased] into [0.8.39] with all fixes: - Revert v0.8.38 /model picker rework (back to instant curated picker) - Restore approval grouping (lossy v0.8.37 logic for approvals, exact key for denials) - Thinking-only turn surface fix (#1727) - ACP server JSON-RPC id stringification (#1696) - Chat client: reasoning_content for generic providers (#1673) - Compaction: user text query preservation (#1704) - Engine: system prompt override survival (#1688) - Pager: G/End overshoot fix (#1706), mouse scroll (#1716) - Composer: scroll with text (#1677), multiline arrows (#1721) - macOS system theme detection (#1670) - rlm_open blank source fields (#1712) - Terminal resize paging fix (#1724) - Docker first-run permission (#1684) - README Rust 1.88+ requirement note (#1718) Tests: 3149 passed, 0 failed (deepseek-tui crate) clippy: clean on --all-targets --all-features
|
Thanks, this was the right bug to catch. The compaction user-query preservation fix was harvested into v0.8.39 via #1734 and credited in the changelog, so I am closing this PR to keep the queue clean. Any remaining cache/compaction performance work is now tracked under the v0.8.40 milestone. |
When auto compaction runs on a session where recent history is dominated by tool calls and results, all original user text queries could be dropped from the pinned context. This causes backend inference servers (e.g. vLLM/SGLang hosting DeepSeek V4) that rely on Jinja chat templates to throw a "No user query found in messages" exception.
This fix forces
plan_compactionto scan backwards and pin at least one user text query if the recent pinned context lacks one.Summary
Testing
cargo test --all-featurescargo fmt --all -- --checkcargo clippy --all-targets --all-featuresChecklist