Repository navigation
fix(cron): scheduled automations run on whatever runtime their session copies instead of the one they were bound for - #185070
Conversation
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
|
Codex review: needs maintainer review before merge. What this changesThis PR records an automation’s execution runtime alongside its account and preserves that runtime during runs and account edits. Example: An automation records runtime openclaw, but its session later carries agentRuntimeOverride: claude-cli.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review This PR fixes runtime drift that remains on main. The earlier findings are resolved, and no new actionable defect was found. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherGateway job creation captures inference ownership; scheduled execution combines the stored binding with current account authorization to select and launch an embedded or CLI runtime. flowchart LR
A[Gateway job creation] --> B[Model and runtime selection]
B --> C[Stored inference binding]
C --> D[Scheduled candidate preparation]
D --> E[Live account authorization]
E --> F[Embedded or CLI execution]
Technical reviewBest possible solution: Preserve the captured runtime through the existing selection and authorization owners while retaining legacy binding behavior. Do we have a high-confidence way to reproduce the issue? Current-main source derives execution from copied session runtime fields, establishing the reported drift path; this read-only review did not execute target code. Is this the best way to solve the issue? The change addresses the producer and both execution consumers through shared selection owners, preserves account identity, and avoids migrating legacy jobs. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 16baf7b73960. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +494, Tests +435, Other +99. Total +1028 across 27 files. Added test files: 1. 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 (4 earlier review cycles)
Reviewed October 26, 2026, 9:08 PM ET / October 27, 2026, 01:08 UTC (Revision 5). |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
@clawsweeper re-review |
…n copies instead of the one they were bound for (openclaw#185070) * fix(cron): capture the inference runtime with the account and run scheduled jobs on it * test(cron): expect the captured runtime in bindings and account errors * test(cron): pin the inference runtime replay shapes once * fix(cron): keep the bound account and record only its runtime * fix(cron): keep the captured runtime on session-job candidates and account edits * fix(cron): type the runtime-entry loader * fix(cron): reject account edits that would drop an unavailable recorded runtime * fix(cron): select replay models through the scheduled-model owner
The openclaw#173411 carry added three lines to src/agents/cli-runner/prepare.ts, which was already over the 700-line cap. The line-cap ratchet against v2026.10.10-beta.4 then counted 1728 -> 1731 lines and refused the growth. The three refusal sites openclaw#173411 touched now throw createUnrecordedScheduledAccountRefusal() from a sibling module, src/agents/scheduled-unrecorded-account.ts. Upstream main later extracted the same module under the same name in openclaw#185070. This copy keeps beta.4's message text. Behaviour is unchanged: the same Error message, and recordModelFallbackStop still runs before the throw.
承認済みの cron.sessionGroup を復元する。設定すると、グループ未設定の 専用実行セッション (agent:<id>:cron:<job>) が実行時にそのサイドバー グループへ入る。手動で付けたグループは新しい isolated 実行でも残す。 current-bound の実行セッションは独自に分類し、元の会話や配送先、 main/custom の会話ターゲットは動かさない。設定を外しても既存の割り当ては 消さない。グループの catalog 登録は、割り当てを保存した後にだけ行い、 失敗しても自動化は止めずに次の書き込みで再試行する。 退避ブランチ backup/personal-wip-20261029 (f82c572cdc4) の未コミット作業を 新しいベースへ載せ直した。コンフリクト解決: - docs/automation/cron-jobs/managing-jobs.md: 上流 0738f13 (openclaw#177855) が 「Disable automations」の段落を host 実行制限の説明に書き換えた。上流の 段落を残し、その前に cron.sessionGroup の説明を置いた - cron/isolated-agent/session.ts: 上流 f31b33f (openclaw#185070) が session-carried-model の import を追加。両方の import を残した - cron/isolated-agent/session.test.ts: 上流 3655433 (openclaw#183506) が未使用の delivery fixture を削除。sessionGroup のテストだけを残し、fixture は戻さない - session.test.ts の store 参照を、core テストの indexed access 規則 (openclaw#105375) に合わせて optional chaining にした rebase 時のコンフリクト解決 (onto 258d034, 元コミット b7547efa95e): - src/config/zod-schema.root-shape.ts: 上流 87ff32d が repository-branch-prefix.js の import を追加。両方の import を残した - docs/.generated/config-baseline.*: 上流版を基に counts の core を +1 (2587)。 sha256 は依存を入れた別 worktree で pnpm config:docs:gen により再生成した (counts は +1 の値のまま一致) rebase 時のコンフリクト解決 (onto 638a185, 元コミット d1e0995b1d7): - 上流が cron に delivery / failureAlert (extend 形式) / agents / creators を追加した (zod-schema.root-shape.ts, schema.help.automation.ts, config-automation.md)。 上流の定義はそのまま残し、sessionRetention の直後に sessionGroup を、 help と許可キー一覧の文にも cron.sessionGroup を足した。 上流の isValidCronExpression import と SESSION_LABEL_MAX_LENGTH import は両方残した。 - docs/.generated/config-baseline.*: counts は上流の core 2638 に本コミットの +1 を足して 2639 とした。config-baseline.sha256 は上流版のまま (未再生成)。依存を入れた別 worktree で pnpm config:docs:gen を実行して再生成する必要がある (今回は install 禁止のため未実施)。
Related: #178812
What Problem This Solves
Fixes: a scheduled automation's runtime is decided at run time from whatever runtime override its cron session copies, not from what the job was created with. A job created from a conversation that runs Claude through
claude-cliwas bound to an account chosen for the embedded runtime, then ran on the CLI. On 2026-10-20, before #180492, that failed twice with "Automation candidate is incompatible with its recorded inference account and route". Since #180492, a forwarding CLI accepts the account, but the runtime still follows the copied override on each run. The error also didn't say which account or runtime was involved.A related failure on 2026-10-25: an hourly automation with no recorded account failed 10 times in a row after the default model moved to a provider with a stored profile. The message ("Automation has no recorded inference account…") named neither the account nor the runtime, so it was unclear what to record.
User Impact
User impact: new automations record the runtime they will run on next to their account, and every run executes on that runtime. The account is unchanged: capture binds exactly the account it bound before this PR, so nothing changes who pays for a run. A job created from a
claude-cliconversation records that account withruntime: "claude-cli", and claude-cli keeps receiving it, as #180492 does today. A job bound for the embedded runtime stays embedded, even if its cron session later copies a different runtime override.Automation inference account <profile> on runtime <runtime> was removed or signed out…. A job with no recorded account fails with…Runtime <runtime> would run <provider/model> with stored account <profile>. Record the account with openclaw automations edit <jobId> --model <provider/model>@<profile>, or with openclaw doctor --fix.(no recorded runtime). Older Gateways ignore the extra field, so a downgrade keeps working.Why This Change Was Made
Phase 5 of the scheduled-run execution context (design: "One tuple, one resolver"):
resolveCronCandidateExecutiondecides a candidate's runtime and execution route. It's shared by inference capture and every scheduled-run candidate, so the two can't disagree for the same inputs.session:jobs, or the runtime the creating conversation carries forcurrentjobs. That carry rule is extracted fromisolated-agent/session.tsunchanged, so both sides use one rule. Capture stores the result asruntimeon the binding.session:jobs (the shared reply path), run preparation, harness selection and candidate dispatch read the binding's runtime instead of the session's override.automations edit --model <ref>@<profile>records the new account with the job's existing runtime. If that runtime is no longer available for the same provider, the edit is rejected and the stored binding stays unchanged, so an edit never silently moves a job to another runtime. An edit to an unbound or legacy job resolves the runtime the same way create does.assertCandidaterefuses a candidate whose provider or runtime differs from the binding, naming both. The unrecorded-account refusal now has one helper, shared by the embedded auth plan, the cron CLI path, the reply-path CLI candidate and CLI preparation.Deferred to openclaw-84c: Codex app authority (row N1) still reads
triggerandscheduledRuntimeAuthority. Moving it toScheduledExecutionFactsneeds the same plugin SDK harness facts contract as rows 41/43. Behavior is the same either way.Evidence
Crabbox (AWS), head
943f9065578: (12df361d7fcchanges only the dev replay scriptscripts/dev/cron-context-replay.mtsand its test, which this Gateway proof does not run.)CRABBOX_AWS_REGION=us-east-1 CRABBOX_CAPACITY_REGIONS=us-east-1,us-east-2,us-west-2 crabbox run --provider aws --ttl 75m --timing-json --download proof-out.tgz=… --shell -- "bash proof/0d513-remote.sh"(hostOPENCLAW_*variables unset)543c92ba688as git HEAD. SHA-256 of all 26 changed files on the box matches local head943f9065578e0ec3d0ca79ac752da5c3d8cd89fb. The proof scripts, mock endpoint and QA CLI plugin are local tooling and are not committed.aws,c7a.8xlarge, leasecbx_8afa4291833a, stopped; inspect reports"state":"released"Real Gateway upgrade proof. v2026.10.7 (latest stable) creates state, then this build runs it. The provider is a mock OpenAI-compatible endpoint
qa-proof/m1with a stored API keyqa-proof:manual. A QA plugin registersqa-proof-cli, a CLI backend for that provider that does not forward stored accounts. 12/12 assertions passed:qa-proof:manualand creates an isolated job. Stable releases record no binding.Automation has no recorded inference account. Runtime openclaw would run qa-proof/m1 with stored account qa-proof:manual. Record the account with openclaw automations edit <jobId> --model qa-proof/m1@qa-proof:manual, or with openclaw doctor --fix.This is the 2026-10-25 shape.retain qa-proof:manual for qa-proof/m1 … Its runs are refused until it records this account.doctor --fixrecords the binding without a runtime, and the job then runs embedded (QA-PROOF-EMBEDDED-REPLY). Existing jobs keep today's resolution.qa-proof/m1withagentRuntimeOverride: qa-proof-cli. Acurrentjob created from it bindsqa-proof:manual, the same account main binds, now withruntime: "qa-proof-cli". This backend can't use a stored account, so the run is refused as it is on main. The message now names the account and the runtime:…incompatible with its recorded inference account and route (account qa-proof:manual on runtime qa-proof-cli). The selected runtime uses a CLI login that cannot use this job's stored account…. A new isolated job recordsruntime: "openclaw"and runs embedded.models.authLogoutremovesqa-proof:manual, the new bound job fails withAutomation inference account qa-proof:manual on runtime openclaw was removed or signed out…. The Doctor-bound job fails with…qa-proof:manual (no recorded runtime) was removed…, and the CLI-runtime job fails with…qa-proof:manual on runtime qa-proof-cli was removed….The same box ran the focused tests: propagation, binding normalization, context fixtures, auth-continuity integration, Doctor migration and gateway
cron.inference-binding. 7 files, 138 tests passed, including the shared-session reply-path suite.Focused tests (
src/cron/isolated-agent.auth-profile-propagation.test.ts):currentjob from aclaude-clicreator, on an Anthropic model, with a stored Anthropic API key, binds that API key, as main does, withruntime: "claude-cli". claude-cli receives the key. With a stored Anthropic token, it records that token the same way.claude-clioverride, it runs on claude-cli with the bound account.session:job on the shared reply path: the target row carriesagentRuntimeOverride: "claude-cli"and the binding recordsopenclaw. Candidates resolve and are checked onopenclaw, and the run is embedded (agent-runner-execution-session-events.test.ts).claude-clikeepsruntime: "claude-cli"after--model …@<profile>, even though config alone would pick the embedded runtime. When that recorded runtime is no longer a CLI backend, the same edit is rejected withruns on runtime claude-cli, which is unavailable…and the binding is left as it was.isolated-agent.auth-continuity.integration.test.ts, real runner) and on the CLI path.agentRuntimeOverride: "claude-cli". It also stays embedded when config later moves its model to a CLI runtime.claude-clijob whose runtime is no longer a CLI backend fails withaccount … on runtime claude-cliandcaptured for runtime claude-cli.Static replay (
scripts/dev/cron-context-replay.mtson Josh's Gateway, read-only copies, at6e4ae6c0f67; from12df361d7fcthe replay picks each bound job's model throughresolveCronModelSelection, the owner capture and runs use, and reportsinference runtime unresolvedinstead of guessing when that selection fails or leaves the bound provider): Rerun at12df361d7fc: 108 jobs, all 39 bound jobs reportinference runtime unresolved, because the selection owner refuses this Gateway's agent databases (schema 35; this checkout expects 37 until Doctor upgrades them). No inference label is guessed. The figures below are from the earlier head. 108 jobs. The newinferencefield: 31 bound jobsequal, 77 unbound or runtime-owned with no label. Nogain-unexpectedon any field. Every stored binding predates theruntimefield and keeps the runtime its run picks today. The remaininglosslabels (automationsCli,requesterYield,ownerEmbedded) and the pauses come from earlier phases and are explained in #183987 and #183913.Pinned fixtures for this phase:
equal: bound withruntime: "claude-cli"(same account as main), and the run would pick claude-cli from the copied override. This is the fix(cron): bind forwarded CLI accounts for scheduled runs #180492 shape.equal: bound without a runtime, run copies a CLI override. It resolves as today.retarget: bound withruntime: "claude-cli", but the conversation's override has since changed to the embedded runtime. Named cause: the job stays on its captured runtime instead of following the creator.Local:
pnpm tsgo:core,pnpm tsgo:core:test, oxlint and oxfmt on changed files pass. Autoreview found no P0/P1 issues. It used Claude, because the Codex CLI failed authentication on this host.