Skip to content

Run memory flush before preflight compaction#84792

Merged
steipete merged 6 commits into
openclaw:mainfrom
TurboTheTurtle:fix/memory-flush-before-compaction-84695
Jul 6, 2026
Merged

Run memory flush before preflight compaction#84792
steipete merged 6 commits into
openclaw:mainfrom
TurboTheTurtle:fix/memory-flush-before-compaction-84695

Conversation

@TurboTheTurtle

@TurboTheTurtle TurboTheTurtle commented May 21, 2026

Copy link
Copy Markdown
Contributor

Fixes #84695.

Summary

  • Run automatic memory flush before preflight compaction in runReplyAgent.
  • Keep visible memory-flush errors on the same pre-run return path before the main reply.
  • Add committed e2e coverage proving memory flush starts before preflight compaction.

What Problem This Solves

runReplyAgent must run the memory-flush phase before preflight compaction so durable memory has a chance to run before aggressive transcript reduction. Before this PR, preflight compaction could run first and reduce transcript context before the automatic memory flush path had a chance to preserve it.

Evidence

Real Gateway Proof

  • Runtime tested: isolated foreground Gateway, not a Vitest harness.
  • Worktree: /private/tmp/openclaw-pr84792-proof-rebase-20260630.
  • Config/home: /private/tmp/openclaw-pr84792-live-gateway/home/.openclaw/openclaw.json with loopback-only gateway auth disabled, channels skipped, and a dummy local OpenAI-compatible provider at 127.0.0.1:9.
  • Base/head: origin/main b63e06f68aa, PR head 26caf5e60ec2.
  • Gateway command:
OPENCLAW_HOME=/private/tmp/openclaw-pr84792-live-gateway/home \
OPENCLAW_CONFIG_PATH=/private/tmp/openclaw-pr84792-live-gateway/home/.openclaw/openclaw.json \
OPENCLAW_SKIP_CHANNELS=1 \
OPENCLAW_DIAGNOSTICS=timeline \
OPENCLAW_DIAGNOSTICS_TIMELINE_PATH=/private/tmp/openclaw-pr84792-live-gateway/timeline.jsonl \
OPENCLAW_DIAGNOSTICS_RUN_ID=pr84792-live-gateway \
node scripts/run-node.mjs gateway run --allow-unconfigured --auth none --bind loopback --port 48792 --verbose
  • Live Gateway call:
OPENCLAW_HOME=/private/tmp/openclaw-pr84792-live-gateway/home \
OPENCLAW_CONFIG_PATH=/private/tmp/openclaw-pr84792-live-gateway/home/.openclaw/openclaw.json \
node scripts/run-node.mjs gateway call chat.send \
  --url ws://127.0.0.1:48792 \
  --token proof-token \
  --json \
  --timeout 60000 \
  --params '{"sessionKey":"main","message":"PR 84792 live gateway proof: respond with NO_REPLY after diagnostics","idempotencyKey":"pr84792-live-gateway-proof"}'
  • ACK:
{
  "runId": "pr84792-live-gateway-proof",
  "status": "started"
}
  • Redacted Gateway diagnostics timeline from /private/tmp/openclaw-pr84792-live-gateway/timeline.jsonl:
{"type":"span.start","timestamp":"2026-07-01T07:04:45.661Z","name":"gateway.chat_send.dispatch_inbound","phase":"agent-turn","attributes":{"runId":"pr84792-live-gateway-proof","sessionKey":"agent:main:main","provider":"proof-local","model":"proof-model"}}
{"type":"span.start","timestamp":"2026-07-01T07:04:46.038Z","name":"reply.memory_flush","phase":"agent-turn","attributes":{"provider":"proof-local","hasSessionKey":true,"isHeartbeat":false,"queueMode":"steer"}}
{"type":"span.end","timestamp":"2026-07-01T07:04:46.038Z","name":"reply.memory_flush","phase":"agent-turn","durationMs":0.374}
{"type":"span.start","timestamp":"2026-07-01T07:04:46.038Z","name":"reply.preflight_compaction","phase":"agent-turn","attributes":{"provider":"proof-local","hasSessionKey":true,"isHeartbeat":false,"queueMode":"steer"}}
{"type":"span.end","timestamp":"2026-07-01T07:04:46.041Z","name":"reply.preflight_compaction","phase":"agent-turn","durationMs":2.642}
{"type":"span.start","timestamp":"2026-07-01T07:04:46.043Z","name":"reply.run_agent_turn","phase":"agent-turn"}
  • Runtime log after the ordering proof reached the model transport:
[agent/embedded] embedded run start: runId=pr84792-live-gateway-proof sessionId=<redacted> provider=proof-local model=proof-model thinking=off messageChannel=webchat
[provider-transport-fetch] [model-fetch] start provider=proof-local api=openai-completions model=proof-model method=POST url=http://127.0.0.1:9/v1/chat/completions
[provider-transport-fetch] [model-fetch] error provider=proof-local api=openai-completions model=proof-model message=fetch failed

Observed result after fix: the real Gateway chat.send path starts reply.memory_flush before reply.preflight_compaction, then enters reply.run_agent_turn and reaches the provider transport. The provider failure is expected because the isolated proof config intentionally points at an unreachable local endpoint after the pre-run ordering has been proven.

Verification

node scripts/run-vitest.mjs src/auto-reply/reply/agent-runner.runreplyagent.e2e.test.ts src/llm/providers/mistral.test.ts src/llm/providers/anthropic.test.ts src/gateway/server-cron.test.ts src/gateway/server-cron-notifications.test.ts
# passed: 3 Vitest shards, 171 tests

pnpm check:test-types
# passed

pnpm lint
# passed

node node_modules/.bin/oxfmt --check --threads=1 src/gateway/server-cron-notifications.test.ts src/gateway/server-cron.test.ts src/llm/providers/anthropic.test.ts src/llm/providers/mistral.test.ts src/auto-reply/reply/agent-runner.runreplyagent.e2e.test.ts src/auto-reply/reply/agent-runner.ts src/auto-reply/reply/agent-runner-direct-runtime-config.test.ts
All matched files use the correct format.

git diff --check
# clean

@openclaw-barnacle openclaw-barnacle Bot added size: XS triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. labels May 21, 2026
@clawsweeper

clawsweeper Bot commented May 21, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed July 6, 2026, 4:06 AM ET / 08:06 UTC.

Summary
The branch reorders runReplyAgent so memory flush runs before preflight compaction, updates direct-runtime ordering and exhausted-flush recovery tests, and corrects the memory-flush helper comment.

PR surface: Source +14, Tests +81. Total +95 across 3 files.

Reproducibility: yes. Source inspection of current main and v2026.6.11 shows preflight compaction runs before memory flush, while the docs and linked bug expect the flush before compaction; this read-only review did not run a local long-context Telegram reproduction.

Review metrics: none identified.

Root-cause cluster
Relationship: fixed_by_candidate
Canonical: #84695
Summary: This PR is the candidate fix for the open direct preflight-compaction-before-memory-flush regression; adjacent memoryFlush issues cover different failure modes or follow-up surfaces.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge readiness
Overall: 🐚 platinum hermit
Proof: 🦞 diamond lobster
Patch quality: 🐚 platinum hermit
Result: ready for maintainer review.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • none.

Risk before merge

  • [P1] Merging intentionally changes pre-run session maintenance order, so maintainers should confirm flush-before-compaction is the desired session-state invariant for existing memoryFlush configurations.
  • [P1] The PR head was recently force-pushed and some broad CI jobs were still in progress during review; final merge should gate on exact-head CI for dc6888fd6bdab353ef307524c7b2d74fa75bea5f.

Maintainer options:

  1. Land after ordering approval (recommended)
    Accept the session-state timing change and let normal exact-head CI/mergeability gates decide the final land step.
  2. Revise the recovery policy
    Require a branch update if maintainers want exhausted memory flushes to rotate, compact, or notify under different conditions after the ordering change.
  3. Defer to broader memoryFlush design
    Pause this PR if maintainers want to bundle the direct preflight-ordering fix with the adjacent in-turn catch-up or failure-escalation work.

Next step before merge

  • No automated repair is needed; the branch is focused and reviewable, and the remaining action is maintainer acceptance of the session-state ordering change plus exact-head merge gates.

Maintainer decision needed

  • Question: Should runReplyAgent make memory flush the canonical pre-compaction maintenance step for existing sessions?
  • Rationale: The patch is focused and source-supported, but it deliberately changes session-state timing for memoryFlush metadata, compaction count, and degraded recovery behavior in existing conversations.
  • Likely owner: steipete — This person has the strongest current history signal on the branch and the intersecting memory-flush exhaustion recovery path.
  • Options:
    • Accept flush-before-compaction (recommended): Merge after exact-head CI if maintainers want durable memory to checkpoint the pre-compaction transcript whenever memoryFlush is enabled.
    • Keep preflight-first ordering: Close or redirect this PR if maintainers prefer the current preflight-first order and want the linked memory gap handled through a different mechanism.
    • Narrow before landing: Ask for a revised branch if maintainers want only the recovery tests or a different exhausted-flush policy without changing the canonical order yet.

Security
Cleared: The diff changes reply runtime ordering and colocated tests only; I found no new dependency, workflow, credential, permission, package, or downloaded-code surface.

Review details

Best possible solution:

Land the narrow ordering change if maintainers accept memory flush as the canonical pre-compaction maintenance step, keeping the adjacent in-turn catch-up and other memoryFlush failure modes on their separate tracks.

Do we have a high-confidence way to reproduce the issue?

Yes. Source inspection of current main and v2026.6.11 shows preflight compaction runs before memory flush, while the docs and linked bug expect the flush before compaction; this read-only review did not run a local long-context Telegram reproduction.

Is this the best way to solve the issue?

Yes. Moving the existing memory-flush call ahead of the existing preflight-compaction call is the narrow owner-boundary fix for this direct ordering bug, and the PR keeps adjacent in-turn catch-up work separate.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against f1f8c1ed1682.

Label changes

Label justifications:

  • P1: The PR addresses a high-impact memory/compaction regression where configured durable memory preservation can be skipped before aggressive transcript reduction.
  • merge-risk: 🚨 session-state: The diff changes the order and recovery behavior of memory flush, preflight compaction, compaction count, and active session metadata.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (logs): The PR body supplies redacted live Gateway diagnostics from an isolated chat.send run showing reply.memory_flush before reply.preflight_compaction and then the normal agent turn/provider transport path.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body supplies redacted live Gateway diagnostics from an isolated chat.send run showing reply.memory_flush before reply.preflight_compaction and then the normal agent turn/provider transport path.
Evidence reviewed

PR surface:

Source +14, Tests +81. Total +95 across 3 files.

View PR surface stats
Area Files Added Removed Net
Source 2 38 24 +14
Tests 1 83 2 +81
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 121 26 +95

What I checked:

Likely related people:

  • steipete: Recent merged work on memory-flush exhaustion and the PR branch's latest commits both modify the same runReplyAgent maintenance block; CONTRIBUTING.md also lists Peter Steinberger as the project owner. (role: recent area contributor and documented maintainer area owner; confidence: high; commits: dd972b8bf775, a95c4c198596, 66d7b3d25bf4; files: src/auto-reply/reply/agent-runner.ts, src/auto-reply/reply/agent-runner-memory.ts, src/auto-reply/reply/agent-runner-direct-runtime-config.test.ts)
  • jared596: Commit history identifies jared596 as the author/co-author of the transcript-estimate preflight compaction work in the same runner/helper surface. (role: preflight compaction contributor; confidence: high; commits: c6d8318d07f5; files: src/auto-reply/reply/agent-runner.ts, src/auto-reply/reply/agent-runner-memory.ts)
  • ArthurNie: Commit history shows recent required preflight compaction failure handling and direct-runtime coverage in the same helper/test area. (role: recent preflight hard-gate contributor; confidence: medium; commits: 9d54285b0d4a; files: src/auto-reply/reply/agent-runner-memory.ts, src/auto-reply/reply/agent-runner-direct-runtime-config.test.ts)
  • Jerry-Xin: Commit history shows recent durable memory-flush failure metadata and exhaustion handling in the helper/session-state path that this PR now preserves after reordering. (role: recent memory-flush state contributor; confidence: medium; commits: 4e84d0eaa547, dd972b8bf775; files: src/auto-reply/reply/agent-runner-memory.ts, src/auto-reply/reply/agent-runner-memory.test.ts, src/config/sessions/types.ts)
  • jalehman: Commit metadata in the same preflight and memory-flush history lists jalehman as reviewer/co-author, and CONTRIBUTING.md lists Josh Lehman for compaction/context engine ownership. (role: reviewer and adjacent session contributor; confidence: medium; commits: c6d8318d07f5, ef7a5c354611, 127e174c9e4d; files: src/auto-reply/reply/agent-runner-memory.ts, src/auto-reply/reply/memory-flush.ts, src/config/sessions/session-accessor.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

How this review workflow works
  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.
Review history (1 earlier review cycle)
  • reviewed 2026-07-05T22:40:06.225Z sha 89de0e6 :: needs maintainer review before merge. :: none

@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. labels May 21, 2026
@clawsweeper

clawsweeper Bot commented May 21, 2026

Copy link
Copy Markdown
Contributor

ClawSweeper PR egg

✨ Hatched: 🌱 uncommon Moonlit Clawlet

Hatch command

Comment @clawsweeper hatch when this PR is hatchable.

Hatchability rules:

  • Merged PRs are hatchable.
  • Open PRs are hatchable when they are status: 👀 ready for maintainer look, status: 🚀 automerge armed, or labeled clawsweeper:automerge.
  • Closed unmerged PRs are hatchable only when one of those hatchable labels is still present in the durable record.

Rarity: 🌱 uncommon.
Trait: sleeps inside passing CI.
Image traits: location CI tidepool; accessory review stamp; palette amber, ink, and glacier blue; mood celebratory; pose balancing on a branch marker; shell smooth pearl shell; lighting calm overcast light; background gentle dashboard dots.
Share on X: post this hatch
Copy: My PR egg hatched a 🌱 uncommon Moonlit Clawlet in ClawSweeper.

What is this egg doing here?
  • Eggs appear after the PR passes real-behavior proof. It is here for vibes, not verdicts: it does not change labels, ratings, merge decisions, or automation.
  • The shell reacts to review momentum: open follow-up work warms it up, re-review makes it wobble, and a clean final review lets it hatch.
  • Hatchability usually comes from sufficient real-behavior proof, no blocking P0/P1/P2 findings, no security attention needed, and clean correctness. A merged PR is already final, so merge makes the egg hatchable independently.
  • The hatch is seeded from this repository and PR number, so the same PR keeps the same creature; the reviewed head SHA can only change safe visual details.
  • Rarity is just collectible sparkle: 🥚 common, 🌱 uncommon, 💎 rare, ✨ glimmer, and 🌈 legendary.

@TurboTheTurtle

Copy link
Copy Markdown
Contributor Author

Real behavior proof for #84695 / this PR:

I reran the targeted maintenance-order regression locally on the PR branch and verified the memory-flush phase runs before preflight compaction.

Command:

/opt/homebrew/opt/node@22/bin/node scripts/run-vitest.mjs src/auto-reply/reply/agent-runner-direct-runtime-config.test.ts src/auto-reply/reply/agent-runner-memory.test.ts src/auto-reply/reply/reply-state.test.ts

Observed terminal result:

RUN  v4.1.6 /Users/andy/openclaw/openclaw-84695

Test Files  3 passed (3)
Tests  66 passed (66)

Specific behavior proved by the new regression:

expect(runMemoryFlushIfNeededMock.mock.invocationCallOrder[0]).toBeLessThan(
  runPreflightCompactionIfNeededMock.mock.invocationCallOrder[0] ?? Number.POSITIVE_INFINITY,
);

That exercises runReplyAgent and proves the pre-run maintenance ordering is now:

  1. runMemoryFlushIfNeeded
  2. runPreflightCompactionIfNeeded

This is the behavior the bug needs: the flush gate sees the pre-compaction session state, instead of seeing the lower post-compaction token count after preflight compaction has already run.

Additional validation:

/opt/homebrew/opt/node@22/bin/node /Users/andy/openclaw/node_modules/.bin/tsgo -p test/tsconfig/tsconfig.test.src.json --pretty false --declaration false --singleThreaded --checkers 1
# exit 0

/opt/homebrew/opt/node@22/bin/node /Users/andy/openclaw/node_modules/.bin/oxfmt --check --threads=1 src/auto-reply/reply/agent-runner.ts src/auto-reply/reply/agent-runner-direct-runtime-config.test.ts
# All matched files use the correct format.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented May 21, 2026

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

@openclaw-barnacle openclaw-barnacle Bot added proof: supplied External PR includes structured after-fix real behavior proof. and removed triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. labels May 21, 2026
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels May 21, 2026
@TurboTheTurtle
TurboTheTurtle marked this pull request as ready for review May 21, 2026 04:42
@RomneyDa

Copy link
Copy Markdown
Member

Heads up: this PR needs to be updated against current main before the new required Dependency Guard check can pass.

@TurboTheTurtle
TurboTheTurtle force-pushed the fix/memory-flush-before-compaction-84695 branch from 023afa3 to 01e356a Compare May 29, 2026 16:21
@openclaw-barnacle openclaw-barnacle Bot removed the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 29, 2026
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels May 29, 2026
@TurboTheTurtle
TurboTheTurtle force-pushed the fix/memory-flush-before-compaction-84695 branch from 01e356a to f472d0e Compare May 29, 2026 16:37
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels May 29, 2026
@clawsweeper clawsweeper Bot added the rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. label Jul 1, 2026
@TurboTheTurtle
TurboTheTurtle force-pushed the fix/memory-flush-before-compaction-84695 branch from cb17b53 to 26caf5e Compare July 1, 2026 06:59
@openclaw-barnacle openclaw-barnacle Bot added the gateway Gateway runtime label Jul 1, 2026
@TurboTheTurtle

Copy link
Copy Markdown
Contributor Author

Rebased onto current origin/main and pushed the committed proof at head 26caf5e60ec2.

The proof is now in src/auto-reply/reply/agent-runner.runreplyagent.e2e.test.ts as starts memory flush before preflight compaction with real maintenance helpers; it runs real runReplyAgent and does not mock runMemoryFlushIfNeeded or runPreflightCompactionIfNeeded.

Local verification on this head:

node scripts/run-vitest.mjs src/auto-reply/reply/agent-runner.runreplyagent.e2e.test.ts src/llm/providers/mistral.test.ts src/llm/providers/anthropic.test.ts src/gateway/server-cron.test.ts src/gateway/server-cron-notifications.test.ts
# passed: 3 Vitest shards, 171 tests

pnpm check:test-types
# passed

pnpm lint
# passed

git diff --check
# clean

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

@TurboTheTurtle

Copy link
Copy Markdown
Contributor Author

Added the live Gateway proof ClawSweeper asked for.

Current head: 26caf5e60ec2

This is no longer only e2e/test-harness evidence. I started an isolated foreground Gateway on loopback with diagnostics enabled, sent a real chat.send through openclaw gateway call, and captured the runtime timeline.

Redacted timeline excerpt:

{"type":"span.start","timestamp":"2026-07-01T07:04:45.661Z","name":"gateway.chat_send.dispatch_inbound","phase":"agent-turn","attributes":{"runId":"pr84792-live-gateway-proof","sessionKey":"agent:main:main","provider":"proof-local","model":"proof-model"}}
{"type":"span.start","timestamp":"2026-07-01T07:04:46.038Z","name":"reply.memory_flush","phase":"agent-turn"}
{"type":"span.end","timestamp":"2026-07-01T07:04:46.038Z","name":"reply.memory_flush","phase":"agent-turn","durationMs":0.374}
{"type":"span.start","timestamp":"2026-07-01T07:04:46.038Z","name":"reply.preflight_compaction","phase":"agent-turn"}
{"type":"span.end","timestamp":"2026-07-01T07:04:46.041Z","name":"reply.preflight_compaction","phase":"agent-turn","durationMs":2.642}
{"type":"span.start","timestamp":"2026-07-01T07:04:46.043Z","name":"reply.run_agent_turn","phase":"agent-turn"}

The run then reached provider transport and failed against the intentionally unreachable local endpoint (127.0.0.1:9), after the ordering proof was already captured.

@clawsweeper re-review

@openclaw-barnacle openclaw-barnacle Bot added triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. and removed triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. labels Jul 1, 2026
@TurboTheTurtle

Copy link
Copy Markdown
Contributor Author

PR body now has a literal ## Evidence section with the live Gateway diagnostics from the isolated chat.send run. The latest Real behavior proof workflow is green on head 26caf5e60ec2.

@clawsweeper re-review

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 🔁 re-review loop A fresh ClawSweeper review was explicitly requested after the latest review. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 🔁 re-review loop A fresh ClawSweeper review was explicitly requested after the latest review. labels Jul 1, 2026
@steipete

steipete commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Land-ready after maintainer rewrite.

  • Memory flush now runs before preflight compaction and passes its returned session forward. Successful preflight recovery keeps the compacted session; exhausted context-overflow failure rotates; cancellation and unrelated preflight failures retain their existing paths.
  • Removed the original unrelated Anthropic cast and redundant diagnostics fixture; final diff is 3 files.
  • Focused proof: node scripts/run-vitest.mjs src/auto-reply/reply/agent-runner-direct-runtime-config.test.ts src/auto-reply/reply/agent-runner-memory.test.ts src/auto-reply/reply/reply-state.test.ts — 3 files, 98 tests passed on final head.
  • Local pnpm build and pnpm check passed. Blacksmith Testbox lease tbx_01kwv3r1kemf11jnashga8a53t ran all 253 Vitest shards; the touched auto-reply shard passed, while unrelated baseline fixture/tooling failures were subsequently separated and the deterministic package fixture was fixed in test(release): match pinned Claude CLI setup #100723.
  • Exact-head hosted CI passed all 44 jobs, including broad compact shards and QA smoke: https://github.com/openclaw/openclaw/actions/runs/28776569239
  • Fresh local-delta and full-branch autoreviews are clean; wrapper review artifacts validate with zero findings and prepare-run completed for dc6888fd6bdab353ef307524c7b2d74fa75bea5f.

Codex contract check: native pre-turn and mid-turn compaction remain owned by codex-rs/core/src/session/turn.rs:796-819 and codex-rs/core/src/session/turn.rs:345-357, using codex-rs/core/src/session/context_window.rs:24-90; manual app-server compaction remains in codex-rs/app-server/src/request_processors/thread_processor.rs:1771-1782. OpenClaw continues to skip this preflight helper for Codex sessions.

Known proof gap: no live long-context provider conversation was forced; source-level ordering, 98 focused tests, the full remote suite, and exact-head hosted CI cover the changed decision surface. Thanks @TurboTheTurtle.

@steipete

steipete commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Merged via squash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. proof: supplied External PR includes structured after-fix real behavior proof. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Compaction does not write summary to daily memory — regression of #79022

3 participants