Repository navigation
fix: preserve sender provenance through compaction - #149869
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. Reviewed September 16, 2026, 4:15 PM ET / 20:15 UTC (Revision 16). ClawSweeper reviewWhat this changesPreserves stored sender identities in conversation summaries, accounts for their token cost, and adds attribution and persisted-replay coverage. Merge readiness✅ Ready for maintainer review The fix remains necessary: current main and the latest release still discard sender attribution during summary serialization. No blocking introduced defect was found, and the latest commit preserves the behavior covered by the existing proof. Priority: P2 Review scores
Verification
How this fits togetherOpenClaw compaction turns older conversation messages into summaries used by later model requests. The serializer supplies conversation text to ordinary and branch summarizers while the original transcript remains intact. flowchart TD
A[Stored conversation turns] --> B{Stable sender ID present}
B -->|Yes| C[Escaped sender label]
B -->|No| D[Unattributed user label]
C --> E[Budgeted summary input]
D --> E
E --> F[Model with attribution instructions]
F --> G[Summary for later turns]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +72, Tests +583. Total +655 across 9 files. View PR surface stats
Review metricsNone. Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Technical reviewBest possible solution: Keep attribution preservation in the shared summarization path, anchored to stable IDs while leaving legacy history explicitly unattributed. Do we have a high-confidence way to reproduce the issue? Yes, from source: current-main serialization turns user messages carrying distinct persisted sender IDs into anonymous User rows. This review did not execute that path. Is this the best way to solve the issue? Yes. Extending the existing serializer and shared summary instructions repairs the projection boundary without adding configuration, rewriting transcripts, or creating another metadata store. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against fa5d32f78264. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (15 earlier review cycles; latest 8 shown)
|
9db7189 to
1a7aa52
Compare
8108fb7 to
88126d3
Compare
|
Maintainer verification of d9d8612: no blocking findings. The root cause is the shared compaction serializer, which discarded existing persisted sender metadata. I executed the main serializer at afc27e7 against two distinct IDs sharing a display name and an unattributed legacy turn: main anonymized both known speakers; this head preserved both IDs and left the legacy turn unattributed. The stable v2026.9.4 serializer has the same lossy behavior. Original introduction provenance remains unknown. Best-fix verdict: repair the existing summary projection and matching token accounting. Storage changes would duplicate existing metadata, and instructions alone cannot recover discarded IDs. Ordinary/custom/split-turn and branch requests share the attribution system invariant. No authentication, schema, or public signature changes. Verification commands: pnpm install --frozen-lockfile
node scripts/run-vitest.mjs packages/agent-core/src/harness/compaction src/agents/sessions/session-manager-provenance-compaction.test.ts src/agents/compaction.token-sanitize.test.ts src/agents/compaction-planning-worker.test.ts
# Passed all 3 selected Vitest shards in 39.17s.
# Main-versus-head serializer assertions also passed through node --import tsx.
autoreview --mode branch --base fc52265f8406ccc1efd69aa7e752b6c5ee5e1552 --max-priority P2
# Fresh independent review: scoped-clean, no P0–P2 findings.
git diff --check fc52265f8406ccc1efd69aa7e752b6c5ee5e1552 HEADExact-head hosted CI: https://github.com/openclaw/openclaw/actions/runs/35144784780 — completed successfully. No unresolved review threads. Latest ClawSweeper review covers this exact head and lists no remaining pre-merge requests/rank-up moves. Production LOC +195/-123 (net +72); tests +583/-0. Most completion code is relocated unchanged; added logic provides stable-ID projection, safely escaped optional labels, shared attribution policy, and matching accounting. No contributor code or ancestry was rewritten during this landing review. Proof limit: provider-backed ordinary/branch semantic runs are reported in the PR body and accepted by ClawSweeper; I did not rerun a provider call. The local tests prove prompt assembly, budgeting, session-tree persistence/reload/navigation, and deterministic serialization, not model semantics. |
|
Merged via squash.
|
* fix(compaction): retain user sender provenance * fix: preserve provenance instructions in branch summaries * fix(compaction): cover sender provenance budgets and prompts * test(compaction): satisfy strict provenance checks * test(compaction): pin sender token estimate * fix(compaction): resolve branch summary rebase * fix(compaction): keep branch provenance policy shared * test(compaction): align branch budget with serializer * fix(compaction): share sender suffix across message carriers * fix(compaction): keep sender policy after custom focus * test(compaction): cover stable sender identities * test(compaction): exercise provenance through session compaction * refactor(compaction): extract summary completion runner * fix(compaction): remove stale completion imports * fix(compaction): use type-only llm imports * fix(compaction): require stable sender ids * fix(compaction): make sender policy a system invariant * test(compaction): cover persisted provenance reload * fix(compaction): keep provenance instruction private --------- Co-authored-by: compoodment <[email protected]>
Summary
Fixes #149868.
What Problem This Solves
OpenClaw already persists stable channel sender metadata and exposes it during ordinary replay. Compaction was the projection boundary that discarded it, serializing every historic participant as anonymous
[User]. That can cause a later summary to merge different speakers' decisions or preferences.What changed
senderIdexists; display name and username are labels, not identity.sender={...}suffix to ordinary and branch-history token budgets.Evidence
Automated coverage
Real Behavior Proof
Two provider-backed synthetic runs exercised the patched ordinary and branch summary helpers. In each result, distinct stable-ID speakers remained distinct and an unlabeled legacy note remained unattributed. The inputs contained synthetic names and content only; no live conversation or delivery target was used. This verifies semantic behavior in addition to the request-assembly regressions above.
Serializer compatibility
The exported
serializeConversation(messages)signature is unchanged. Legacy user records without a stable sender ID preserve their existing[User]: …output. Only user records carrying a nonblank persistedsenderIdgain an escapedsender={...}suffix inside that existing user label; this is the intentional attributed-row extension. No public API or normal-replay behavior changes.Scope
This preserves provenance that the transcript already stored. It does not reconstruct authors for historic sessions that never had stable sender metadata, change normal replay, or add a public API.
Worked on by