← Back to PRs

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

by AnonO6 open 2026-02-07 21:29 View on GitHub →
agents stale
#### 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: ```json { "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 - Searched `sessions-spawn-tool.ts` for reference implementation of subagent model resolution. - Verified `resolveConfiguredModelRef` only checks `agents.defaults.model`, confirmed the gap. - Confirmed no existing PRs targeting #11461. #### 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](https://cursor.com) <!-- greptile_comment --> <h2>Greptile Overview</h2> <h3>Greptile Summary</h3> 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. <h3>Confidence Score: 3/5</h3> - 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 <!-- greptile_other_comments_section --> **Context used:** - Context from `dashboard` - CLAUDE.md ([source](https://app.greptile.com/review/custom-context?memory=fd949e91-5c3a-4ab5-90a1-cbe184fd6ce8)) - Context from `dashboard` - AGENTS.md ([source](https://app.greptile.com/review/custom-context?memory=0d0c8278-ef8e-4d6c-ab21-f5527e322f13)) <!-- /greptile_comment -->

Most Similar PRs