Hmbown/CodeWhale · error

{} model {:?} uses {:?}, but this client is bound to {:?} an

Error message

{} model {:?} uses {:?}, but this client is bound to {:?} and no configuration is available to rebuild it

What it means

`rebound_for_model_protocol` handles providers whose wire policy is `ModelAware` — different models on the same provider can speak different wire protocols (OpenAI Responses vs Anthropic Messages vs ChatCompletions). When the central route resolver maps the requested model to a protocol different from the client's construction-time `wire_format`, the client must be rebuilt via `Self::from_candidate(config, ...)`. This error fires when a rebind is required but the caller passed `config: None`, so there is nothing to rebuild from. In practice this is hit from the subagent runtime (`tools/subagent/mod.rs`), which passes `child_runtime.api_config`.

Source

Thrown at crates/tui/src/client.rs:1290

        if !model_aware {
            return Ok(None);
        }
        static RESOLVER: OnceLock<RouteResolver> = OnceLock::new();
        let candidate = RESOLVER
            .get_or_init(RouteResolver::new)
            .resolve(&RouteRequest {
                explicit_provider: self.api_provider.kind(),
                model_selector: Some(LogicalModelRef::from(model)),
                saved_provider_model: None,
                base_url_override: Some(self.base_url.clone()),
                limit_overrides: Vec::new(),
            })
            .map_err(anyhow::Error::msg)?;
        if candidate.protocol() == self.wire_format {
            return Ok(None);
        }
        let config = config.ok_or_else(|| {
            anyhow::anyhow!(
                "{} model {:?} uses {:?}, but this client is bound to {:?} and no configuration is available to rebuild it",
                self.api_provider.display_name(),
                model,
                candidate.protocol(),
                self.wire_format
            )
        })?;
        Self::from_candidate(config, &candidate).map(Some)
    }

    fn bind_request_to_protocol(&self, mut request: MessageRequest) -> Result<MessageRequest> {
        let model_aware = self.api_provider.metadata().is_some_and(|provider| {
            provider.wire_policy() == codewhale_config::provider::WirePolicy::ModelAware
        });
        if !model_aware {
            return Ok(request);
        }

View on GitHub (pinned to 8880682c63)

Solutions

  1. Ensure the runtime executing the model carries the loaded configuration (pass the `Config` through so `rebound_for_model_protocol` receives `Some(config)`).
  2. As a workaround, pin the subagent/child model to one whose resolved protocol matches the client's existing wire binding, so no rebind is needed.
  3. If you control the provider definition, avoid mixing wire protocols under one ModelAware provider, or verify the model-to-protocol mapping in the route resolver configuration.

Example fix

// before
let client = client.rebound_for_model_protocol(None, &model)?;
// after
let client = client.rebound_for_model_protocol(Some(&config), &model)?;
Defensive patterns

Strategy: fallback

Validate before calling

// Before selecting a cross-protocol model for a child runtime, ensure a Config is available.
if client_needs_rebind(provider, model)? && child_runtime.api_config.is_none() {
    // fall back to the parent's current model instead of failing the send
    effective_model = parent_model.clone();
}

Type guard

fn is_model_aware(provider: ApiProvider) -> bool {
    provider.metadata().is_some_and(|m| m.wire_policy() == WirePolicy::ModelAware)
}

Try / catch

match client.rebound_for_model_protocol(config.as_ref(), &model) {
    Ok(Some(rebound)) => use(rebound),
    Ok(None) => use(client),          // already correct binding
    Err(e) if e.to_string().contains("no configuration is available") => {
        // degrade gracefully: keep the existing binding / parent model
        fall_back_to_parent_binding();
    }
    Err(e) => return Err(e),
}

Prevention

When it happens

Trigger: Launching a subagent (or any code path calling `rebound_for_model_protocol(None, model)`) whose effective model resolves to a different wire protocol than the parent client's binding — e.g. a ModelAware provider where model A is chat-completions and model B is responses — while the child runtime was created without an `api_config`.

Common situations: Custom ModelAware provider definitions where a subagent's model selector crosses protocol families; a programmatic embedding that constructs a client and calls subagent tooling without threading the loaded `Config` through; version drift where an older caller site was not yet updated to pass the config.

Related errors


AI-assisted analysis of Hmbown/CodeWhale@8880682c63 (2026-08-16). Data as JSON: /api/errors/9eb41326fbd2c569. Report an issue: GitHub.