fix(plugin): Fix OpenClaw commit failure semantics - #4441
Conversation
c7a3da5 to
4c7ae15
Compare
linhongyu510
left a comment
There was a problem hiding this comment.
archived=true proves that Phase 1 moved messages, but it does not currently prove that a compacted representation is available. Server get_session_context() deliberately excludes overviews from failed archives and merges their raw messages.jsonl back into current_messages. This branch can therefore return ok=true, compacted=true with an empty summary and the same uncompressed messages/tokens after Phase 2 fails. The added test does not exercise that contract: its getSessionContext fake always returns no messages and estimatedTokens: 0, so it cannot distinguish actual reduction from a false success report. Please add an integration-faithful regression where a failed archive contains raw messages and no authoritative overview, and require compacted=true only when the returned context demonstrates a usable compacted representation/token reduction. Otherwise this should remain a failure/degraded result until the server exposes explicit partial-success semantics.
linhongyu510
left a comment
There was a problem hiding this comment.
Correction to one sentence in my previous review: current _collect_session_context_components() does not merge the failed archive raw messages back. It stops at the newest failed terminal, excludes that archive and everything older, and only returns newer pending archives plus the live tail. The blocking conclusion still holds, but the concrete failure is stronger: failed + archived=true can be reported as compacted=true with no authoritative overview while the archived conversation is omitted from the returned context. The regression should therefore use a failed archive containing the only prior conversation, no overview, and an empty/new live tail, then assert that the plugin must not report successful compaction with an empty summary or silently drop that conversation. Apologies for the earlier inaccurate characterization of the read path.
Description
修复 OpenClaw 插件在 session commit Phase 2 失败后的 compact 语义。
当前服务端语义是:Phase 1 归档成功后,commit 边界已经成立;如果 Phase 2 后续失败,archive 会进入
.failed.json终态并被后续 context/commit 跳过,不应阻塞后续 commit。此前 OpenClaw 插件会把wait=true返回的 Phase 2 failed 统一当成 compact 失败,导致用户再次 compact 时看到commit_no_archive,表现为 session 像是无法继续压缩。本 PR 将
failed + archived=true明确处理为“压缩边界已建立,但 Phase 2 抽取降级失败”。同时保留 timeout 的未完成语义:timeout 不是终态,archive 仍可能 pending 并被 context 读取路径回放原文,因此不把timeout + archived=true报告为 compacted。Human Involvement
Related Issue
Fixes #4419
Type of Change
Changes Made
commitOVSession:当服务端返回status=failed且archived=true时,认为 Phase 1 边界已成立,返回成功;timeout 仍返回失败。compact:当failed + archived=true时返回compacted=true和reason=commit_archived_phase2_failed,并保留 commit details;当 timeout 时继续返回commit_timeout。Testing
执行过的验证:
npm test -- tests/ut/context-engine-compact.test.tsnpm run typecheckgit diff --checkChecklist
Screenshots (if applicable)
不适用。
Additional Notes
这次修复没有修改服务端 archive 状态机,只让 OpenClaw 插件的返回语义与现有服务端行为和测试约定对齐。