fix(tui): preserve chat roles after compaction - #6286
Conversation
Signed-off-by: zhuowp <zwp-1989@qq.com>
|
Thanks @zhuowp for taking the time to contribute. This repository is observing a maintainer-managed PR intake gate in dry-run mode, so this pull request is staying open. This note helps maintainers prepare the allowlist before any enforcement is considered. Please read |
|
Independent review, round 1: changes requested. P1 — No other blocking issue found in this round. The new wire ordering, provenance check, and restore-position behavior otherwise match the intended fix. |
Signed-off-by: zhuowp <zwp-1989@qq.com>
|
Independent review, round 2: PASS. Reviewed the complete diff against upstream No remaining blocking code-review findings. A live strict-provider call and migration of pre-fix sessions remain outside this PR's verification and scope. |
Summary
When compaction follows a tool result, the saved summary is a
usermessage after the tool exchange. Chat Completions then sendsuser → assistant(tool_calls) → tool → user, which strict paired chat templates reject. Move only generated summaries before the retained prompt on the outbound wire, place Agent topology checkpoints before the active tool chain, and keep tool-call IDs and persisted history intact. On session restore, retain the position of a generated checkpoint so later turns stay later.A second compaction must not mistake the runtime-owned topology checkpoint for a real user turn. Keep the actual user prompt and tool pair inside the protected round even when the prompt exceeds the minimum verbatim retention budget; runtime text cannot stand in for the user's prompt in the coverage check.
Testing
cargo fmt --all -- --checkandgit diff --checkpassed.unfulfilled_lint_expectations; the allow was removed before both commits. Full workspace checks and a live provider call were not run.No-Issue: reproduced downstream bug on upstream main; this PR provides the report and fix.