Repository navigation
fix(agents): retry ready context-engine turns behind old admissions - #172102
Leon-SK668 wants to merge 2 commits into
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. What this changesThis PR selects only sessions whose oldest non-blocked context-engine turn is ready for bounded retry. Example: A ready turn from an idle session sits behind 16 other sessions with unresolved admissions.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Partial Merge readiness✅ Ready for maintainer review Keep this PR: current main still permits retry starvation, and this focused repair preserves session ordering and owner isolation without introducing a new queue or cleanup policy. Priority: P1 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherAccepted agent turns enter the context-engine outbox through the existing worker or memory actor; finalization selects pending sessions, invokes the engine's idempotent commit, and acknowledges successful rows. flowchart TD
A[Accepted agent turn] --> B[Outbox store]
B --> C[Database worker]
B --> D[Memory actor]
C --> E[Ready session heads]
D --> E
E --> F[Bounded drain]
F --> G[Engine commit and acknowledgment]
Technical reviewBest possible solution: Land the focused session-head selection repair while retaining the broader issue for historical admission recovery. Do we have a high-confidence way to reproduce the issue? Current-main source establishes the 16-slot starvation path, corroborated by production reports and the contributor's historical native CLI RED; this read-only review ran no target code. Is this the best way to solve the issue? The patch fixes eligibility at the existing selection owners, preserving same-session FIFO, blocked audit records, owner filters, retry accounting, and acknowledgment without speculative cleanup machinery. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 4f8cf06b1892. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +16, Tests +74. Total +90 across 5 files. Added test files: 1. View PR surface stats
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. 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 (1 earlier review cycle)
Reviewed October 22, 2026, 8:37 PM ET / October 23, 2026, 00:37 UTC (Revision 2). |
|
@clawsweeper re-review Please review current head The upstream conflict repair and current-head proof are published in the PR body. The native CLI / registered context-engine / loopback-provider scenario retries a real failed-once engine commit, independently verifies its acknowledgment and ledger contents, and preserves all 16 historical admission payload hashes. The exact committed build and focused validation commands/results are included. This remains a bounded retry-starvation repair related to the broader issue, not a claim that all historical recovery is solved. |
|
🦞👀 Re-review progress:
|
|
Thanks @Leon-SK668 for this fix! The credited replacement #190165 is now merged as b68d571, with fresh red/green regressions and green CI. It preserves ready-head selection and same-session FIFO; broader historical admission cleanup remains in #135628. |
Refs #135628 — repairs cross-session retry starvation; historical admission retirement remains outside this PR.
What Problem This Solves
Sixteen older unresolved session heads consume the bounded context-engine retry list. A later
readyturn is not selected even when an independent session finishes successfully. Protecting the current accepted turn and disposing new admissions does not make the existing retry slots available to other ready sessions.User Impact
Ready context-engine commits can progress despite unresolved admissions in other sessions. Same-session FIFO, blocked audit evidence, engine/plugin isolation, idempotent commit, and current admissions remain intact. No historical cleanup, TTL, new queue, config/default, schema, protocol, dependency, provider-authentication, or permission change. This is a bounded part of #135628, not a claim to resolve its broader recovery request.
Why This Change Was Made
Identify each session's oldest non-blocked row before filtering for readiness and limiting the retry list. Keep ownership filters on both queries and apply the same invariant to the memory-store sibling. An unresolved head still blocks later work in its own session, without consuming another session's retry slot.
The canonical owners are the existing outbox kernel and memory session store; the finalizer/drainer continues to own commit, retry accounting and acknowledgment. Existing-solutions preflight: this is a missing invariant in the current queue owner; neither an external queue nor a new plugin/library is needed. Installed Kysely aggregate/subquery types and source, database schema and executor, callers and memory sibling were inspected.
October 18 maintenance normally merges
9b707074b5f231f6976456ea7431567893fe7d1c. The query now uses main's canonical explicitenqueue_sequenceand typedfn.min; it does not restore deleted rowid helpers or alter schema. The accepted-turn regression uses main's consolidated fixture and places 16 unresolved rows ahead of the ready retry. The other stale type-check failure was in unrelatedmemory-coreWorker/MessagePort test code; no contributor workaround was added there.Evidence
Current contributor head
1c4293e5c87f389f7e1e634859c414465da67968, tree0d1f835de572ef70426d49346ea3228277c57085; clean checkout. Built OpenClaw 2026.10.4, Linux, Node 24.16.0. Build metadata records this exact head and2026-10-18T03:08:46.938Z.The original acceptance RED was captured before production edits on
d4256984ac0435d8f5225e0d1706235b798f1e9e: an independent successful CLI turn left the ready backlog behind 16 unresolved admissions. The October 18 exact-head GREEN replays the same immutable native harness after integrating main:Three real
openclaw.mjs agent --local --agent main --session-key ... --message ... --thinking off --timeout 60 --jsonprocesses use isolated state, a normally registered context-engine fixture and a loopback HTTP/SSE model endpoint. Every invocation returns the expected current answer and exits 0.The recovered ledger contains the exact closed-turn user/assistant payload. 1/1 ready backlogs drain, compared with 0/1 on historical RED. 16/16 historical admission hashes remain identical. Fixture initialization represents reported persisted state; it does not claim to recreate the original crash. No external model account, channel recipient, production state or Mac environment is used.
GREEN completed
2026-10-18T03:16:14.687Z; three CLI invocations took 30.60 / 31.45 / 29.58 seconds. Harness SHA-256c217e70233acdfc99d10341774048fc4c549f91ac5b5e62459673376dc261a3b; current receipt SHA-256d5f2e9e303906f3fe41cbd2635a7a9f1e108542959c3c6f872b836f68cd04ac0. Local logs/databases/receipts retained; the table supplies sanitized observations, without claiming a hosted artifact.Vitest file durations: selection 137.33 s, memory 128.26 s, accepted-turn 157.18 s. Cold compiler/import preparation dominated this invocation; overlapping local type probes caused memory pressure and were stopped and resumed with bounded concurrency. No assertion, production timeout, test limit, or guard was weakened. Checks cover readiness selection, FIFO/owner separation, memory sibling and the actual finalizer.
Against merged main: 5 files; production +25/-9, net +16; tests +83/-9, net +74. No contributor generated/lock/release-changelog changes. Added production lines implement the shared session-head invariant. No speculative index/schema expansion.
Not tested: original crash generation, historical cleanup, sustained load, PostgreSQL, external providers/channels, Windows/macOS, browser, all suites, or packaged declaration bootstrap. Earlier synthetic rowid-based query timing is not represented as a fresh benchmark of this integrated head. Broad exact-head PR CI remains separate. The user waived independent automated autoreview; no automated review pass is claimed.
AI assistance: implemented and maintained for Leon-SK668 after source/owner/sibling/dependency inspection, native RED and same-scenario GREEN, focused checks and committed-head readback. Credentials, private configuration, unrelated sessions and raw agent logs are omitted.