Skip to main content

resolve_agent_model_slug

Function resolve_agent_model_slug 

Source
pub fn resolve_agent_model_slug(
    agents_dir: &Path,
    agent_name: &str,
    model_override: Option<&str>,
) -> String
Expand description

Resolve an agent’s model slug, honouring an optional per-run override (#1035, #1475 bug 1 fix’s prerequisite).

Why: InProcessAgentRunner resolves the engineer’s model internally and does not expose it, so pricing the engineer’s turns against its OWN model (rather than blending everything under the PM model — the #1475 bug) needs this same resolution done independently, here, purely for the pricing step. Shared with the daemon path (task::executor’s own resolve_engineer_model, which now delegates here) so the two paths can never independently drift on how per-role pricing resolves a model. What: loads <agents_dir>/<agent_name>.toml; on any load failure (missing/invalid file) falls back to the literal string "unknown" — crate::perf::cost_usd degrades gracefully (Sonnet-equivalent pricing) for an unrecognised model rather than erroring, so a missing agent config degrades pricing accuracy, not the whole run. When model_override is Some, it wins over the config’s own model (mirrors RunContext’s override precedence). Test: run_task::tests::resolve_agent_model_slug_falls_back_when_config_missing, run_task::tests::resolve_agent_model_slug_honours_override.