{"record":{"id":"3ae274fefc043dda","repo":"Hmbown/CodeWhale","slug":"kimi-web-search-formula-fiber-did-not-succeed","errorCode":null,"errorMessage":"Kimi web-search Formula fiber did not succeed","messagePattern":"Kimi web-search Formula fiber did not succeed","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tui/src/client/provider_native_search/kimi.rs","lineNumber":245,"sourceCode":"\nfn formula_web_search_tools(payload: &Value) -> Result<Value> {\n    let tools = payload\n        .get(\"tools\")\n        .and_then(Value::as_array)\n        .context(\"Kimi web-search Formula omitted tools\")?;\n    if tools.len() != 1\n        || tools[0].get(\"type\").and_then(Value::as_str) != Some(\"function\")\n        || tools[0].pointer(\"/function/name\").and_then(Value::as_str)\n            != Some(WEB_SEARCH_FORMULA_FUNCTION)\n    {\n        bail!(\"Kimi web-search Formula returned an unexpected tool declaration\");\n    }\n    Ok(Value::Array(tools.clone()))\n}\n\nfn formula_fiber_result(payload: &Value) -> Result<&str> {\n    if payload.get(\"status\").and_then(Value::as_str) != Some(\"succeeded\") {\n        bail!(\"Kimi web-search Formula fiber did not succeed\");\n    }\n    payload\n        .pointer(\"/context/output\")\n        .or_else(|| payload.pointer(\"/context/encrypted_output\"))\n        .and_then(Value::as_str)\n        .map(str::trim)\n        .filter(|result| !result.is_empty())\n        .context(\"Kimi web-search Formula fiber omitted its result\")\n}\n\nfn builtin_search_tools() -> Value {\n    json!([{\n        \"type\": \"builtin_function\",\n        \"function\": { \"name\": \"$web_search\" }\n    }])\n}\n\nfn parse_kimi_code(payload: &Value) -> ProviderNativeSearchResponse {","sourceCodeStart":227,"sourceCodeEnd":263,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/client/provider_native_search/kimi.rs#L227-L263","documentation":"The Kimi Formula flow runs the web-search function as a fiber (server-side execution). After awaiting the fiber, the client checks payload.status == \"succeeded\" before reading the output; a failed, pending, or unrecognized status means no usable search result, so it bails. On success it extracts /context/output or /context/encrypted_output as a string.","triggerScenarios":"formula_fiber_result receives a fiber payload whose status field is absent or anything other than \"succeeded\" (e.g. \"failed\", \"running\", \"timeout\").","commonSituations":"Upstream Kimi fiber execution failure (search backend outage); polling too early while the fiber is still running; a payload schema change moving/renaming the status or output fields.","solutions":["Log the full fiber payload to see the actual status/error detail","If status is transient (running/queued), poll/await the fiber to completion before reading the result","Retry the search request if the fiber failed due to a transient upstream issue","Update the status/output field extraction if the Kimi fiber schema changed"],"exampleFix":"// before\nif payload.get(\"status\").and_then(Value::as_str) != Some(\"succeeded\") {\n    bail!(\"Kimi web-search Formula fiber did not succeed\");\n}\n// after: include the upstream status in the error\nlet status = payload.get(\"status\").and_then(Value::as_str).unwrap_or(\"<missing>\");\nif status != \"succeeded\" {\n    bail!(\"Kimi web-search Formula fiber did not succeed (status: {status})\");\n}","handlingStrategy":"retry","validationCode":"// inspect status before extracting output\nlet status = payload.get(\"status\").and_then(Value::as_str).unwrap_or(\"<missing>\");\nif status != \"succeeded\" { eprintln!(\"fiber status: {status}\"); }","typeGuard":"fn fiber_succeeded(payload: &Value) -> bool {\n    payload.get(\"status\").and_then(Value::as_str) == Some(\"succeeded\")\n}","tryCatchPattern":"match fiber_result {\n    Err(e) if e.to_string().contains(\"did not succeed\") => {\n        // transient upstream failure: retry once, then give up\n        tokio::time::sleep(Duration::from_secs(2)).await;\n        retry_search(req).await\n    }\n    other => other,\n}","preventionTips":["Await/poll fibers to terminal state before reading output","Log the full fiber payload on failure for upstream diagnosis","Monitor Z.AI/Kimi status for search-backend incidents"],"tags":["kimi","formula","fiber","async-execution"],"backgroundTag":"upstream-api-error","analyzedSha":"73e0f67d83c59909b571efdfc88c4bc28c309cb1","analyzedAt":"2026-09-22T01:30:00.501Z","contentChangedAt":"2026-09-22T01:30:00.501Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}