Repository navigation
fix(cron): session-target automations fail on PostgreSQL state before they start - #187530
Conversation
… they start
Without an explicit cron.store, session-target runs (and standalone
isolated prompt preparation) resolved the cron partition with the
synchronous machine-state read on the Gateway main thread. PostgreSQL
state refuses that ("PostgreSQL connections must run in a worker"), so
the run failed before enqueueing its turn. Resolve the partition with
the existing worker-backed async resolver instead.
Closes openclaw#187334
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01StYtJ4UGDrdH1BXUySJXmR
|
🦞👀 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 SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex review: needs maintainer review before merge. What this changesUse the existing worker-backed async partition resolver when preparing automation scratch. Example: A PostgreSQL-backed Gateway runs an automation targeting session:agent:main:proof187530 without prepared scratch.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review This PR fixes a current PostgreSQL automation failure with a focused change; no actionable defects remain, and normal CI is still pending. Priority: P1 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherCron prepares job instructions and scratch before submitting a turn to the session controller; shared-state workers resolve the selected cron partition. flowchart LR
A[Scheduled automation] --> B[Prompt preparation]
B --> C[Async partition resolver]
C --> D[Shared state worker]
D --> E[Scratch snapshot]
E --> F[Session controller]
F --> G[Target conversation]
Technical reviewBest possible solution: Land the existing async-resolver substitution after the normal exact-head CI gates pass. Do we have a high-confidence way to reproduce the issue? The supplied Gateway comparison reproduces the precise pre-inference PostgreSQL failure on main, and fetched-main source retains the responsible synchronous calls; this review executed no target code. Is this the best way to solve the issue? The patch is the smallest complete repair: reuse the existing worker resolver in both affected async owners while retaining partition precedence, scratch bypasses, and current-authority checks. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against c6999b9ffb17. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
PR surfaceSource 0, Tests +34. Total +34 across 4 files. Added test files: 0. View PR surface stats
Review metrics
LabelsLabel 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 29, 2026, 6:05 AM ET / 10:05 UTC (Revision 2). |
Clean exact-head PostgreSQL Gateway proofCandidate The Gateway uses the documented mixed-engine config: Through the built CLI and real Gateway RPC:
Observed results: Main's PostgreSQL target failures are the specific pre-turn error: Both candidate target runs record their exact The selected-partition setup writes only the existing The PG server's actual application tables—not a status label—hold these rows. Controls and limits: current Gateway JSON correctly rejects the retired Root cause and fix: two async prompt owners still called the synchronous partition resolver on their caller thread. Await the existing async worker resolver instead. Partition choice, stores, schemas, migration, retry and authority contracts are unchanged; there is no new DB opener or helper. Focused verification: 30/30 tests passed in Original fix: @yousan. Report: @etzelm in #187334. No merge performed. |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
… they start (#187530) fix(cron): use the async partition resolver for session-target runs on PostgreSQL Cron runs with a session target, and standalone runs, prepared their session with the synchronous partition resolver. A Gateway that keeps shared state in PostgreSQL can't resolve partitions synchronously, so these jobs failed with a worker-thread error before inference. They now use the existing async worker resolver that already owns this path. No store or schema changes. Evidence: built Gateway with PostgreSQL 17.8 shared state and SQLite agents. On main, session-target jobs failed before inference with the worker-thread error (twice); with this change they completed with one provider request and the reply stored in the correct target session (twice), including on a custom partition, which PostgreSQL store_key receipts confirm. SQLite and no-target controls behave the same on both refs. Details: openclaw/openclaw#187530 (comment). Thanks @yousan. Co-authored-by: Claude Opus 5.5 <[email protected]> Co-authored-by: Ayaan Zaidi <[email protected]>
… they start (openclaw#187530) fix(cron): use the async partition resolver for session-target runs on PostgreSQL Cron runs with a session target, and standalone runs, prepared their session with the synchronous partition resolver. A Gateway that keeps shared state in PostgreSQL can't resolve partitions synchronously, so these jobs failed with a worker-thread error before inference. They now use the existing async worker resolver that already owns this path. No store or schema changes. Evidence: built Gateway with PostgreSQL 17.8 shared state and SQLite agents. On main, session-target jobs failed before inference with the worker-thread error (twice); with this change they completed with one provider request and the reply stored in the correct target session (twice), including on a custom partition, which PostgreSQL store_key receipts confirm. SQLite and no-target controls behave the same on both refs. Details: openclaw#187530 (comment). Thanks @yousan. Co-authored-by: Claude Opus 5.5 <[email protected]> Co-authored-by: Ayaan Zaidi <[email protected]>
Closes #187334
What Problem This Solves
Session-target automations can fail before their agent turn starts when the Gateway uses PostgreSQL shared state and has no explicit cron store path. Prompt preparation calls the synchronous partition resolver on the Gateway thread, triggering
PostgreSQL connections must run in a worker.What Changed
Await the existing async worker resolver in session-target scratch preparation and standalone automation prompt preparation. Keep the existing prepared-scratch and explicit-path fast paths. No new store, database opener, schema, migration, partition-selection rule, retry or permission change; unrelated Doctor and one-shot callers are untouched.
Original fix: @yousan. Report: @etzelm in #187334. Contributor commits are preserved.
Evidence
Clean exact-head built Gateway + real PostgreSQL proof: a separate PostgreSQL 17.8 Docker server holds actual shared-state schemas and cron receipts; agents use SQLite. Jobs are created and forced through shipped Gateway RPC, with real local provider HTTP requests and persisted target-session replies.
cron_run_receipts.store_keyconfirms the selected partition is retained.cron.storefield; validation was not bypassed.30/30 focused tests and formatting passed. Existing coverage now checks worker-owned selected-path resolution, preserved localized prompt content, prepared scratch without re-reading it, cancellation, source revocation and retained authority. Net test-count growth zero; production +4/-4 and test lines +50/-16.
Merge Danger
Two-way door: reverting restores synchronous metadata lookups. No persisted-format or schema change. Blast radius is cron prompt preparation when scratch is not already prepared; the async resolver already owns partition selection for both engines.