Skip to content

Isolated cron job payload.model override leaks back to parent/main session model #107922

Closed as not planned

Description

Bug Report

Version: 2026.7.1 (2d2ddc4)

Summary

Isolated cron jobs with an explicit payload.model override leak that model back into the parent/main session after the cron job runs. The main session's model silently changes from its configured default to whatever model the cron job used.

Impact

  • Main session silently switches models mid-conversation without user action
  • If cron jobs use expensive models (Sonnet, Opus) for cost-effective processing, the main session inherits that expensive model
  • User must manually reselect the default model after every cron job run
  • Makes agents.defaults.model.primary meaningless when cron jobs are active

Reproduction

  1. Configure agent default model: agents.defaults.model.primary: "moonshot/kimi-k2.6"
  2. Create an isolated cron job with payload.model: "deepseek/deepseek-v4-flash" and sessionTarget: "isolated"
  3. From the WebChat UI, confirm the main session model is moonshot/kimi-k2.6
  4. Trigger the isolated cron job (or wait for scheduled run)
  5. Observed: Main session model changes to deepseek/deepseek-v4-flash immediately or shortly after the cron job runs
  6. Expected: Main session model remains moonshot/kimi-k2.6 (the configured default)

Root Cause (suspected)

The session-management-compaction logic appears to carry "explicit user-selected model/auth overrides" from the isolated cron session back to the parent session entry, rather than keeping it scoped to the isolated run.

This is a regression between 2026.6.11 and 2026.7.1. Issue #77339 (fixed in 2026.6.11) addressed a similar "cached model override" issue for fresh sessions.

Related but distinct issues:

Workaround

Environment

  • OpenClaw 2026.7.1 (2d2ddc4)
  • Running in Docker on Ubuntu Linux x64
  • WebChat UI (browser incognito)
  • Multiple cron jobs with various payload.model values

Activity

  1. added
    P1High-priority user-facing bug, regression, or broken workflow.
    impact:session-stateSession, memory, transcript, context, or agent state can drift or corrupt.
    impact:auth-providerAuth, provider routing, model choice, or SecretRef resolution may break.
    issue-rating: 🦪 silver shellfishThin issue quality; more reproduction proof or environment detail is needed.
    clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.
    clawsweeper:needs-maintainer-reviewClawSweeper marked this issue as needing maintainer review before automation.
    on Jul 16, 2026
  2. clawsweeper commented on Jul 16, 2026

    @clawsweeper
    Contributor

    Codex review: keeping this open for maintainer follow-up; there is still a little grit to resolve. Reviewed July 15, 2026, 10:22 PM ET / July 16, 2026, 02:22 UTC.

    Summary
    Keep open: the v2026.7.1 report has concrete user-visible session/model impact, but current main now separates detached cron execution keys from source session keys; without a focused regression or identifiable fix commit, it is not yet safe to close as implemented. Likely related people: steipete, shakkernerd, and vincentkoc based on the isolated-cron runtime history.

    Reproducibility: no. high-confidence current-main reproduction has been established. The reporter supplies concrete steps for v2026.7.1, while current main's detached execution-key logic may already prevent that exact path.

    Ways to help us reproduce this

    • Add a screenshot or short recording showing the behavior.
    • Add expected vs actual behavior.
    • Include redacted logs or terminal output.

    Next step
    Verify the exact reproduction against current main and identify whether the existing detached execution-key changes already fix it before dispatching a repair.

    Review details

    Best possible solution:

    Add a regression that seeds a main session model, executes an isolated cron with a different payload model, and asserts the main session entry remains unchanged while the cron-owned entry records only run-local state; fix the execution/persistence boundary only if that test fails.

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

    No high-confidence current-main reproduction has been established. The reporter supplies concrete steps for v2026.7.1, while current main's detached execution-key logic may already prevent that exact path.

    Is this the best way to solve the issue?

    No, the suspected reverse compaction merge is not yet demonstrated by current source. The narrowest maintainable approach is first proving parent-entry immutability with a focused regression, then repairing whichever execution or persistence boundary fails it.

    AGENTS.md: found and applied where relevant.

    Remaining risk / open question:

    • Current main appears to contain stronger session-key isolation than v2026.7.1, but no focused test or live current-main reproduction establishes whether another path still copies the cron model into the parent entry.
    • No specific post-v2026.7.1 commit was identified as the fix, so release or current-main-only provenance is insufficient for an implemented-on-main close.

    Codex review notes: model internal, reasoning high; reviewed against 08ecf63bb608.

    Label changes

    Label changes:

    • add P1: A released isolated-cron workflow reportedly changes the active main session's model silently, affecting ongoing conversations and model cost until manually corrected.
    • add impact:session-state: The reported failure crosses an isolation boundary and mutates model state associated with the parent/main session.
    • add impact:auth-provider: The issue changes the effective provider/model selection from the configured main-session default to the cron payload override.
    • add issue-rating: 🦪 silver shellfish: Current issue advisory state selects this label.
    • add clawsweeper:no-new-fix-pr: Current issue advisory state selects this label.
    • add clawsweeper:needs-maintainer-review: Current issue advisory state selects this label.

    Label justifications:

    • P1: A released isolated-cron workflow reportedly changes the active main session's model silently, affecting ongoing conversations and model cost until manually corrected.
    • impact:session-state: The reported failure crosses an isolation boundary and mutates model state associated with the parent/main session.
    • impact:auth-provider: The issue changes the effective provider/model selection from the configured main-session default to the cron payload override.
    Evidence reviewed

    Acceptance criteria:

    • node scripts/run-vitest.mjs src/cron/isolated-agent.run.test.ts
    • Add a focused persisted-session regression covering different main and cron payload models
    • Run a real isolated cron from WebChat or the production cron runner and inspect the main session model before and after

    What I checked:

    • Reported shipped behavior: The reporter provides a repeatable v2026.7.1 sequence where an isolated cron using a different payload model is followed by the WebChat main session adopting that model; this is a concrete released-version report, not a speculative feature request. citeturn399718view0. (2d2ddc43d0dc)
    • Current execution-key isolation: Current main derives a cron-owned execution session key for detached isolated runs when the supplied source key is not already cron-scoped, which appears designed to prevent writes through the parent key. citeturn307823view1turn936046view1. (src/cron/isolated-agent/run.ts:3361, 08ecf63bb608)
    • Persistence boundary: The completion path persists the isolated run through the derived agentSessionKey and then returns that key, but the available tests and discussion do not directly prove that the source/main entry's model fields remain byte-for-byte unchanged. citeturn820163view1. (src/cron/isolated-agent/run.ts:3503, 08ecf63bb608)
    • Fresh-session override handling: The session helper deliberately preserves explicit user-selected model/auth overrides while clearing stale runtime cache fields, making model-field provenance sensitive and warranting a targeted parent-versus-cron regression test. citeturn373059view1. (src/cron/isolated-agent/session.ts:884, 08ecf63bb608)
    • Documented isolation contract: Cron documentation describes isolated jobs as creating a fresh session for each run, supporting the expectation that a run-specific model override must not mutate the main session. citeturn253522view0. Public docs: docs/automation/cron-jobs.md. (docs/automation/cron-jobs.md:194, 08ecf63bb608)
    • Related collision history: The earlier parent-session overwrite report documented that an isolated cron key collision could replace the main entry, including its model fields; it is strong same-area evidence but does not prove this newly reported regression has the identical current root cause. (src/cron/isolated-agent/session.ts:823, 08ecf63bb608)

    Likely related people:

    • steipete: The isolated cron runner history attributes the large execution-phase refactor and several surrounding cron behavior changes to this contributor. citeturn229698view0turn463602view0. (role: major isolated-run refactor author; confidence: high; commits: bbb73d3, 4575cae, 89e6da1; files: src/cron/isolated-agent/run.ts)
    • shakkernerd: Recent history on the central runner includes cron runtime and isolated-run changes from this contributor, making them relevant to the present execution-key behavior. citeturn229698view0turn463602view0. (role: recent cron runtime contributor; confidence: medium; commits: 6363094, b98ee01; files: src/cron/isolated-agent/run.ts, src/cron/isolated-agent/session.ts)
    • vincentkoc: History ties this contributor to per-agent model defaults and isolated-run type extraction near the model-selection and persistence surface. citeturn229698view0turn463602view0. (role: cron model and run-state contributor; confidence: medium; commits: c96a12a, a81dc15; files: src/cron/isolated-agent/run.ts, src/cron/isolated-agent/run-types.ts)
    How this review workflow works
    • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
    • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
    • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
    • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
    • Maintainers can also comment @clawsweeper review to request a fresh review only.
    • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
    • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
    • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.
  3. steipete commented on Jul 18, 2026

    @steipete
    Contributor

    Maintainer verification: I cannot reproduce a cron-to-parent model leak on current main, and the current persistence/event paths do not contain a parent write for a literal isolated job.

    Live proof used the official OpenAI API through an isolated QA environment:

    • Gateway: loopback-only, fresh state/config, custom port 36155.
    • Main WebChat session: agent:main:main, model openai/gpt-5.6-luna.
    • Cron job: recurring every, sessionTarget: isolated, payload model openai/gpt-5.6-sol, strict fallback list, delivery disabled.
    • Two real forced cron runs both completed ok and attributed openai/gpt-5.6-sol in run history.
    • After each cron run, the main session kept the same session ID, model provider/model, and updatedAt value.
    • A subsequent real WebChat turn on the same main session still ran and projected as openai/gpt-5.6-luna.

    The tested relevant source at 13ae897cfbd7 is byte-identical in the cron/session/UI model-routing files to current main at cb5070101e94.

    Source audit also found no reverse-compaction path: literal isolated jobs enter Gateway execution as cron:<jobId>, persist under agent:<agentId>:cron:<jobId>, and emit the cron run key. WebChat derives its picker from the selected session key and rejects nonmatching cron events. The reported v2026.7.1 standard Gateway path already used the same literal-isolated cron key, so the older explicit-session collision does not explain these reproduction steps.

    Closing as not reproducible/currently unsupported by the persistence boundary. If this still reproduces on a current build, please reopen with redacted output for cron.get, sessions.describe for both main and cron keys before/after, and the outer agent-event sessionKey; those distinguish a stored-row bug from a projection or UI-cache issue.

  4. locked as resolved and limited conversation to collaborators on Sep 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1High-priority user-facing bug, regression, or broken workflow.clawsweeper:needs-maintainer-reviewClawSweeper marked this issue as needing maintainer review before automation.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.impact:auth-providerAuth, provider routing, model choice, or SecretRef resolution may break.impact:session-stateSession, memory, transcript, context, or agent state can drift or corrupt.issue-rating: 🦪 silver shellfishThin issue quality; more reproduction proof or environment detail is needed.

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions