Hmbown/CodeWhale · error · anyhow::Error

FIM completion is not supported for {} because the route has

Error message

FIM completion is not supported for {} because the route has no proven FIM wire contract ({:?})

What it means

`DeepSeekClient::fim_completion` calls the DeepSeek `/beta/completions` FIM (fill-in-the-middle) endpoint, and it only trusts that wire contract for direct ChatCompletions routes. It bails up front when the provider is `OpencodeZen` or the wire format is anything other than `ChatCompletions`, because no proven FIM contract exists for those routes. No HTTP request is made; the check fails fast at the client boundary.

Source

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

        reasoning_tokens,
        reasoning_replay_tokens: None,
        server_tool_use,
    }
}

impl DeepSeekClient {
    /// Call the DeepSeek `/beta/completions` FIM endpoint.
    pub async fn fim_completion(
        &self,
        model: &str,
        prompt: &str,
        suffix: &str,
        max_tokens: u32,
    ) -> anyhow::Result<String> {
        if self.api_provider == ApiProvider::OpencodeZen
            || self.wire_format != WireFormat::ChatCompletions
        {
            bail!(
                "FIM completion is not supported for {} because the route has no proven FIM wire contract ({:?})",
                self.api_provider.display_name(),
                self.wire_format
            );
        }
        let url = api_url_with_suffix(&self.base_url, "beta/completions", None);
        let model = wire_model_for_provider_route(self.api_provider, &self.base_url, model);
        let max_tokens = max_tokens.min(self.effective_max_output_tokens(&model));
        let body = json!({
            "model": model,
            "prompt": prompt,
            "suffix": suffix,
            "max_tokens": max_tokens,
        });
        let response = self.send_json_with_retry(&url, &body).await?;
        let status = response.status();
        if !status.is_success() {
            let raw_error_text = bounded_error_text(response, ERROR_BODY_MAX_BYTES).await;

View on GitHub (pinned to 0c42157ee5)

Solutions

  1. Route FIM requests through a dedicated direct DeepSeek (or DeepSeek-compatible) provider configured with `wire_format = "chat-completions"`
  2. Disable FIM/autocomplete for zen and non-ChatCompletions routes instead of calling it
  3. Add a separate provider entry for completion work with its own base_url pointing at DeepSeek directly

Example fix

// before (provider = OpencodeZen -> bail)
let text = client.fim_completion(model, prefix, suffix, 256).await?;

// after: use a direct DeepSeek ChatCompletions client for FIM
let fim_client = deepseek_client_for(base_url, api_key); // wire_format = ChatCompletions
let text = fim_client.fim_completion(model, prefix, suffix, 256).await?;
Defensive patterns

Strategy: validation

Validate before calling

if client.api_provider == ApiProvider::OpencodeZen
    || client.wire_format != WireFormat::ChatCompletions
{
    return Ok(None); // skip FIM on this route
}
let completion = client.fim_completion(model, prefix, suffix, max).await?;

Type guard

fn route_supports_fim(provider: ApiProvider, wire: WireFormat) -> bool {
    provider != ApiProvider::OpencodeZen && wire == WireFormat::ChatCompletions
}

Try / catch

match client.fim_completion(model, prefix, suffix, max).await {
    Ok(text) => insert(text),
    Err(err) if err.to_string().contains("no proven FIM wire contract") => {
        skip_autocomplete(); // expected on zen/non-chat routes
    }
    Err(err) => log_and_disable_autocomplete(err),
}

Prevention

When it happens

Trigger: Invoking `fim_completion(model, prompt, suffix, max_tokens)` when `api_provider == ApiProvider::OpencodeZen`, or when `wire_format` is `AnthropicMessages` / `OpenAiResponses` / any non-ChatCompletions format.

Common situations: Enabling autocomplete/FIM while the default provider routes through opencode zen. Pointing the client at an OpenAI-compatible gateway that negotiates a different wire format. Config entries that inherit the zen provider for the autocomplete lane.

Related errors


AI-assisted analysis of Hmbown/CodeWhale@0c42157ee5 (2026-08-20). Data as JSON: /api/errors/59cd0ce44ac6cfc7. Report an issue: GitHub.