Hmbown/CodeWhale · error
Kimi native web search exceeded the
Error message
Kimi native web search exceeded the {MAX_NATIVE_SEARCH_TOOL_CALLS}-call safety limit What it means
All Kimi web-search variants share a hard safety cap: at most MAX_NATIVE_SEARCH_TOOL_CALLS (8) tool calls per search request, counted across all rounds, not per round. reserve_native_search_tool_calls adds the round's call count to the running total (checked_add guards overflow) and bails if the total would exceed the cap.
Solutions
- Reduce query breadth so fewer total searches are needed
- Raise MAX_NATIVE_SEARCH_TOOL_CALLS to accommodate multi-round workloads
- Restructure the task into multiple smaller search requests
- Accept the failure and fall back to non-native search
Example fix
// before const MAX_NATIVE_SEARCH_TOOL_CALLS: usize = 8; // after const MAX_NATIVE_SEARCH_TOOL_CALLS: usize = 12; // allow 2 rounds of 6 parallel searches
Defensive patterns
Strategy: try-catch
Try / catch
match provider.search(req).await {
Err(e) if e.to_string().contains("-call safety limit") => {
warn!("Kimi search hit the 8-call cap; reducing parallel searches");
provider.search(req.with_fewer_rounds()).await
}
other => other,
} Prevention
- Remember the cap is cumulative across rounds, not per round
- Keep each round's parallel tool-call count small (<= 8 total)
- Raise the constant deliberately with cost/latency review
When it happens
Trigger: search_builtin or search_formula reserves a round whose call count pushes the cumulative total above 8; also exercised directly by test native_search_tool_call_limit_is_total_not_per_round.
Common situations: A model issuing many parallel searches in one round (e.g. two rounds of 5 calls = 10 > 8); very search-hungry queries; a mistaken assumption that the limit resets per round.
Related errors
- Kimi Formula web search exceeded the bounded tool-call loop
- Kimi Formula web search requested an unexpected tool
- Kimi native search requested an unexpected tool
- Kimi native web search exceeded the bounded tool-call loop
- Kimi returned an empty native web-search tool call list
AI-assisted analysis of Hmbown/CodeWhale@73e0f67d83 (2026-09-22).
Data as JSON: /api/errors/2ae4850af7cb0735.
Report an issue: GitHub.
Appendix: source
Thrown at crates/tui/src/client/provider_native_search/kimi.rs:220
)
.await?;
messages.push(json!({
"role": "tool",
"tool_call_id": id,
"content": formula_fiber_result(&fiber)?,
}));
}
}
bail!("Kimi Formula web search exceeded the bounded tool-call loop")
}
fn reserve_native_search_tool_calls(executed: &mut usize, additional: usize) -> Result<()> {
let total = executed
.checked_add(additional)
.context("Kimi native web search tool-call count overflowed")?;
if total > MAX_NATIVE_SEARCH_TOOL_CALLS {
bail!(
"Kimi native web search exceeded the {MAX_NATIVE_SEARCH_TOOL_CALLS}-call safety limit"
);
}
*executed = total;
Ok(())
}
fn formula_web_search_tools(payload: &Value) -> Result<Value> {
let tools = payload
.get("tools")
.and_then(Value::as_array)
.context("Kimi web-search Formula omitted tools")?;
if tools.len() != 1
|| tools[0].get("type").and_then(Value::as_str) != Some("function")
|| tools[0].pointer("/function/name").and_then(Value::as_str)
!= Some(WEB_SEARCH_FORMULA_FUNCTION)
{
bail!("Kimi web-search Formula returned an unexpected tool declaration");View on GitHub (pinned to 73e0f67d83)