#765·llm_wiki

Chat agent panics on MiniMax Anthropic endpoints: HeaderName::from_static with invalid bytes — every chat message silently fails

Author: shanhe114Created Sep 17, 2026Updated Sep 17, 2026

Bug Description

When the main/chat LLM is configured with an Anthropic-compatible MiniMax endpoint (api.minimaxi.com / api.minimax.io), every chat message fails silently: the UI stalls after "规划下一步 / planning next step" with no assistant reply, no error shown, and nothing written to .llm-wiki/chats/*.json (user messages only).

The Rust chat-agent backend panics while building the request headers:

thread 'tokio-rt-worker' panicked at .../http-1.4.0/src/header/name.rs:1254:13:
HeaderName::from_static with invalid bytes

The panic kills the tokio worker task, so the HTTP request never completes and the UI waits forever.

Root Cause

In src-tauri/src/agent/provider.rs, anthropic_headers() (around line 655):

rust
let name = if requires_bearer_auth(url) {
    "Authorization"
} else {
    "x-api-key"
};
...
headers.insert(
    HeaderName::from_static(name),   // <-- panics here
    ...
);

requires_bearer_auth() returns true for any URL containing minimax.io / minimaxi.com:

rust
fn requires_bearer_auth(url: &str) -> bool {
    let lower = url.to_ascii_lowercase();
    lower.contains("minimax.io") || lower.contains("minimaxi.com")
}

HeaderName::from_static only accepts lowercase header names; "Authorization" contains an uppercase A, so it panics with "invalid bytes". Verified with http 1.4.0 (same version as the shipped binary): HeaderName::from_static("Authorization") panics, while the headers.insert("Authorization", ...) path used by openai_headers() works fine.

Reproduction

  1. Settings → LLM: provider custom, apiMode anthropic_messages, endpoint https://api.minimaxi.com/anthropic (the documented MiniMax Anthropic-compatible URL), any model.
  2. Send any chat message.
  3. Result: generation stalls indefinitely; terminal output shows the panic. 100% reproducible (10/10 messages failed in my case).

Note: ingest/wiki generation still works because it goes through the TypeScript frontend fetch path, not the Rust agent backend — only Chat is affected.

Environment

  • LLM Wiki v0.6.11 (macOS aarch64, also affects all platforms — the bug is in the Rust backend)
  • http crate 1.4.0

Suggested Fix

One-line change in provider.rs (~line 645):

rust
let name = if requires_bearer_auth(url) {
    "authorization"   // lowercase — from_static safe
} else {
    "x-api-key"
};

Alternatively use HeaderName::from_bytes(name.as_bytes()) or headers.insert(name, ...) via the &str IntoHeaderName path, which handles case correctly.

Workaround for Users (until fixed)

Switch the Chat LLM preset to a non-MiniMax provider, or change the MiniMax preset to chat_completions mode with the OpenAI-compatible endpoint https://api.minimaxi.com/v1 (the openai_headers() path does not hit this bug).