Skip to content

fix(cron): respect subagents.model in isolated cron sessions#11474

Merged
Takhoffman merged 3 commits intoopenclaw:mainfrom
AnonO6:fix/cron-subagent-model
Mar 1, 2026
Merged

fix(cron): respect subagents.model in isolated cron sessions#11474
Takhoffman merged 3 commits intoopenclaw:mainfrom
AnonO6:fix/cron-subagent-model

Conversation

@AnonO6
Copy link
Copy Markdown
Contributor

@AnonO6 AnonO6 commented Feb 7, 2026

Summary

Fixes #11461

agents.defaults.subagents.model is ignored when spawning isolated cron sessions. All isolated sessions fall back to agents.defaults.model.primary, regardless of the subagents config. This means users can't use cheaper local models (e.g. Ollama) for background cron work while keeping premium models for interactive sessions.

lobster-biscuit

Repro Steps

  1. Configure agents.defaults.subagents.model to a different model than the main agent model:
    {
      "agents": {
        "defaults": {
          "model": { "primary": "anthropic/claude-sonnet-4-5" },
          "subagents": { "model": "ollama/llama3.2:3b" }
        }
      }
    }
  2. Create a cron job with sessionTarget: "isolated" (no explicit --model)
  3. Run the job
  4. Observe the session uses anthropic/claude-sonnet-4-5 instead of ollama/llama3.2:3b

Root Cause

In src/cron/isolated-agent/run.ts, resolveConfiguredModelRef() only checks cfg.agents.defaults.model.primary and never checks cfg.agents.defaults.subagents.model. The correct pattern already exists in sessions-spawn-tool.ts which properly resolves subagent models.

Behavior Changes

  • Isolated cron sessions now respect agents.defaults.subagents.model (and per-agent subagents.model) when selecting the default model.
  • Precedence chain: explicit job model > gmail hook model > subagents.model > main model.
  • No change when subagents.model is not configured (falls back to main model as before).
  • Extracted normalizeModelSelection from sessions-spawn-tool.ts into shared model-selection.ts to avoid duplication.

Codebase and GitHub Search

Tests

  • 4 new integration tests (isolated-agent.subagent-model.test.ts):
    • Uses subagents.model when set (string format)
    • Explicit job model override takes precedence over subagents.model
    • Falls back to main model when subagents.model is unset
    • Supports {primary} object format for subagents.model
  • 5 new unit tests (model-selection.test.ts): normalizeModelSelection utility coverage
  • All 963 test files / 6523 tests pass

Manual Testing

N/A — fully covered by automated tests.

Sign-Off

  • Models used: Claude (AI-assisted)
  • Submitter effort: read issue, traced code, implemented fix + tests, ran full gate
  • Agent notes: The fix mirrors the existing sessions-spawn-tool.ts pattern. normalizeModelSelection was extracted to a shared module to avoid duplication.

Made with Cursor

Greptile Overview

Greptile Summary

This change fixes isolated cron sessions to respect agents.defaults.subagents.model (and per-agent subagents.model) when choosing the default model, matching the existing behavior in sessions-spawn-tool.ts. To avoid duplication, it extracts normalizeModelSelection into src/agents/model-selection.ts and adds unit + integration coverage for the new resolution behavior.

Confidence Score: 3/5

  • This PR is close to mergeable but has a model-allowlist enforcement gap in cron isolated sessions.
  • Core change is small and well-tested, but the new subagents.model resolution path in runCronIsolatedAgentTurn does not enforce the model allowlist in the way the explicit job override does, which can lead to running disallowed models in allowlist configurations.
  • src/cron/isolated-agent/run.ts

Context used:

  • Context from dashboard - CLAUDE.md (source)
  • Context from dashboard - AGENTS.md (source)

@openclaw-barnacle openclaw-barnacle Bot added the agents Agent runtime and tooling label Feb 7, 2026
Copy link
Copy Markdown
Contributor

@greptile-apps greptile-apps Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 file reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

Comment thread src/cron/isolated-agent/run.ts Outdated
@AnonO6
Copy link
Copy Markdown
Contributor Author

AnonO6 commented Feb 7, 2026

FIx — the subagent model was bypassing the allowlist.

Fixed: replaced resolveModelRefFromString with resolveAllowedModelRef (same function used by the explicit job model override path). Now subagents.model is validated against agents.defaults.models allowlist — if the model isn't allowed, it's silently skipped and the main model is used instead.

See commit cc79abf31.

@openclaw-barnacle
Copy link
Copy Markdown

This pull request has been automatically marked as stale due to inactivity.
Please add updates or it will be closed.

@openclaw-barnacle openclaw-barnacle Bot added stale Marked as stale due to inactivity and removed stale Marked as stale due to inactivity labels Feb 21, 2026
@Takhoffman Takhoffman force-pushed the fix/cron-subagent-model branch from cc79abf to f71a19c Compare March 1, 2026 13:54
@Takhoffman Takhoffman merged commit d0ca02e into openclaw:main Mar 1, 2026
8 checks passed
@Takhoffman
Copy link
Copy Markdown
Contributor

Autoland update: fixed integration issues discovered during gate execution, reran full default verification, and merged.

What was fixed while landing:

  • Removed duplicate normalizeModelSelection export that caused build/type errors after rebase.
  • Updated cron isolated-subagent-model test fixtures to match current CliDeps and CronJob contract (sendMessageSlack, name).
  • Verified subagents.model string + object-form ({ primary: ... }) resolution path remains covered.

Verification run (worktree .worktrees/pr-11474):

  • pnpm install --frozen-lockfile
  • pnpm build
  • pnpm check
  • pnpm test:macmini

All checks passed before merge.

zooqueen added a commit to hanzoai/bot that referenced this pull request Mar 1, 2026
steipete pushed a commit to Sid-Qin/openclaw that referenced this pull request Mar 2, 2026
…w#11474)

* fix(cron): respect subagents.model in isolated cron sessions

* fix(cron): enforce model allowlist for subagents.model

* Cron: fix isolated subagent model gate regressions

---------

Co-authored-by: Tak Hoffman <781889+Takhoffman@users.noreply.github.com>
safzanpirani pushed a commit to safzanpirani/clawdbot that referenced this pull request Mar 2, 2026
…w#11474)

* fix(cron): respect subagents.model in isolated cron sessions

* fix(cron): enforce model allowlist for subagents.model

* Cron: fix isolated subagent model gate regressions

---------

Co-authored-by: Tak Hoffman <781889+Takhoffman@users.noreply.github.com>
hanqizheng pushed a commit to hanqizheng/openclaw that referenced this pull request Mar 2, 2026
…w#11474)

* fix(cron): respect subagents.model in isolated cron sessions

* fix(cron): enforce model allowlist for subagents.model

* Cron: fix isolated subagent model gate regressions

---------

Co-authored-by: Tak Hoffman <781889+Takhoffman@users.noreply.github.com>
execute008 pushed a commit to execute008/openclaw that referenced this pull request Mar 2, 2026
…w#11474)

* fix(cron): respect subagents.model in isolated cron sessions

* fix(cron): enforce model allowlist for subagents.model

* Cron: fix isolated subagent model gate regressions

---------

Co-authored-by: Tak Hoffman <781889+Takhoffman@users.noreply.github.com>
zooqueen added a commit to hanzoai/bot that referenced this pull request Mar 6, 2026
zooqueen pushed a commit to hanzoai/bot that referenced this pull request Mar 6, 2026
…w#11474)

* fix(cron): respect subagents.model in isolated cron sessions

* fix(cron): enforce model allowlist for subagents.model

* Cron: fix isolated subagent model gate regressions

---------

Co-authored-by: Tak Hoffman <781889+Takhoffman@users.noreply.github.com>
Mateljan1 pushed a commit to Mateljan1/openclaw that referenced this pull request Mar 7, 2026
…w#11474)

* fix(cron): respect subagents.model in isolated cron sessions

* fix(cron): enforce model allowlist for subagents.model

* Cron: fix isolated subagent model gate regressions

---------

Co-authored-by: Tak Hoffman <781889+Takhoffman@users.noreply.github.com>
lovewanwan pushed a commit to lovewanwan/openclaw that referenced this pull request Apr 28, 2026
…w#11474)

* fix(cron): respect subagents.model in isolated cron sessions

* fix(cron): enforce model allowlist for subagents.model

* Cron: fix isolated subagent model gate regressions

---------

Co-authored-by: Tak Hoffman <781889+Takhoffman@users.noreply.github.com>
ogt-redknie pushed a commit to ogt-redknie/OPENX that referenced this pull request May 2, 2026
…w#11474)

* fix(cron): respect subagents.model in isolated cron sessions

* fix(cron): enforce model allowlist for subagents.model

* Cron: fix isolated subagent model gate regressions

---------

Co-authored-by: Tak Hoffman <781889+Takhoffman@users.noreply.github.com>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request May 9, 2026
…w#11474)

* fix(cron): respect subagents.model in isolated cron sessions

* fix(cron): enforce model allowlist for subagents.model

* Cron: fix isolated subagent model gate regressions

---------

Co-authored-by: Tak Hoffman <781889+Takhoffman@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling size: M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: agents.defaults.subagents.model config ignored in cron isolated sessions

2 participants