Hmbown/CodeWhale · error
Kimi Formula web search exceeded the bounded tool-call loop
Error message
Kimi Formula web search exceeded the bounded tool-call loop
What it means
The Kimi Formula (K3) web-search flow is a bounded loop: rounds of function fibers are executed and results fed back until the model answers, capped by the shared MAX_NATIVE_SEARCH_TOOL_CALLS budget (8). If the loop runs out of budget while the model keeps requesting fibers, the client bails to prevent unbounded loops and runaway cost.
Solutions
- Narrow or split the search query to reduce required rounds
- Increase MAX_NATIVE_SEARCH_TOOL_CALLS if legitimately needed (watch cost/latency)
- Check for a model-side loop (identical query repeatedly) and consider retrying the request
- Fall back to the built-in native search path or a different model
Example fix
// before
bail!("Kimi Formula web search exceeded the bounded tool-call loop")
// after
bail!("Kimi Formula web search exceeded the bounded tool-call loop after {tool_calls_executed} calls; last query: {last_query}") Defensive patterns
Strategy: fallback
Validate before calling
// estimate rounds and warn early
if expected_rounds * calls_per_round > MAX_NATIVE_SEARCH_TOOL_CALLS { warn!("likely to exceed search budget"); } Try / catch
match provider.search_formula(req).await {
Err(e) if e.to_string().contains("bounded tool-call loop") => {
eprintln!("Formula search exceeded budget; splitting the query");
split_and_search(req).await
}
other => other,
} Prevention
- Split research-style tasks into multiple bounded searches
- Watch for the model re-issuing the same query (loop signature)
- Tune MAX_NATIVE_SEARCH_TOOL_CALLS from observed round counts, not guesses
When it happens
Trigger: search_formula exhausts its loop iterations because the K3 model repeatedly requests web-search fibers and never returns a final answer within the 8-call budget (reserve_native_search_tool_calls rejecting further reservations throws first if the per-round additions exceed the cap).
Common situations: Broad queries requiring many search rounds; a K3 model looping on the same query; budget too small for research-style tasks.
Understand the failure class
Background: "value must be between 0 and 1" / "out of range" / "must not be negative" errors: fixing range-validation failures across open-source libraries — this error's family across 42 libraries.
Related errors
- 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 native web search exceeded the
- 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/8ef38a67919cfd40.
Report an issue: GitHub.
Appendix: source
Thrown at crates/tui/src/client/provider_native_search/kimi.rs:212
.context("Kimi Formula web-search call omitted arguments")?;
let _: Value = serde_json::from_str(arguments)
.context("Kimi Formula web-search arguments were not valid JSON")?;
let fiber = client
.post_json(
&fiber_url,
&json!({ "name": name, "arguments": arguments }),
&[],
)
.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")View on GitHub (pinned to 73e0f67d83)