Repository navigation
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. |
9dab3e4 to
41b750e
Compare
|
Codex review: needs real behavior proof before merge. What this changesAdds a model-facing tool that requests summarization of the current session after reply delivery, with runtime wiring, display metadata, documentation, and tests. Review scores
Merge readiness⛔ Blocked before merge - 12 items remain Keep open: this remains a distinct, useful proposal paired with an open issue. All four previous blockers remain at the unchanged head, and the contributor’s willingness to adopt a plugin capability gives maintainers a concrete product choice. Priority: P2 Decision needed
Before merge
Findings
Agent review detailsHow this fits togetherOpenClaw’s reply runtime turns model tool calls into recorded requests and delivered responses. Session compaction then summarizes older conversation history and updates the context accounting used by subsequent turns. flowchart TD
A[Model tool call] --> B[Record compaction request]
B --> C[Finish agent turn]
C --> D[Reply delivery settlement]
D --> E[Compaction scheduling]
E --> F[Existing summarization pipeline]
F --> G[Transcript and context accounting]
Technical reviewBest possible solution: Keep compaction execution with the existing preemptible maintenance owner, preserve operator settings, and expose topic-shift policy through a maintainer-approved capability surface. Do we have a high-confidence way to reproduce the issue? Yes for the patch defects: source establishes missing assembler exports and bindings, an unchecked opt-out, and incomplete scheduling guards. Runtime scenarios were not executed in this read-only review. Is this the best way to solve the issue? No as submitted: reuse of the existing summarizer is appropriate, but scheduling must use the established maintenance owner and the capability surface needs maintainer direction. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against aad3deb6d88e. Merge-risk optionsMaintainer options:
SecurityNone. EvidenceWhat I checked:
PR surfaceSource +467, Tests +466, Docs +12. Total +945 across 29 files. View PR surface stats
Review metrics
LabelsLabel changes: No label changes. Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (7 earlier review cycles)
Reviewed October 2, 2026, 4:30 PM ET / 20:30 UTC (Revision 8). |
41b750e to
95eb1a0
Compare
738ac9c to
4495c3d
Compare
4495c3d to
2cf2586
Compare
Let the model request compaction of the current session when it judges the conversation ready - for example when a topic concludes and a new one starts - instead of waiting for context pressure. - Add the session_compact built-in tool following the sessions_yield pattern: the tool records the request, the runtime owns execution. - The tool is only offered when the runtime provides a compaction request receiver; heartbeat turns and native-compaction runtimes ignore requests, and failures never fail the recorded reply. - Execution reuses the manual compaction pipeline (trigger manual, force, focus passed as customInstructions) after the turn completes, so checkpoints, hooks, and quality guards apply unchanged. - Document the behavior in docs/concepts/compaction.md.
2cf2586 to
bbbf99c
Compare
|
This pull request has been automatically marked as stale due to inactivity. |
|
Closing due to inactivity. |
Closes #138083
What Problem This Solves
Long-running assistant sessions that switch between unrelated topics carry the
finished topic's history until token pressure finally triggers compaction. The
model has no way to say "this discussion is done, archive it now," so context
budget is wasted and the eventual pressure-driven summary mixes unrelated
topics.
Why This Change Was Made
Add a
session_compactbuilt-in tool that lets the model request compactionof the current session, following the established
sessions_yieldpattern:the tool records the request, the runtime owns execution.
Key design decisions:
receiver, so unsupported contexts never see a dead tool. Heartbeat turns do
not install the receiver at all (they never execute agent compaction).
the turn's deferred lifecycle completion, which releases the embedded
active-run handle first (the manual pipeline rejects requests with
active_runwhile the handle is still registered). Scheduling the workbehind delivery keeps a non-streamed final reply from waiting on the whole
summarization request. The run itself goes through the existing manual
compaction pipeline (
trigger: "manual",force, focus passed ascustomInstructions), reusing lane queueing, checkpoints, hooks, qualityguards, and provider/model overrides unchanged.
/compact(incrementCompactionCountwith the committed successor entry asthe writer fence), so finalization never persists the pre-summarization
usage as the current context.
CORE_TOOL_DEFINITIONSunder thesessionssection with
coding/messagingprofiles and the OpenClaw group, soprofile allowlists,
group:sessions, andgroup:openclawagree withruntime eligibility.
summary lives in the session transcript as today, and full history stays on
disk.
User Impact
The agent can now proactively compact on topic shifts instead of only
reacting to context pressure. Behavior is the same contract as
/compact:recent turns are preserved, the summary is stored in the session transcript,
and the operator can always inspect the full on-disk history.
Evidence
New focused tests (
pnpm testscope):src/agents/tools/session-compact-tool.test.ts(4 tests): error pathswithout session context or runtime receiver, scheduling with and without
focus, callback payload.
src/auto-reply/reply/agent-runner-memory.agent-compaction.test.ts(7 tests): manual-pipeline invocation with focus/force, committed-entry
writer fence plus
incrementCompactionCountaccounting on success,accounting failure logged without throwing, no-op without a request,
heartbeat skip, skip outcome and failure both non-fatal.
src/auto-reply/reply/agent-runner-execution-agent-compaction.test.ts(2 tests): drives a full
executeAgentTurnwith the realdeferred-lifecycle manager and asserts the turn surfaces the recorded
request on the settled outcome without running compaction in-turn (the
finalize side owns execution, after delivery settlement).
src/auto-reply/reply/agent-runner-maintenance.agent-compaction.test.ts(3 tests): the scheduled compaction runs only after
ownerSettlementresolves, is skipped without a recorded request, and is skipped when the
reply operation aborted before settlement.
Regression:
agent-runner-execution-command-events.test.ts(4 tests),agent-tools-agent-config.test.ts(24 tests),agent-runner-memory.preflight-stale-tokens.test.ts(7 tests) all pass.tsgo --noEmit -p tsconfig.core.jsonclean on this branch (core and coretest graphs).
oxfmt --checkclean on all touched files; docs updated indocs/concepts/compaction.md(Agent-initiated compaction section).pnpm buildandpnpm checkpass locally on this branch (check includes thetool-display and assertion-safety ratchets that this change updates).
Live verification: not feasible in the author's environment — the execution
path is the embedded auto-reply owner, which needs a full channel + provider
setup (none available locally; the CLI-direct runtime intentionally does not
expose the tool). The ordering and accounting guarantees are instead proven
against the real deferred-lifecycle manager and the real settlement gate in
the regression tests above; CI owns the full-suite run. The change touches no
bundled plugin artifacts.
Follow-up noted during this work
src/system-agent/chat-turn-router.ts(untouched by this PR) has apre-existing type error:
resolveOperatorApprovalDecisioninfersTfromboth
applyanddenied, and the narrow literal returned bydeniedconflicts with the wide
SystemAgentChatReplyreturned byapply. It doesnot affect the
pnpm checklane (no full-project tsc there) and is unrelatedto this feature; flagged here as a named follow-up for the owner of that
surface.