Hmbown/CodeWhale · error

Fleet task references unknown agent profile selector

Error message

Fleet task {} references unknown agent profile selector {selector:?}

What it means

A fleet task's worker.agent_profile selector was resolved but no agent profile with that id/selector exists in the session's profile set. resolve_task_agent_profile looks up the selector after validating its syntax; the bail fires when the lookup returns None, meaning the task references a profile that has not been defined.

Solutions

  1. Run the profile validation path (validate_task_agent_profiles) and fix the selector spelling to match a defined profile id.
  2. Add the missing agent profile definition to the session config.
  3. Remove the worker.agent_profile field from the task so it inherits the default route.
  4. Validate all task profile references at config load with the same resolver used at runtime.

Example fix

// before
[task.research]
worker.agent_profile = "deep-reserch"
// after
[task.research]
worker.agent_profile = "deep-research"
Defensive patterns

Strategy: validation

Validate before calling

fn profile_exists(profiles: &[AgentProfile], selector: &str) -> bool {
    profiles.iter().any(|p| p.matches_selector(selector.trim()))
}

Type guard

fn resolve<'a>(profiles: &'a [AgentProfile], sel: &str) -> Option<&'a AgentProfile> {
    profiles.iter().find(|p| p.id == sel.trim())
}

Try / catch

match resolve_task_agent_profile(&task, &profiles) {
    Err(e) if e.to_string().contains("unknown agent profile") => {
        eprintln!("task {}: profile {:?} not defined; available: {:?}", task.id, sel, ids); }
    other => other?,
}

Prevention

When it happens

Trigger: Any call chain through resolve_task_agent_profile (validate_task_agent_profiles, validate_fleet_task_routes, validate_fleet_reasoning_effort, fleet_task_to_worker_spec_with_profiles, resolve_fleet_route_with_config, resolve_fleet_route_from_worker_report) with a task_spec whose worker.agent_profile names a selector absent from the loaded profile registry (after trimming, per the underlying selector parser).

Common situations: Typo or case mismatch in the agent_profile name in the fleet config; profile deleted or renamed while tasks still reference it; profile defined in a different config file that was not loaded; copy-pasting a fleet config between machines with different profile sets.

Understand the failure class

Background: "Not found" and "does not exist" errors: why "Task not found", "No such folder", and "Can't find" fire when a lookup comes back empty — this error's family across 14 libraries.

Related errors


AI-assisted analysis of Hmbown/CodeWhale@73e0f67d83 (2026-09-22). Data as JSON: /api/errors/fd1313d0ad76aa4b. Report an issue: GitHub.

Appendix: source

Thrown at crates/tui/src/fleet/worker_runtime.rs:1001

        return Ok(Some(Cow::Owned(snapshot.into_profile()?)));
    }
    let Some(worker) = task_spec.worker.as_ref() else {
        return Ok(None);
    };
    if let Some(selector) = worker
        .agent_profile
        .as_deref()
        .map(str::trim)
        .filter(|selector| !selector.is_empty())
    {
        let profile = resolve_member_in_profiles(agent_profiles, selector).map_err(|error| {
            anyhow::anyhow!(
                "Fleet task {} has invalid worker.agent_profile selector {selector:?}: {error}",
                task_spec.id
            )
        })?;
        let Some(profile) = profile else {
            bail!(
                "Fleet task {} references unknown agent profile selector {selector:?}",
                task_spec.id
            );
        };
        validate_selected_member_model(task_spec, profile)?;
        return Ok(Some(Cow::Borrowed(profile)));
    }

    let Some(selector) = worker
        .role
        .as_deref()
        .map(str::trim)
        .filter(|selector| !selector.is_empty())
    else {
        return Ok(None);
    };
    // `worker.role` predates human member selectors. Resolve it only when one
    // member is deterministic; an ambiguous/missing roster match remains the

View on GitHub (pinned to 73e0f67d83)