Repository navigation
Description
English
What happened
A successful manual /compact checkpoint can be invalidated before the next ordinary Turn is sent.
The source-level sequence is:
- A completed function response (for example, E3) is still unarchived and has a result larger than the archive threshold.
- Manual
compactHistory()does not run tool-result pruning first. Its summarizer receives the current effective view of the covered events; if E3 has no earlier projection transition, that view includes the full E3 result. The successful checkpoint records coverage for that view. - On the next Turn,
prepareContextBudgetPolicy()runspruneToolResults()before deciding whether to replay the checkpoint. If E3 is archived at this point, its effective representation changes to an archive placeholder. - The checkpoint currency check rejects the checkpoint because its covered effective-history digest no longer matches. The next request is built without that checkpoint and from the effective event history, where E3 is now represented by the placeholder.
Thus the user can receive a successful manual-compaction result, but the very next Turn does not use that summary. This report concerns the cross-Turn sequence; it is not the already-fixed already_compacted fast-path defect from #5929, nor the stale-pruning replay-order defect from #3631.
Expected: a successful manual compaction should remain useful on the next Turn when the only intervening change is Maka's own archive projection of a covered tool result. The implementation should preserve checkpoint correctness while avoiding silently dropping the just-created summary (for example, by coordinating the archive transition and checkpoint, or explicitly rebuilding/replacing the checkpoint from the new effective view).
How to reproduce
Source-derived scenario; not yet reproduced in a live Desktop/TUI session:
- Have a completed session with an unarchived
function_responsewhose serialized result exceedsREAD_PAGE_MAX_BYTES(7,500 bytes). This can occur when the result predates pruning being enabled, or when no archive transition was committed at the time. - Run
/compact. Confirm it returns success and its checkpoint covers the large result. - Start a new ordinary user Turn with tool-result pruning enabled and archive services available.
- Inspect the checkpoint decision and outgoing model history. If that Turn archives the covered result, the old checkpoint is rejected for effective-history drift; the outgoing history has no compact checkpoint block and uses the archive placeholder for that result.
Relevant source paths: AiSdkCompaction.compactHistory(), prepareContextBudgetPolicy(), and AiSdkTurn pre-send context preparation.
Environment
- Maka version or commit: upstream
mainin the checked-out source at report time - Surface: Runtime; manual compaction exposed through Desktop/TUI
- Reproduction status: source-path confirmed; no live-session reproduction yet
Logs, screenshots, or additional context
compactHistory()passes the covered events throughfoldEffectiveModelHistory()for summarization, but does not callpruneToolResults()first.prepareContextBudgetPolicy()callspruneToolResults()before validating whether the stored checkpoint's effective coverage is current.- Archive candidacy is based on result size and projection eligibility; it is not an age-based rule.
- Related: fix(runtime): replay history checkpoint before stale Tool Result pruning #3631 (checkpoint replay vs stale pruning order), bug(runtime): manual compaction reports "already compacted" when the checkpoint's effective history is stale #5929 (manual compact fast path with an already-stale checkpoint), refactor(runtime): single owner for history-compact checkpoint currency #5930 (checkpoint-currency ownership).
中文
发生了什么
手动 /compact 成功写入的 checkpoint,可能在下一次普通 Turn 发送前就失效。
按当前源码,时序如下:
- 已完成的工具响应(例如 E3)尚未归档,且结果大于归档阈值。
- 手动
compactHistory()不会先执行工具结果裁剪。摘要器读取被覆盖事件当时的有效模型视图;如果 E3 尚无更早的投影转换,该视图就包含完整的 E3 结果。成功后 checkpoint 按这个视图记录覆盖范围。 - 下一次 Turn 开始时,
prepareContextBudgetPolicy()会先运行pruneToolResults(),再判断是否重放 checkpoint。如果此时 E3 被归档,它的有效表示就变成归档占位符。 - checkpoint 的覆盖范围摘要指纹不再匹配,于是 checkpoint 被拒绝。下一次模型请求不带这个摘要块,而是根据有效事件历史构建;E3 在其中表现为归档占位符。
因此用户可能看到手动压缩成功,但紧接着的下一 Turn 并没有使用刚生成的摘要。本 issue 讨论的是跨 Turn 时序;它不同于已由 #5931 修复的 #5929(手动压缩快路径误报 already_compacted),也不同于 #3631 的旧 checkpoint 与过期裁剪顺序问题。
期望行为:如果下一 Turn 唯一的变化是 Maka 自己归档了 checkpoint 覆盖范围内的工具结果,刚成功的手动压缩仍应对下一 Turn 有效。实现需要在保持 checkpoint 正确性的同时,避免悄悄丢弃刚创建的摘要(例如协调归档转换与 checkpoint,或基于新的有效视图明确重建/替换 checkpoint)。
如何复现
以下是源码推导场景;尚未在真实 Desktop/TUI 会话中复现:
- 准备一个已完成会话,其中有尚未归档的
function_response,序列化结果超过READ_PAGE_MAX_BYTES(7,500 字节)。例如该结果产生于启用裁剪之前,或当时没有成功提交归档转换。 - 执行
/compact,确认成功返回,且 checkpoint 覆盖了该大结果。 - 开始新的普通用户 Turn,并确保工具结果裁剪已启用、归档服务可用。
- 检查 checkpoint 决策和发出的模型历史。如果该 Turn 归档了被覆盖结果,旧 checkpoint 会因有效历史漂移而被拒绝;发出的历史不含该压缩 checkpoint 块,工具结果则显示为归档占位符。
相关源码路径:AiSdkCompaction.compactHistory()、prepareContextBudgetPolicy()、以及 AiSdkTurn 的发送前上下文准备。
环境
- Maka 版本或提交:报告时检视的 checkout 对应 upstream
main - 使用界面:Runtime;Desktop/TUI 暴露手动压缩入口
- 复现状态:已确认源码路径,尚无真实会话复现
日志、截图或其他上下文
compactHistory()会用foldEffectiveModelHistory()为摘要器准备覆盖事件,但不会先调用pruneToolResults()。prepareContextBudgetPolicy()会先调用pruneToolResults(),然后再检查 checkpoint 的有效覆盖是否仍然匹配。- 归档候选由结果大小和投影条件决定,不按结果年龄决定。
- 相关:fix(runtime): replay history checkpoint before stale Tool Result pruning #3631(checkpoint 重放与过期裁剪的顺序)、bug(runtime): manual compaction reports "already compacted" when the checkpoint's effective history is stale #5929(已有过期 checkpoint 时手动 compact 快路径)、refactor(runtime): single owner for history-compact checkpoint currency #5930(checkpoint currency 检查的归属)。
Drafted with AI-agent assistance from source inspection at the reporter's request; the reporter should review the issue after submission.
Activity
ggbdpq commentedon Oct 10, 2026
take
github-actions commentedon Oct 10, 2026
Issue #6048 is already assigned to me2seeks, so it was not reassigned.
fix(runtime): keep manual compaction checkpoints valid across tool-re…