Skip to content

fix(cron): keep stored user session models strict - #177494

Merged
obviyus merged 15 commits into
openclaw:mainfrom
nxmxbbd:fix/cron-session-override-strict
Oct 23, 2026
Merged

obviyus merged 15 commits into
openclaw:mainfrom
nxmxbbd:fix/cron-session-override-strict

Conversation

@nxmxbbd

@nxmxbbd nxmxbbd commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

A scheduled automation can answer using a configured fallback after the user explicitly pins its session model and that model fails. Normal session selections are exact, but automation fallback preparation loses the stored selection provenance.

User Impact

Automations targeting either isolated or ordinary named sessions honor an explicit user model pin. A failed pinned model produces a failed run instead of silently answering with a different model. Explicit job fallback lists and job model overrides retain their existing precedence; automatic selections retain configured fallback behavior.

Why This Change Was Made

Carry the existing session-selection provenance through scheduled run preparation into the existing fallback resolver. Refresh that derived policy when queued work is retargeted without replacing its admitted authority. No persisted schema, config option, plugin SDK surface, or new fallback policy is introduced.

Evidence

Captured provider request order, shipped CLI output, and red/green regression.

Built Gateway/CLI artifacts on Node 24.22.1 in isolated Linux Docker with owned local provider fixtures. All state was created through shipped config CLI, automations add/run/edit, and sessions.create/patch RPCs.

  • Baseline: for each of an isolated job and an ordinary named-session job, two runs after sessions.patch pinned model-x requested model-x and then configured model-b, and succeeded with model-b's final marker.
  • Candidate: the same four runs requested only model-x and failed visibly after its HTTP 404 model_not_found. Neither configured fallback was contacted.
  • Control: explicit per-job fallback model-c still answered after model-x failed, on both baseline and candidate, for both session targets.
  • Focused tests protect strict user/legacy selections, automatic selections, explicit job precedence, preflight candidate policy, queued selection refresh, and admission-authority preservation. Integration fixtures use the current scheduled-occurrence fixture required by main.

Simplification: reuse the existing fallback resolver and selection facts; remove the duplicated prompt-executor parameter projection. Remaining production growth carries provenance across the two execution paths and refreshes queued derived policy without changing authority. The larger integration fixtures exercise actual runner/provider outcomes and distinct queued-admission behavior rather than adding production test seams.

Merge Danger

Two-way door: a revert restores the old fallback behavior; no stored format is changed. Blast radius is scheduled agent model fallback, including queued turns. Explicit job overrides and normal automatic fallback remain supported.

Isolated cron runs that used a session's stored model selection still
resolved the configured fallback chain, because the run's fallback policy
only knew about payload, subagent, and agent/default selections. A model
pinned with /model, the picker, or sessions.patch (and legacy pins without
a source) could fail and then be answered by a configured fallback or the
configured primary.

Carry the stored session provenance from run preparation into the shared
cron fallback policy, which preflight and execution both use, and let the
shared session policy keep user selections exact. Explicit payload
fallbacks, payload models, and automatic session selections keep their
existing chains.
Keep the stored user pin in the integration controls so they differ from the strict cases only by the job's own fallbacks or model, assert the provider error on the strict runs, exercise the payload-model guard at the policy level, and note that a user pin keeps local-provider preflight strict.
The explicit-fallbacks control used the configured fallback model, so a regression that let configured fallbacks replace the job's own list would still pass. Use a distinct job fallback and assert each control's trace.
@clawsweeper

clawsweeper Bot commented Oct 19, 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 size: M labels Oct 19, 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. P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. labels Oct 19, 2026
@clawsweeper

clawsweeper Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

Scheduled agent turns preserve stored user model pins while retaining explicit job model and fallback precedence.

Example: An automation session pins pinned/model-x, which returns HTTP 404 model_not_found, with fallback/model-b configured.

  • Before: The automation requests model-x and then succeeds using model-b.
  • After: The automation requests only model-x and reports an actionable failure; explicit job fallbacks still work.

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) A focused contract repair with matched Gateway/CLI evidence, red/green regressions, preserved override controls, and the prior finding resolved.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): obviyus's isolated Linux Docker captures exercise built Gateway/CLI automations with real local provider HTTP fixtures: baseline repeatedly requests model-x then model-b, while the candidate requests only model-x and fails visibly for both isolated and named-session jobs; explicit model-c job fallbacks still succeed. Production code is unchanged between the captured runtime and reviewed head. Compatibility is a verified no-migration case: existing selection fields and persisted preferences remain unchanged, including legacy-pin handling.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Scheduled work can answer from another configured model after the user's explicitly selected model fails.
Reason: This restores an existing documented contract without a new option, persisted format, or competing policy owner.

Merge readiness

✅ Ready for maintainer review

This PR fixes a documented model-selection bug still present on current main. The prior fixture finding is resolved, and no new actionable defects were found; exact-head CI remains pending.

Priority: P2
Reviewed head: 639b2df25e6bdeebff1e726d4ee2a8b86c677376

Before merge

None.

Findings

None.

Agent review details

How this fits together

Cron resolves scheduled work into isolated execution or ordinary session admission; session selection facts and job overrides determine the provider candidate chain and final run result.

flowchart TD
  A[Scheduled job] --> B[Session model selection]
  B --> C[Isolated preparation]
  B --> D[Session admission and queue]
  C --> E[Shared fallback policy]
  D --> E
  E --> F[Provider execution]
  F --> G[Automation result]
Loading

Technical review

Best possible solution:

Land this provenance handoff through the existing fallback and admission owners once required CI passes.

Do we have a high-confidence way to reproduce the issue?

Current-main source confirms the missing provenance handoff, consistent with the supplied baseline Gateway traces; this read-only review executed no target code or tests.

Is this the best way to solve the issue?

The patch restores the documented exact-selection contract using existing owners, preserves explicit job overrides, and captures queued derived policy at the existing admission fence.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 28f539f636ba.

Provenance checked

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit d2320e4 adds src/auto-reply/reply/queue/state.ts:143 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: d2320e4d4b42; files: src/auto-reply/reply/queue/state.ts)
  • Vito Cappello: Raw commit 5621979 adds src/auto-reply/reply/queue/state.ts:269 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 5621979a469a; files: src/auto-reply/reply/queue/state.ts)

PR surface

Source +42, Tests +790, Docs +2. Total +834 across 14 files. Added test files: 2.

View PR surface stats
Area Files Added Removed Net
Source 8 50 8 +42
Tests 5 792 2 +790
Docs 1 3 1 +2
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 14 845 11 +834

Review metrics

Metric Value Why it matters
Production versus test changes Production +50/-8; tests +792/-2 Production growth carries existing provenance across two execution paths and the admission fence; integration coverage exercises distinct isolated, ordinary-session, and queued-selection failures.

Root-cause cluster

Relationship: same_root_cause
Canonical: #177546
Summary: The linked report owns the demonstrated automation model-pin bug, and this PR supplies its repair.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Labels

Label changes:

  • add rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster 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: 🦐 gold shrimp: Current PR rating is rating: 🦞 diamond lobster, so this older rating label is no longer current.
  • remove status: ⏳ waiting on author: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P2: The deterministic bug affects scheduled work with stored user model pins when the selected model fails.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster 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 (7 earlier review cycles)
  • reviewed 2026-10-19T17:04:52.182Z sha 03c5dff :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-19T17:43:11.011Z sha 08d1aee :: needs maintainer review before merge. :: none
  • reviewed 2026-10-19T18:33:41.486Z sha 4e33ab7 :: needs maintainer review before merge. :: none
  • reviewed 2026-10-19T23:19:45.444Z sha eeb05ee :: needs maintainer review before merge. :: none
  • reviewed 2026-10-21T21:54:34.901Z sha a35aa2e :: needs changes before merge. :: [P2] Capture the refreshed scheduled policy at the admission fence
  • reviewed 2026-10-22T05:59:39.683Z sha 38b02d2 :: needs maintainer review before merge. :: none
  • reviewed 2026-10-23T04:03:50.560Z sha a096f71 :: needs changes before merge. :: [P2] Supply scheduled occurrences in both added unit-test fixtures

Reviewed October 23, 2026, 12:32 AM ET / 04:32 UTC (Revision 8).

Realistic model ids made the deliberately failing stub read like a real provider credential failure. Name the stubs by role (pinned, primary, fallback, jobfallback) and record requests by provider route.
@nxmxbbd

nxmxbbd commented Oct 19, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 19, 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: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Oct 19, 2026
@nxmxbbd

nxmxbbd commented Oct 19, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. 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 23, 2026
@obviyus

obviyus commented Oct 23, 2026

Copy link
Copy Markdown
Collaborator

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 23, 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. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. 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 23, 2026
@obviyus
obviyus merged commit 9883515 into openclaw:main Oct 23, 2026
141 checks passed
@obviyus

obviyus commented Oct 23, 2026

Copy link
Copy Markdown
Collaborator

Landed in 9883515. Thanks @nxmxbbd. Automations now respect an explicitly pinned session model.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 24, 2026
fix(cron): keep an automation on the user's pinned session model

When a user explicitly pinned a session's model and that model failed, an automation running in that session silently answered with the configured fallback model instead, unlike a normal chat turn. Automations now honor the explicit pin the same way chat does: they use only the pinned model and report its failure. Jobs that set their own fallback list still use it.

Evidence: built Gateway and CLI with local provider fixtures. On main both isolated and named-session automations answered from the fallback after the pinned model failed (twice each); with this change they contact only the pinned model and fail visibly (twice each). A job with an explicit fallback list still succeeds through it. Captures: openclaw#177494 (comment).

Thanks @nxmxbbd.

Co-authored-by: Ayaan Zaidi <[email protected]>
@nxmxbbd
nxmxbbd deleted the fix/cron-session-override-strict branch October 27, 2026 07:21
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 P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. size: L 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.

2 participants