Skip to content

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

@BigPotty

Description

@BigPotty

Bug Report: agents.defaults.subagents.model Config Ignored in Cron Isolated Sessions

Date: February 7, 2026 Reporter: Sebastian (AI Agent) Affected Versions: 2026.2.3, 2026.2.6-3 Investigation Time: ~3 hours

================================================================================ SUMMARY
The agents.defaults.subagents.model configuration parameter is completely ignored when spawning isolated cron sessions. All isolated sessions default to the main agent model instead of respecting the subagent model configuration.

================================================================================ ENVIRONMENT
OpenClaw Version: 2026.2.6-3 (also present in 2026.2.3)
Platform: macOS 26.2 (arm64)
Node: v25.5.0
Installation: Git (~/openclaw)
================================================================================ EXPECTED BEHAVIOR
When creating cron jobs with sessionTarget: "isolated", the spawned sessions should use the model specified in agents.defaults.subagents.model as their default.

Example config: { "agents": { "defaults": { "model": { "primary": "anthropic/claude-sonnet-4-5" }, "subagents": { "model": "ollama/llama3.2:3b" } } } }

Expected: Isolated cron sessions use ollama/llama3.2:3b Actual: Isolated cron sessions use anthropic/claude-sonnet-4-5

================================================================================ ACTUAL BEHAVIOR
All isolated cron sessions ignore subagents.model and fall back to agents.defaults.model.primary (or the hardcoded default if not set).

================================================================================ REPRODUCTION STEPS
Configure agents.defaults.subagents.model in gateway config: { "agents": { "defaults": { "model": { "primary": "anthropic/claude-sonnet-4-5" }, "subagents": { "model": "ollama/llama3.2:3b" } } } }

Create a cron job with isolated session (no explicit model): openclaw cron add
--name "Test Job"
--schedule "at:2026-02-08T10:00:00-08:00"
--target isolated
--message "Test message"

Let the job run or trigger with: openclaw cron run --id

Check the session transcript or logs

Observed: Session uses anthropic/claude-sonnet-4-5 (not the configured ollama/llama3.2:3b)

================================================================================ ROOT CAUSE
File: src/cron/isolated-agent/run.ts Lines: ~125-145

The resolveConfiguredModelRef function is called with the agent config, but it only checks:

cfg.agents.defaults.model.primary (or .model if string)
Falls back to DEFAULT_MODEL if not set
It never checks cfg.agents.defaults.subagents.model.

Relevant code:

// Line ~125: Agent config is copied but subagents.model is never used const agentCfg: AgentDefaultsConfig = Object.assign( {}, params.cfg.agents?.defaults, agentOverrideRest as Partial, );

// Line ~145: Only looks at .model.primary, not .subagents.model const resolvedDefault = resolveConfiguredModelRef({ cfg: cfgWithAgentDefaults, defaultProvider: DEFAULT_PROVIDER, // "anthropic" defaultModel: DEFAULT_MODEL, // "claude-sonnet-4-5" });

================================================================================ PROPOSED FIX
Add logic to check subagents.model when spawning isolated sessions:

// After line 125, before resolveConfiguredModelRef call:

// For isolated sessions, use subagents.model if configured if (params.job.sessionTarget === "isolated") { const subagentsModel = agentCfg.subagents?.model; if (subagentsModel && typeof subagentsModel === "string") { // Override model.primary with subagents.model for this session agentCfg.model = { primary: subagentsModel }; } }

This respects the intent of the subagents config block: allowing different default models for spawned sessions vs. the main agent.

================================================================================ WORKAROUND
Currently, the only way to use a different model for isolated cron sessions is to specify it explicitly in each job's payload:

openclaw cron add
--name "Test Job"
--model "ollama/llama3.2:3b"
--schedule "..."
--target isolated
--message "..."

Or when updating existing jobs via the cron tool, modify the payload to include "model": "ollama/llama3.2:3b".

================================================================================ IMPACT
Use Case: Running autonomous agents on local models (cost optimization)

Users who want to:

Use premium models (Sonnet/GPT-4) for main interactive sessions
Use free local models (Ollama) for background autonomous agents
Save API costs for scheduled background work
...cannot do so without explicitly specifying the model in every cron job, defeating the purpose of the subagents config.

Cost Impact Example:

4 daily check-ins + 2 weekly check-ins = ~200 cron runs/month
Current: ~$9-15/month (forced to use Sonnet)
Target: $0/month (local Ollama models)
================================================================================ TEST EVIDENCE
Tested 160+ cron runs with various configurations: ❌ subagents.model = "ollama/llama3.2:3b" → Ignored ❌ subagents.model = "local" (alias) → Ignored ❌ subagents.model = "llama3.2:3b" (short form) → Ignored ✅ Explicit "model": "ollama/llama3.2:3b" in job payload → Works

All jobs without explicit model fell back to Sonnet regardless of config.

================================================================================ ADDITIONAL CONTEXT
The model specified in subagents.model IS in the allowlist (verified in agents.defaults.models)
Ollama provider is properly configured and working when models are explicitly specified
Main session correctly uses agents.defaults.model.primary
Only isolated cron sessions are affected
================================================================================ RELATED DOCUMENTATION
From docs/reference/session-management-compaction.md, the subagents config is documented:

"Control spawned sessions (e.g., via sessions_spawn or isolated cron jobs)."

This confirms the intent: subagents config should apply to isolated sessions.

================================================================================

Thank you for OpenClaw! This is a fantastic project. Happy to test any fixes or provide additional information.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions