Repository navigation
fix(cron): current automations change model or fail when their conversation switches models - #185341
Conversation
…reated with A current job is a child run of its creating conversation. Its run session no longer copies the conversation's model, runtime or account selection when the job recorded its inference runtime, so a conversation that later switches model or provider neither moves the job nor invalidates its binding. Jobs without a recorded runtime keep today's resolution.
|
🦞👀 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 changesRuntime-bound current automations stop inheriting later model, runtime, and account selections from their creating conversation. Example: A current automation uses qa-proof/m1, then its conversation switches to qa-alt/m3.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep open: this PR fixes a current capture-versus-execution mismatch, and the supplied upgrade evidence addresses the previous review’s blocker; no concrete introduced defect was found. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherCron preparation combines a stored job with conversation preferences, resolves its scheduled model, and dispatches an isolated child run through existing inference authorization. flowchart TD
A[Stored automation] --> C[Cron preparation]
B[Creating conversation] --> C
C --> D[Session preference sanitizer]
D --> E[Scheduled model selection]
A --> F[Recorded inference authorization]
E --> G[Agent execution]
F --> G
Technical reviewBest possible solution: Use the existing session sanitizer to keep runtime-bound child inference independent of later conversation selections while preserving legacy behavior. Do we have a high-confidence way to reproduce the issue? Source confirms that capture ignores current-conversation model overrides while main execution copies them, and the supplied Gateway comparison demonstrates both silent model drift and provider-mismatch refusal. Is this the best way to solve the issue? The repair belongs in the existing fresh-session carry owner, uses the recorded-runtime compatibility boundary, and introduces no competing inference owner. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 1f24921b5fd9. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +144, Tests +208, Docs 0, Other +19. Total +371 across 12 files. Added test files: 0. View PR surface stats
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 26, 2026, 11:37 PM ET / October 27, 2026, 03:37 UTC (Revision 2). |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Merged via squash.
|
…reated with (openclaw#185341) A current job is a child run of its creating conversation. Its run session no longer copies the conversation's model, runtime or account selection when the job recorded its inference runtime, so a conversation that later switches model or provider neither moves the job nor invalidates its binding. Jobs without a recorded runtime keep today's resolution.
Related: #178814, #178812
What Problem This Solves
Fixes: a
currentautomation changes model, or stops running, when the conversation that created it later switches model or provider. Each run copies the conversation's model, runtime and account selection as it is at that moment. A switch to another model on the same provider silently moves the automation to that model. A switch to another provider makes every run fail withAutomation candidate … is incompatible with its recorded inference account and route … The selected model uses a different provider from this job's stored account.User Impact
User impact: an automation created from a conversation runs on the model, runtime and inference account it was created with (its
--model, or the agent's default). Changing the conversation's model later no longer moves the automation or breaks it. Useautomations edit --model …to change an automation's model.--model <provider/model>@<profile>records the runtime and moves the job to the new behavior.currentas a child run of its creating conversation.Why This Change Was Made
Phase 6 of the scheduled-run execution context (#178812, design: "Phase 6:
currentsemantics"). Acurrentjob is a child of its conversation. It keeps its owncron:<jobId>run key, so it never joins a live turn in the conversation, and since the phase 2 changes it uses the conversation's dashboard, memory, workspace and sandbox. Its inference was the remaining per-run read from the parent row.Inference capture already ignores the creating conversation's model for
currentjobs. It binds the account for the job's scheduled model (#180677), and since #185070 it records the runtime too. The run still copied the conversation's model on every occurrence. So run and capture disagreed whenever the conversation had a model override. On the same provider the run used a different model from the one the account was captured for; on another provider the drift guard refused it.Now, when the job's binding records a runtime, the run session takes no model, runtime or account selection from the creating conversation. Run and capture resolve the same scheduled model, and the binding supplies the runtime and account. Bindings without a runtime keep today's copy, because the job has no captured tuple to use instead. This is the same compatibility rule #185070 uses.
Code
src/cron/isolated-agent/session.ts:inferenceCapturedstops a differing source row from seeding model, runtime and account overrides. A job rolling its own row is unaffected.src/cron/isolated-agent/run-prepare.ts: passesinferenceCapturedwhen the binding records a runtime. Comment on the run key.src/cron/session-target.ts:isDetachedCronSessionTargetdocuments that it decides the run key only.scripts/dev/cron-context-replay.mtsandsrc/cron/execution-context-projection.ts: the inference comparison also compares the copied conversation model with the job's scheduled model forcurrentjobs with a recorded runtime.docs/automation/cron-jobs/payloads.md,docs/automation/cron-jobs/delivery.md.Evidence
Crabbox (AWS), head
71cc0204e17: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=… -- bash proof/0d514-remote.sh(hostOPENCLAW_*service variables unset)71cc0204e1770911beb38a6fc6a6f6b1ece998eb. The proof scripts and the mock endpoint are local tooling and are not committed.aws,c7a.8xlarge, leasecbx_d442eb4d2d7b, stopped; inspect reports"state":"released"The test uses a real Gateway with a mock OpenAI-compatible endpoint that logs the model of every request. It has two providers,
qa-proof(modelsm1,m2) andqa-alt(m3), each with a stored API-key account. The agent default isqa-proof/m1. Eachcurrentjob is created from one dashboard conversation. Then the conversation is switched withsessions.patchand the jobs are forced withcron.run. The run is done twice: once on this head, and once on the same tree with the one-line fix reverted (inferenceCaptured: false, the same behavior as main).switch-modelqa-proof, runtimeopenclawqa-proof/m2m2m1switch-providerqa-proof, runtimeopenclawqa-alt/m3Automation candidate qa-alt on runtime openclaw is incompatible with its recorded inference account and route (account qa-proof:manual on runtime openclaw). The selected model uses a different provider from this job's stored account…m1legacy-binding(nearest unchanged case)qa-proof, no runtime (recorded before #185070)qa-proof/m2m2m2(unchanged)stable-current(upgrade)doctor --fix, no runtimeqa-proof/m2m2(unchanged)currentjob. It records no binding. This build'sdoctor --fixrecordsqa-proof:manualwithout a runtime.cron.listshows the job unchanged across the upgrade (jobs-upgrade.diffis empty). It keeps following the conversation's model, as on main.m1before any switch.sessionIdandlifecycleRevisionare the same before and after all runs. The child runs did not change the conversation's row.runtime: "openclaw"after every run. A conversation switch does not invalidate them.Focused tests:
isolated-agent.auth-profile-propagation.test.ts: acurrentjob bound withruntime: "claude-cli"keepsclaude-cli, its model and its account after the conversation switches to another model, and after it switches to another provider. Both cases fail with the fix reverted: the first runs the conversation's new model, the second fails with the provider-mismatch refusal above.isolated-agent.session-identity.test.ts: a linkedcurrentjob admitted through the real occurrence admission runs underagent:main:cron:<jobId>:run:…(never the conversation's key), withplacement: "child"and the conversation's board, memory and workspace. The conversation's row is unchanged after the run.isolated-agent/session.test.ts: the carry rule for captured and uncaptured jobs, and for a job rolling its own row.test/scripts/cron-context-replay.test.tsand fixtures: the replay's model comparison, including the shape whose legacy pick the drift guard refuses.src/cron/isolated-agentand related suites: 65 files and 630 tests pass, plus the session-identity, propagation, auth-continuity, execution-context, gatewaycron.inference-bindingand replay suites.pnpm tsgo:core,pnpm tsgo:core:test, and oxlint/oxfmt on the changed files pass.Static replay (
scripts/dev/cron-context-replay.mtson Josh's Gateway, read-only copies): 108 jobs. Nogain-unexpectedon any field. This PR does not change the builder, so every non-inference label is the same as on main. The pauses andlosslabels (automationsCli,requesterYield,ownerEmbedded) are explained in #183913 and #183987. All 39 bound jobs reportinference runtime unresolvedbecause the selection owner refuses this Gateway's agent databases (schema 35; this checkout expects 37 until Doctor upgrades them). A direct read of the same copies covers the field this PR changes: 21 storedcurrentjobs, and none has a binding with a recorded runtime. So no stored job on this Gateway changes behavior, and all 21 keep today's resolution. One of them shows the failure this fixes: "PR #178904 landing watch" is bound toopenaiwhile its conversation has since moved toanthropic/claude-opus-5-5onclaude-cli. Today its runs would be refused by the drift guard. It has no recorded runtime, so it keeps that behavior until its account is selected again.Pinned fixtures for the new comparison:
equalwhen the copied model matches the scheduled model, andretargetwhen the conversation's model differs. Named cause: the job runs its scheduled model, the one its account was captured for, instead of the conversation's later model.Autoreview (Claude; the Codex CLI failed authentication on this host): one P2. It suggested that the binding's provider might come from the conversation's selection, so a job could now pick the agent default on another provider and be refused. That doesn't happen: capture resolves the model with
sessionEntry: executionSessionEntry ?? {}, and forcurrentjobsexecutionSessionEntryis undefined (src/gateway/server-methods/cron-input-validation.ts, #180677). So the binding's provider is the scheduled model's provider, the one the run now selects. The "another provider" test and the Crabboxswitch-providercase run successfully on that path.