Repository navigation
refactor(automations): run scheduled conversation work through session admission - #178764
Conversation
…ssion admission Slice 2 of #167796. Route explicit session agent turns through the ordinary session controller while preserving scheduled source authority, inference binding, delivery and managed-worktree custody. Retain legacy heartbeats and detached execution until their migration slices. Add Peter-approved Claw review everyMs and owner variants without changing existing declaration variants.
|
🦞👀 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. |
There was a problem hiding this comment.
💡 Codex Review
openclaw/src/auto-reply/reply/session-event-handoff.ts
Lines 547 to 548 in 1783087
When the agent returns a normal terminal failure result, such as exhausted provider fallbacks, onFailed is not invoked and this assignment becomes the run's top-level error even though deliveryEvidence.meta.error.message contains the actual cause. runCronSessionTurn() consequently records and sends failure alerts containing only Session event execution failed, leaving operators without the actionable provider/model error; project the terminal error into failure while retaining diagnostics.
AGENTS.md reference: AGENTS.md:L75-L75
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Reject explicit scheduled models after policy revocation before automatic selection can substitute another model. Preserve terminal agent errors in settlement receipts and keep shared result and delivery contracts independent of runtime imports. Real deferred-admission and terminal-failure regressions pass with the focused consumer and restart checks.
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: fa55804a57
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
Codex review: needs changes before merge. What this changesRoutes explicitly conversation-targeted scheduled turns through ordinary session admission, execution, delivery, and settlement. Example: A scheduled report targets session:agent:main:project:inbox while another turn is active.
Review scores
ProductKind: Refactor · Worth it: Yes · Fix scope: Complete Regression provenancePossible regression — suspected (reviewed change). No predecessor PR is attributed. Merge readiness⛔ Needs changes before merge - 2 items remain Keep this maintainer-authored PR open: the session-admission cutover is useful, but the previously reported scheduled-send finality regression remains unfixed. Priority: P2 Before merge
Findings
Provenance
Tests
Agent review detailsHow this fits togetherCron supplies scheduled work and captured authority to the session controller; ordinary reply execution produces tool effects, delivery evidence, and a terminal result for Cron history. flowchart LR
A[Cron occurrence] --> B[Session event admission]
B --> C[Conversation controller]
C --> D[Reply execution]
D --> E[Embedded or CLI runtime]
E --> F[Tools and delivery]
F --> G[Terminal settlement]
G --> A
Technical reviewBest possible solution: Forward Cron’s existing message-tool finality default through the shared candidate builder and preserve send-then-continue behavior through ordinary session execution. Do we have a high-confidence way to reproduce the issue? Source establishes the failing path: scheduled candidates omit the finality override, the resolver defaults omitted final to true, and a confirmed same-target send terminates embedded execution; no target code was run during this review. Is this the best way to solve the issue? Reusing ordinary session admission is the right ownership direction, and the smallest remaining repair is one shared parameter projection rather than another execution or delivery owner. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 1bc029e59c6c. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceAcceptance criteria:
What I checked:
Likely related people:
PR surfaceSource +1433, Tests +2099, Docs +4. Total +3536 across 80 files. Added test files: 4. 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 (9 earlier review cycles; latest 8 shown)
Reviewed October 20, 2026, 9:50 PM ET / October 21, 2026, 01:50 UTC (Revision 10). |
Reject malformed explicit models and contradictory agent/session targets while preserving legacy main-session aliases. Route authenticated continuation proof through ordinary session admission and retain its recovery, revocation, and no-duplicate contracts.
Resolve scheduled model and fallback policy through the existing Cron owner at ordinary session admission. Preserve queued configuration changes, Gmail thinking, model locks, and durable conversation preferences. Keep model preparation separate from settlement callbacks and consolidate existing stored-pin selection.
|
Updated to 3d47d9a. The three review findings are fixed with boundary regressions: revoked or malformed explicit models fail visibly, and contradictory agent/session targets are refused while legacy main-session aliases retain their behavior. The repair also preserves scheduled model/fallback precedence and separates turn-local account selection from saved conversation pins. Independently recorded job accounts retain their existing authorization checks and work when an unrelated destination account is unavailable. Focused tests and affected static checks pass; committed-branch review is scoped-clean. The PR body records the proof, costs, and limits. Exact-head CI is running in 39508097052. @clawsweeper re-review |
|
🦞👀 Re-review progress:
|
…essionEvent The scheduled follow-up authority backport (eb843f7) added fixtures that only wire runIsolatedAgentJob. The harness backport (c9e4bb5, #180270, from main 3d2f7ca / #178764) landed on the parallel line and routes `session:` agent turns through runSessionEvent; merge 4a81b7f combined them without updating these fixtures, so every explicit-session job failed with "Session event execution is unavailable" or hung waiting for a payload that never ran. Port main's fixture shape: wire runSessionEvent through runCronSessionTurn, mock only embedded model execution, report execution start from the fake runner, retire the completed recovery predecessor before admission, and expect mid-run operator revocation to fail the session turn (main's contract). One-shot ownership uses a runSessionEvent mock as on main.
…n session is used from a DM (#180603) fix(cron): bind scheduled message capabilities under the keys the run's tools use Since scheduled conversation work moved through session admission (#178764), a cron or heartbeat run on the main session minted its message-action capability under the plain session key, while the run's own tools looked it up under the peer-scoped runtime policy key when the main session was used from a DM. The lookup missed, so every message send failed with "message action turn capability is no longer active", or the run failed earlier with "plugin delivery capability is no longer active". The scheduled grant is now redeemable under the turn's runtime policy key and records the execution session key as sourceReplySessionKey, as ordinary replies already do (#149131). It is still one capability for the same run with the same lifetime and revocation; nothing is granted, widened or skipped. No text changes. Evidence: a built Gateway with the real bundled Codex app-server against a local model endpoint that calls message, the real WhatsApp channel with only the Baileys socket stood in, and a Telegram stand-in, two runs each. With the main session used from a WhatsApp DM, a heartbeat on agent:main:main failed the send on main and delivers with this change; from a Telegram DM it failed before the model call on main and delivers with this change. Ordinary DM turns, an isolated job and an announce job with --to deliver on both, a heartbeat whose job is removed mid-decision sends nothing, and a grant minted for one peer is refused for another peer on both. Net 0 test lines; the structured-result test fails on main. Details: #180603 (comment). Closes #180602. Closes #197181. Thanks @masatohoshino for the fix and @Suiah98 for the report. Co-authored-by: Ayaan Zaidi <[email protected]>
…n session is used from a DM (openclaw#180603) fix(cron): bind scheduled message capabilities under the keys the run's tools use Since scheduled conversation work moved through session admission (openclaw#178764), a cron or heartbeat run on the main session minted its message-action capability under the plain session key, while the run's own tools looked it up under the peer-scoped runtime policy key when the main session was used from a DM. The lookup missed, so every message send failed with "message action turn capability is no longer active", or the run failed earlier with "plugin delivery capability is no longer active". The scheduled grant is now redeemable under the turn's runtime policy key and records the execution session key as sourceReplySessionKey, as ordinary replies already do (openclaw#149131). It is still one capability for the same run with the same lifetime and revocation; nothing is granted, widened or skipped. No text changes. Evidence: a built Gateway with the real bundled Codex app-server against a local model endpoint that calls message, the real WhatsApp channel with only the Baileys socket stood in, and a Telegram stand-in, two runs each. With the main session used from a WhatsApp DM, a heartbeat on agent:main:main failed the send on main and delivers with this change; from a Telegram DM it failed before the model call on main and delivers with this change. Ordinary DM turns, an isolated job and an announce job with --to deliver on both, a heartbeat whose job is removed mid-decision sends nothing, and a grant minted for one peer is refused for another peer on both. Net 0 test lines; the structured-result test fails on main. Details: openclaw#180603 (comment). Closes openclaw#180602. Closes openclaw#197181. Thanks @masatohoshino for the fix and @Suiah98 for the report. Co-authored-by: Ayaan Zaidi <[email protected]>
…n session is used from a DM (#180603) fix(cron): bind scheduled message capabilities under the keys the run's tools use Since scheduled conversation work moved through session admission (#178764), a cron or heartbeat run on the main session minted its message-action capability under the plain session key, while the run's own tools looked it up under the peer-scoped runtime policy key when the main session was used from a DM. The lookup missed, so every message send failed with "message action turn capability is no longer active", or the run failed earlier with "plugin delivery capability is no longer active". The scheduled grant is now redeemable under the turn's runtime policy key and records the execution session key as sourceReplySessionKey, as ordinary replies already do (#149131). It is still one capability for the same run with the same lifetime and revocation; nothing is granted, widened or skipped. No text changes. Evidence: a built Gateway with the real bundled Codex app-server against a local model endpoint that calls message, the real WhatsApp channel with only the Baileys socket stood in, and a Telegram stand-in, two runs each. With the main session used from a WhatsApp DM, a heartbeat on agent:main:main failed the send on main and delivers with this change; from a Telegram DM it failed before the model call on main and delivers with this change. Ordinary DM turns, an isolated job and an announce job with --to deliver on both, a heartbeat whose job is removed mid-decision sends nothing, and a grant minted for one peer is refused for another peer on both. Net 0 test lines; the structured-result test fails on main. Details: #180603 (comment). Closes #180602. Closes #197181. Thanks @masatohoshino for the fix and @Suiah98 for the report. Co-authored-by: Ayaan Zaidi <[email protected]> (cherry picked from commit 4f96534) Co-authored-by: RomneyDa <[email protected]>
Related: #167796. Slice 2 of 4, following landed #178650. Doctor migration is slice 3; heartbeat execution and SDK retirement are slice 4.
What Problem This Solves
An existing
session:<key>scheduled agent turn needs to join its conversation's ordinary admission and mailbox and remain running until that turn settles. Running it through the detached executor gives execution, authority, workspace and delivery decisions a second owner.User Impact
Explicit conversation jobs now use the session controller and retain their authenticated source, model/account policy, managed workspace, delivery policy and recorded result. Cron records completion only after the controller settles. Main-session system events retain #178650's adoption and restart behavior. Legacy heartbeats and detached jobs remain working; this slice performs no migration.
Claw Add review accepts positive-integer
everyMsschedules andownerdelivery, as Peter approved on October 18. Existing cron/timezone and none/last-channel variants remain unchanged. Runtime owner delivery and portable Claw Add conversion follow in slice 3.Why This Change Was Made
Both execution paths share Cron's authority, inference, telemetry, workspace and prompt owners. Deferred admission revalidates policy; disallowed or malformed models and contradictory targets fail visibly. Scheduled model/account choices stay turn-local and do not replace the conversation's saved preferences. A recorded job account retains independent authorization, including replacement and revocation checks.
The shared prompt builder preserves job identity, local/UTC time, legacy Gmail/custom-hook untrusted wrapping, the existing unsafe-content opt-in and unattended guidance. Source leases and managed-worktree custody remain live through settlement and terminal writes. No authority is widened.
Evidence
hooks.gmail.allowUnsafeExternalContentcould leave the old unwrapped prompt after config re-admission. Cron now retains the raw occurrence and rebuilds the prompt with each admitted config, keeping its original firing timestamp. The real Cron/queue regression fails before the fix; all 57 affected queue, source-custody, prompt and restart cases pass (108 seconds wrapper; the new case takes 3.2 seconds).f70a4ba83c2bafter GitHub reported a conflict. The sole overlap was the failure-alert fixture: it now uses main’s shared setup while retaining both execution adapters. All six failure-alert/restart cases and four Claw schema cases pass; core/Cron/infra types, typed lint, format, exact staged line-growth and zero-cycle Madge pass. No production file overlapped./compactand/newguidance. The affected selection passes all 33 cases across the initial run and focused replay; 22 handoff and three restart cases also pass. Core/infra types, typed lint, format and line-growth pass; local and committed delta reviews are scoped-clean through P2. No authority, status or delivery policy changed.durationMsfield in the new synthetic context-overflow fixture. The owning messaging type graph reproduces the error before the one-line fixture correction and passes after it. The selected context-overflow case still passes in 3.1 seconds (14.8 seconds wrapper); typed lint, format and local/committed delta reviews pass. No production behavior or assertion changed.delivery:nonecontrols pass afterward. All 39 affected cases, including restart, pass in 76.7 seconds; core/messaging type graphs, typed lint, format and line-growth pass. The change adds three net production lines and preserves the original occurrence authority.The prior-head Android Play CI run (39518190275, job 118956103466) timed out in
ChatComposerLayoutTest.modelSelectionPinsNamedDefaultAndKeepsAdmittedEffectOwnedat its unchanged 1-second catalog wait. A secretless Linux replay with matching Java/Gradle pins and two test forks passed the exact case 3/3 on clean CI maind6e3a30c0bfceand 3/3 on the tested merge439a6ede1c35. The Android source and relevant toolchain inputs match. This is non-reproduction evidence, not an inherited-failure or repair claim; the isolated replay does not reproduce preceding suite order/load. Android Play subsequently passed in exact-head run 39520774003 on9b4a2cabd181.CI run 39523844566, job 118974256949 fails
server.sessions.create-notices.test.ts:144: its trusted spawn fixture expects a human profile while the existing delegated-creator projection returns an agent. The original 28-file shard selection with CI's checksum-pinned Bun reproduces the identical assertion on clean current main1989e3dc4360on macOS; the complete selection has 1 failure/222 passes in 190.6 seconds (the first batch matches CI at 1 failure/135 passes). The test, creation handler, inheritance, provenance and row-projection inputs are unchanged by this PR. The run completed with 101 successful jobs, 20 skipped jobs, this inherited failure and its aggregate gate. The next completed run 39526422189 on66a8829ab738had 100 successful jobs, 20 skipped jobs, the same inherited creator failure, the now-repaired fixture type failure, and the aggregate gate. Final-head CI 39528902818, attempt 1 on78c8fa1884a7b, completed with 103 successful jobs, 20 skipped jobs, the same inherited creator assertion (job 118990488145), an inherited formatting failure, and the aggregate gate. All build, type, lint, UI, Android and PostgreSQL jobs passed. The initial runner queue drained without cancellation or retry.The formatting failure is confined to unchanged
ui/src/pages/chat/chat-state-resource-layout.test.tsin check-docs job 118990487035. The same formatter command on that file fails identically on clean actual CI main15905ee254d0, with oxfmt/Bun agreement. The file, formatter owners, pins, configuration and dependency inputs are unchanged in the tested merge. The creator test and its four runtime inputs also match the retained clean-main proof and are unchanged in tested mergef12ef35f0dae(parents main15905ee254d0and this PR head). These two unrelated failures qualify for the authorized pre-existing-failure landing exception; failed CI is not presented as green.The original system-event restart regression has a separate failing-on-main control in #178650: unadopted work becomes one interrupted error after restart, without replay or duplication.
Two repository-wide static inventories fail identically on clean base
c4c695af703bf82e7ae72005639e7f18f9e760f0: max-lines suppression entries in three untouched UI files, and test-root counts (agents-tools 721, gateway-root 724, infra 724, plugins-platform 727 against 720). Affected compiler graphs pass. No thresholds, assertions or skips were changed. The build reports the existing advisory UI startup size of 318.6 KiB against 317.5 KiB; exact-head CI supplies the enforced broad result.Production +2,400/−967 (net +1,433); tests/support +2,232/−133 (net +2,099); docs +5/−1. The incremental growth retains the shipped heartbeat and detached execution contracts until their migration and deletion slices. The prompt repair itself removes eight production lines by sharing the existing builder.
Representative proof commands:
Limits: synthetic-model proof covers runtime authority and settlement, not external-provider transport. No live Team or Gateway state changed. Main-target agent turns, migration, runtime owner delivery and portable Claw Add remain slice 3; heartbeat/SDK removal remains slice 4. Exact-head PR CI supplies broad proof.