Skip to content

fix(cron): current automations change model or fail when their conversation switches models - #185341

Merged
jalehman merged 1 commit into
mainfrom
openclaw-0d5.14/current-child-model
Oct 27, 2026
Merged

jalehman merged 1 commit into
mainfrom
openclaw-0d5.14/current-child-model

Conversation

@jalehman

@jalehman jalehman commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Related: #178814, #178812

What Problem This Solves

Fixes: a current automation 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 with Automation 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. Use automations edit --model … to change an automation's model.

  • Not changed: jobs whose account was recorded before fix(cron): scheduled automations run on whatever runtime their session copies instead of the one they were bound for #185070 (no recorded runtime) and jobs with no recorded account (for example a CLI backend that uses its own login) keep following the conversation's model, exactly as today. Selecting the account again with --model <provider/model>@<profile> records the runtime and moves the job to the new behavior.
  • Thinking level and the other conversation preferences a run copies are unchanged.
  • The docs now describe current as a child run of its creating conversation.

Why This Change Was Made

Phase 6 of the scheduled-run execution context (#178812, design: "Phase 6: current semantics"). A current job is a child of its conversation. It keeps its own cron:<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 current jobs. 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: inferenceCaptured stops 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: passes inferenceCaptured when the binding records a runtime. Comment on the run key.
  • src/cron/session-target.ts: isDetachedCronSessionTarget documents that it decides the run key only.
  • scripts/dev/cron-context-replay.mts and src/cron/execution-context-projection.ts: the inference comparison also compares the copied conversation model with the job's scheduled model for current jobs with a recorded runtime.
  • Docs: docs/automation/cron-jobs/payloads.md, docs/automation/cron-jobs/delivery.md.

Evidence

Crabbox (AWS), head 71cc0204e17:

Command 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 (host OPENCLAW_* service variables unset)
Tested source The box syncs the working tree onto its seed commit. The SHA-256 of all 12 changed files on the box matches local head 71cc0204e1770911beb38a6fc6a6f6b1ece998eb. The proof scripts and the mock endpoint are local tooling and are not committed.
Provider / lease aws, c7a.8xlarge, lease cbx_d442eb4d2d7b, stopped; inspect reports "state":"released"
Run run_89318fab93b6a87aa112c9691e3d3e32, exit 0, evidence bundle downloaded

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 (models m1, m2) and qa-alt (m3), each with a stored API-key account. The agent default is qa-proof/m1. Each current job is created from one dashboard conversation. Then the conversation is switched with sessions.patch and the jobs are forced with cron.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).

Case Binding Conversation Main (fix reverted) This PR
switch-model qa-proof, runtime openclaw switched to qa-proof/m2 ran m2 ran m1
switch-provider qa-proof, runtime openclaw switched to qa-alt/m3 error: Automation 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… ok, ran m1
legacy-binding (nearest unchanged case) qa-proof, no runtime (recorded before #185070) switched to qa-proof/m2 ran m2 ran m2 (unchanged)
stable-current (upgrade) created on v2026.10.7, bound by doctor --fix, no runtime switched to qa-proof/m2 — ran m2 (unchanged)
  • Upgrade from v2026.10.7 (latest stable): v2026.10.7 stores both accounts, the conversation and a current job. It records no binding. This build's doctor --fix records qa-proof:manual without a runtime. cron.list shows the job unchanged across the upgrade (jobs-upgrade.diff is empty). It keeps following the conversation's model, as on main.
  • Every job ran first on m1 before any switch.
  • The conversation's sessionId and lifecycleRevision are the same before and after all runs. The child runs did not change the conversation's row.
  • The new bindings keep runtime: "openclaw" after every run. A conversation switch does not invalidate them.

Focused tests:

  • isolated-agent.auth-profile-propagation.test.ts: a current job bound with runtime: "claude-cli" keeps claude-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 linked current job admitted through the real occurrence admission runs under agent:main:cron:<jobId>:run:… (never the conversation's key), with placement: "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.ts and fixtures: the replay's model comparison, including the shape whose legacy pick the drift guard refuses.
  • src/cron/isolated-agent and related suites: 65 files and 630 tests pass, plus the session-identity, propagation, auth-continuity, execution-context, gateway cron.inference-binding and replay suites.
  • pnpm tsgo:core, pnpm tsgo:core:test, and oxlint/oxfmt on the changed files pass.

Static replay (scripts/dev/cron-context-replay.mts on Josh's Gateway, read-only copies): 108 jobs. No gain-unexpected on any field. This PR does not change the builder, so every non-inference label is the same as on main. The pauses and loss labels (automationsCli, requesterYield, ownerEmbedded) are explained in #183913 and #183987. All 39 bound jobs report inference runtime unresolved because 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 stored current jobs, 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 to openai while its conversation has since moved to anthropic/claude-opus-5-5 on claude-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: equal when the copied model matches the scheduled model, and retarget when 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 for current jobs executionSessionEntry is 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 Crabbox switch-provider case run successfully on that path.

…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.
@clawsweeper

clawsweeper Bot commented Oct 27, 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.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation scripts Repository scripts size: M labels Oct 27, 2026
@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. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed 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 Oct 27, 2026
@clawsweeper

clawsweeper Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

Runtime-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.

  • Before: The next automation run selects qa-alt/m3 and fails because its recorded account belongs to qa-proof.
  • After: The automation runs qa-proof/m1 using its recorded runtime and account.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused repair with relevant regression coverage, supplied Gateway and stable-upgrade evidence, and green exact-head validation.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): The PR supplies exact-head real-Gateway results through sessions.patch and cron.run against a request-recording OpenAI-compatible endpoint: switched conversations retain m1 after repair, the reverted fix reproduces drift/refusal, and legacy jobs retain their prior behavior; the linked portal artifact could not be opened here.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: A conversation model switch unexpectedly changes its automation’s model or causes every subsequent run to fail.
Reason: The focused repair restores agreement between existing account capture and execution, and the supplied maintainer-authored classification establishes direction.

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
Reviewed head: 71cc0204e1770911beb38a6fc6a6f6b1ece998eb

Before merge

None.

Findings

None.

Agent review details

How this fits together

Cron 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
Loading

Technical review

Best 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

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

  • Introduced fix: The pinned introduced diff adds an inferenceCaptured input and suppresses carried inference selection only when a different source row seeds a fresh session; same-row rollover and unrelated preferences retain their existing behavior. (src/cron/isolated-agent/session.ts:247, 71cc0204e177)
  • Current main still needs the repair: Fetched main retains unconditional model-selection and user-auth carry during fresh cron-session sanitization; the PR’s changed preparation and sanitizer behavior is absent. (src/cron/isolated-agent/session.ts:113, 1f24921b5fd9)
  • Capture contract: Current-job capture supplies no persistent execution-session model override, so account capture resolves the scheduled model rather than the creating conversation’s model; the repair aligns execution with this existing contract from fix(cron): preserve scheduled accounts and restart retry deadlines #180677. (src/gateway/server-methods/cron-input-validation.ts:400, 71cc0204e177)
  • Behavior and upgrade evidence: The full PR body records real Gateway sessions.patch and cron.run comparisons against the reverted fix: same-provider model switching and cross-provider switching both retain m1 after repair. It also records a v2026.10.7 upgrade through Doctor, unchanged listed job data, and successful legacy model-following behavior. The linked Crabbox portal artifact was inaccessible from this review environment; these are contributor-supplied results. (71cc0204e177)
  • Credential authority remains live: Execution continues to reacquire the recorded credential authorization, reject provider/runtime drift, disable account fallback, and pass live authorization assertions through CLI launch; this PR changes neither binding capture nor those enforcement owners. (src/cron/run-inference.ts:96, 71cc0204e177)
  • Exact-head CI: Paginated check results show successful production/test type checks, changed-path tests, prompt snapshots, security checks, and openclaw/ci-gate. Two cancelled auto-response jobs are bot-response workflow records, not failed product validation; all three commit statuses are successful. (71cc0204e177)

Likely related people:

  • Peter Steinberger: Raw commit f2745aa adds src/cron/isolated-agent/session.ts:93 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: f2745aa03ac9; files: src/cron/isolated-agent/session.ts)

PR surface

Source +144, Tests +208, Docs 0, Other +19. Total +371 across 12 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 5 155 11 +144
Tests 4 209 1 +208
Docs 2 9 9 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 29 10 +19
Total 12 402 31 +371

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🦞 diamond lobster.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • remove rating: 🦪 silver shellfish: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.

Label justifications:

  • P2: Conversation model changes can silently retarget scheduled work or repeatedly refuse it, with impact limited to affected current automations.
  • merge-risk: 🚨 auth-provider: The patch changes which model-selection inputs reach inference routing; the accepted direction aligns execution with recorded bindings and preserves legacy jobs.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.

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.

History

Review history (1 earlier review cycle)
  • reviewed 2026-10-27T02:48:41.613Z sha 71cc020 :: blocked before merge. :: none

Reviewed October 26, 2026, 11:37 PM ET / October 27, 2026, 03:37 UTC (Revision 2).

@jalehman

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Oct 27, 2026
@jalehman
jalehman merged commit 6cdb29b into main Oct 27, 2026
159 of 161 checks passed
@jalehman
jalehman deleted the openclaw-0d5.14/current-child-model branch October 27, 2026 03:48
@jalehman

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 27, 2026
…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. scripts Repository scripts size: M status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant