openclaw - 💡(How to fix) Fix Cron sessions permanently cache fallback model in sessions.json [1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#61573Fetched 2026-04-08 02:57:08
View on GitHub
Comments
0
Participants
1
Timeline
0
Reactions
0
Participants

Fix Action

Workaround

Periodically clear the model field from cron session keys in sessions.json:

# Clear cached model from all cron session keys
for key, val in data.items():
    if ':cron:' in key and 'model' in val:
        del val['model']

Code Example

# Clear cached model from all cron session keys
for key, val in data.items():
    if ':cron:' in key and 'model' in val:
        del val['model']
RAW_BUFFERClick to expand / collapse

Bug Description

When a cron job fires and the primary model (e.g., anthropic/claude-sonnet-4-6) is temporarily unavailable, OpenClaw correctly falls back through the model chain. However, the fallback model gets permanently cached in the session's model field in agents/<agent>/sessions/sessions.json.

On subsequent cron runs — even after the primary model is available again — the session uses the cached fallback model instead of the model configured in the cron job's payload.model field.

Steps to Reproduce

  1. Create a cron job with payload.model: anthropic/claude-sonnet-4-6
  2. Wait for a run where Anthropic is unavailable and the fallback chain kicks in (e.g., to openai-codex/gpt-5.4-mini)
  3. Observe that sessions.json now has "model": "gpt-5.4-mini" for that cron's session key
  4. On the next run, even with Anthropic back online, the cron continues using gpt-5.4-mini

Expected Behavior

Cron jobs should always use the model specified in their payload.model configuration, regardless of what model was cached from a previous run's fallback.

Actual Behavior

The cached fallback model in sessions.json takes precedence over the cron's configured model permanently.

Impact

  • Jobs silently run on wrong models (potentially consuming paid API credits instead of flat-rate Anthropic)
  • Compounds over time — each Anthropic outage infects more session keys
  • No self-healing mechanism — requires manual cleanup of sessions.json

Workaround

Periodically clear the model field from cron session keys in sessions.json:

# Clear cached model from all cron session keys
for key, val in data.items():
    if ':cron:' in key and 'model' in val:
        del val['model']

Environment

  • OpenClaw: 2026.4.2
  • Model chain: anthropic/claude-opus-4-6 → anthropic/claude-sonnet-4-6 → openai-codex/gpt-5.4-mini → openrouter/google/gemini-3-flash-preview

extent analysis

TL;DR

Clear the cached model from cron session keys in sessions.json to ensure the correct model is used for each job.

Guidance

  • Identify and clear the model field from all cron session keys in sessions.json using the provided Python snippet to prevent permanent caching of fallback models.
  • Verify that the model field is being updated correctly in sessions.json after clearing the cache to ensure the fix is working as expected.
  • Consider implementing a periodic task to automatically clear the model field from cron session keys to prevent future issues.
  • Review the model chain configuration to ensure that the fallback models are correctly specified and prioritized.

Example

# Clear cached model from all cron session keys
for key, val in data.items():
    if ':cron:' in key and 'model' in val:
        del val['model']

Notes

This workaround assumes that the sessions.json file is accessible and modifiable. If the file is not accessible, alternative solutions may be necessary.

Recommendation

Apply the workaround by periodically clearing the model field from cron session keys in sessions.json to prevent permanent caching of fallback models and ensure the correct model is used for each job. This is necessary because the current implementation does not automatically update the model field when the primary model becomes available again.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

openclaw - 💡(How to fix) Fix Cron sessions permanently cache fallback model in sessions.json [1 participants]