zeroclaw-labs/zeroclaw · error · anyhow::Error

agents.{agent_alias}.model_provider = "{agent_ref}" does not

Error message

agents.{agent_alias}.model_provider = "{agent_ref}" does not resolve to a configured [providers.models.<type>.<alias>] entry

What it means

Under the V3 config schema every agent's model_provider must be a "<type>.<alias>" reference that resolves to an existing [providers.models.<type>.<alias>] table. During agent construction (resolved_model_provider_for_agent returning None with a non-empty ref), ZeroClaw bails rather than guessing a provider — a dangling reference is treated as a hard config error, not a silent fallback.

Source

Thrown at crates/zeroclaw-runtime/src/agent/agent.rs:1566

            // None for the runtime profile and silently falls back to the
            // schema default of 20 actions/hour regardless of config.
            let mut policy = SecurityPolicy::for_agent(config, agent_alias).with_context(|| {
                format!("agents.{agent_alias}: failed to build security policy")
            })?;
            if let Some(cwd) = session_cwd {
                policy.workspace_dir = cwd.to_path_buf();
                policy.allowed_roots.push(agent_workspace.clone());
            }
            policy
        });

        let (provider_name, provider_alias, agent_model_provider) =
            match config.resolved_model_provider_for_agent(agent_alias) {
                Some(resolved) => (resolved.0, resolved.1, Some(resolved.2)),
                None => {
                    let agent_ref = agent_cfg.model_provider.as_str();
                    if !agent_ref.is_empty() {
                        anyhow::bail!(
                            "agents.{agent_alias}.model_provider = \"{agent_ref}\" does not \
                             resolve to a configured [providers.models.<type>.<alias>] entry"
                        );
                    }
                    // V3 schema requires every agent to set model_provider.
                    // Empty is a config error rather than a silent fallback.
                    anyhow::bail!(
                        "agents.{agent_alias}.model_provider is empty — set it to a \
                         configured \"<type>.<alias>\" (e.g. \"anthropic.{agent_alias}\")"
                    );
                }
            };
        let memory: Arc<dyn Memory> = zeroclaw_memory::create_memory_for_agent(
            config,
            agent_alias,
            agent_model_provider.and_then(|e| e.api_key.as_deref()),
        )
        .await?;

View on GitHub (pinned to 88bb9c8533)

Solutions

  1. Compare the reference string character-by-character with the table header [providers.models.<type>.<alias>].
  2. Add the missing [providers.models.<type>.<alias>] table with at least a model key.
  3. Run ZeroClaw's config validation/doctor command to catch every dangling agent ref at once.
  4. If you renamed an alias, update every agents.<alias>.model_provider that referenced the old name.

Example fix

# before — reference does not match the table name
[providers.models.anthropic.default]
model = "claude-sonnet-4-5"

[agents.helper]
model_provider = "anthropic.main"

# after
[agents.helper]
model_provider = "anthropic.default"
Defensive patterns

Strategy: validation

Validate before calling

// Startup lint: every agent ref must resolve
for (alias, agent) in &config.agents {
    let r = agent.model_provider.as_str();
    anyhow::ensure!(
        !r.is_empty() && config.resolved_model_provider_for_agent(alias).is_some(),
        "agents.{alias}.model_provider '{r}' does not resolve"
    );
}

Prevention

When it happens

Trigger: model_provider = "anthropic.main" while the table is [providers.models.anthropic.default]; typo in either the type or alias segment; the [providers.models.*] table missing entirely; V2-era configs referencing a bare provider name.

Common situations: Renaming a provider alias without updating agents that point at it; migrating from an older schema where agents referenced providers differently; config split across files and the models table never gets included.

Related errors


AI-assisted analysis of zeroclaw-labs/zeroclaw@88bb9c8533 (2026-08-23). Data as JSON: /api/errors/0fd021452eecd629. Report an issue: GitHub.