Skip to content

fix(agents): retry ready context-engine turns behind old admissions - #190165

Merged
roboclaw-bot merged 1 commit into
mainfrom
loop/contributor-pr-172102
Nov 1, 2026
Merged

roboclaw-bot merged 1 commit into
mainfrom
loop/contributor-pr-172102

Conversation

@roboclaw-bot

@roboclaw-bot roboclaw-bot commented Nov 1, 2026 •

Copy link
Copy Markdown
Collaborator

Supersedes #172102, thanks @Leon-SK668.

Related: #135628

What Problem This Solves

Fixes ready context-engine turns remaining queued when 16 older unresolved admissions from other sessions fill the bounded retry list.

User Impact

A successful independent turn can retry the ready backlog through the existing finalizer wake path. Same-session FIFO and engine/plugin isolation remain intact. Historical admissions are retained; retiring them remains separate work.

Why This Change Was Made

Select each session's oldest non-blocked row before filtering for readiness and applying the retry limit, in both the database worker and memory actor. No new timer, queue, configuration, schema, or dependency is needed. Work still relies on existing turn/recovery wake paths.

The two single-use worker selection helpers are folded into the existing command dispatcher, and the SQL-filtered, unreachable blocked-row branch is removed. Production delta: +38/-39, net -1. Regression tests add 30 lines; their dedicated test-line allocation covers starvation and non-ready FIFO heads.

Evidence

  • RED on current-main base 3e253689582b00fa7b2e7b0f7f11a3ffd3add1f5: the real finalizer commits only the current session, skipping the ready backlog behind 16 admissions. The worker negative control reads two non-ready heads; the memory selector also exposes non-ready work.
  • GREEN: 54 tests passed in 75.85 s across two focused shards (40.82 s memory, 32.10 s agents; cold compilation dominates memory startup), including unchanged-row and no-dispatch assertions for non-ready heads. Exact command: pnpm test src/agents/harness/context-engine-turn-attempt.test.ts src/agents/harness/context-engine-turn-outbox.test.ts src/config/sessions/session-actor-memory-side-effects.test.ts --maxWorkers=1.
  • Targeted TypeScript, declaration preparation, typed lint, formatting and whitespace checks passed. The whole-repository test-line counter exceeded its 60 s local timeout; the exact-head CI baseline-ratchet step subsequently passed in 259 s.
  • Exact-head CI passed, including PostgreSQL conformance (all three shards), changed-boundary tests (50 s test step), production/test type checks, lint, build, and baseline ratchets. openclaw/ci-gate is successful.
  • Autoreview (Codex, P0–P2) reviewed the final local snapshot against the base above: scoped-clean, no actionable findings.
  • Contributor source was read through GitHub only and was never checked out or executed. This replacement was independently implemented on main. No live Gateway/model run or production-state change is claimed.

Select ready session heads before applying the existing bounded retry limit.
Preserve same-session FIFO and mirror selection in the memory actor.

Co-authored-by: Leon-SK668 <[email protected]>
@clawsweeper

clawsweeper Bot commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@roboclaw-bot
roboclaw-bot marked this pull request as ready for review November 1, 2026 09:03
@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: S labels Nov 1, 2026
steipete added a commit that referenced this pull request Nov 1, 2026
Remove dead exports left by #190019, #189350, and #190165. Preserve existing auth and repository restoration coverage through the production entry points. Production LOC is unchanged; no runtime behavior or Knip exemptions change.
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 1, 2026
@clawsweeper

clawsweeper Bot commented Nov 1, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

Select ready session heads before applying the context-engine retry limit, preserving FIFO ordering within each session.

Example: Sixteen orphaned-admission sessions precede retry-ready when accepted-turn finishes.

  • Before: The finalizer commits accepted-turn, but unresolved sessions fill the retry list and retry-ready remains queued.
  • After: The finalizer commits accepted-turn and retries retry-ready while retaining the historical admissions.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) A focused, useful repair with meaningful regression coverage and no identified defect; supplied execution evidence for this head remains harness-based.
Proof confidence 🦐 gold shrimp (3/6) This maintainer-authored bot PR is outside the ordinary contributor proof gate; its supplied evidence exercises the real finalizer and worker/memory selectors in tests with mocked engine callbacks, while the linked CLI execution covers an earlier contributor head.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Partial
User problem: Completed turns from idle sessions can remain queued indefinitely because unresolved sessions occupy every bounded retry slot.
Reason: The maintainer-authored direction repairs a demonstrated failure with existing owners; it appropriately uses Related because historical admission retirement remains outside this patch.

Merge readiness

✅ Ready for maintainer review

Keep open: this maintainer-authored PR addresses a confirmed backlog-starvation bug still present on main, and the reviewed diff introduces no definite correctness or security defect.

Priority: P1
Reviewed head: 57c73e5a297403a9a34cf98f634f2a0eb847f9af

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: The supplied replacement-head evidence does not exercise the isolated CLI failed-once commit and independent-turn recovery scenario recorded on the superseded PR.
Agent review details

How this fits together

Accepted transcript turns enter the context-engine outbox; database workers or memory actors select eligible sessions, and the existing drainer invokes the engine's idempotent commit and acknowledges successful rows.

flowchart TD
  A[Accepted transcript turn] --> B[Outbox store]
  B --> C[Database worker]
  B --> D[Memory actor]
  C --> E[Ready FIFO session heads]
  D --> E
  E --> F[Bounded retry drain]
  F --> G[Engine commit and acknowledgment]
Loading

Technical review

Best possible solution:

Land the focused eligibility repair through the existing outbox owners while keeping historical admission retirement in the broader issue.

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

Source establishes the 16-session starvation path, production reports corroborate it, and the PR reports a failing-base/passing-head finalizer regression; this read-only review executed no target code.

Is this the best way to solve the issue?

The smallest complete repair selects eligible FIFO heads at the existing database and memory owners, preserving retry accounting, acknowledgment, owner isolation, and historical rows without adding recovery machinery.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 3db01a06ea00.

Provenance checked

  • Worker selection and dispatch changes intended behavior with a stated reason (e63b5a0: Move outbox SQL into the existing execution worker and remove synchronous fallback ownership.)
  • Explicit FIFO sequence keeps the original intent (35dbd07: Preserve surviving queue order through rebuilds and retries using an explicit enqueue sequence.)
  • Memory actor selection keeps the original intent (b8441e0: Restore the intentionally retained standalone memory foundation without activating it or changing its ownership boundary.)
  • Accepted-session regression keeps the original intent (5360b70: Commit the accepted session first while retaining bounded retry opportunities for other sessions.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Eric Cai: Raw commit 5360b70 adds src/agents/harness/context-engine-turn-attempt.test.ts:157 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 5360b70fe44c; files: src/agents/harness/context-engine-turn-attempt.test.ts)

PR surface

Source -1, Tests +30, Other +2. Total +31 across 6 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 2 38 39 -1
Tests 3 39 9 +30
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 2 0 +2
Total 6 79 48 +31

Root-cause cluster

Relationship: partial_overlap
Canonical: #135628
Summary: This PR repairs retry selection within the broader orphan-admission report and explicitly replaces the contributor's earlier implementation.

Members:

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

Labels

Label changes:

  • add P1: Reported production backlogs prevent durable context-engine commits for idle sessions, and main retains the responsible selection behavior.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • P1: Reported production backlogs prevent durable context-engine commits for idle sessions, and main retains the responsible selection behavior.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rating scale

6/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.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed November 1, 2026, 3:17 AM ET / 08:17 UTC.

@roboclaw-bot
roboclaw-bot merged commit b68d571 into main Nov 1, 2026
207 checks passed
@roboclaw-bot
roboclaw-bot deleted the loop/contributor-pr-172102 branch November 1, 2026 09:30
@roboclaw-bot

Copy link
Copy Markdown
Collaborator Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 2, 2026
…penclaw#190165)

Select ready session heads before applying the existing bounded retry limit.
Preserve same-session FIFO and mirror selection in the memory actor.

Co-authored-by: Leon-SK668 <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 2, 2026
Remove dead exports left by openclaw#190019, openclaw#189350, and openclaw#190165. Preserve existing auth and repository restoration coverage through the production entry points. Production LOC is unchanged; no runtime behavior or Knip exemptions change.
RomneyDa added a commit that referenced this pull request Nov 17, 2026
…190165)

Select ready session heads before applying the existing bounded retry limit.
Preserve same-session FIFO and mirror selection in the memory actor.
Keep the now owner-local pending-turn type private.

(cherry picked from commit b68d571)
Owner-local type cleanup from 726a4da.

Co-authored-by: Leon-SK668 <[email protected]>
Co-authored-by: RomneyDa <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant