{"record":{"id":"40584676ff9449a5","repo":"zeroclaw-labs/zeroclaw","slug":"final-summary-llm-call-timed-out-after-step-secs","errorCode":null,"errorMessage":"Final summary LLM call timed out after {step_secs}s (step_timeout_secs)","messagePattern":"Final summary LLM call timed out after (.+?)s \\(step_timeout_secs\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/zeroclaw-runtime/src/agent/turn/max_iter.rs","lineNumber":150,"sourceCode":"                    tokio::select! {\n                        () = token.cancelled() => SummaryCall::Cancelled,\n                        result = summary_future => SummaryCall::Done(result),\n                    }\n                } else {\n                    SummaryCall::Done(summary_future.await)\n                }\n            }\n        }\n    };\n\n    let resp = match summary_call {\n        SummaryCall::Cancelled => {\n            history.pop();\n            return Err(ToolLoopCancelled.into());\n        }\n        SummaryCall::TimedOut(step_secs) => {\n            history.pop();\n            anyhow::bail!(\"Final summary LLM call timed out after {step_secs}s (step_timeout_secs)\")\n        }\n        SummaryCall::Done(Err(e)) => {\n            ::zeroclaw_log::record!(\n                ERROR,\n                ::zeroclaw_log::Event::new(module_path!(), ::zeroclaw_log::Action::Fail)\n                    .with_category(::zeroclaw_log::EventCategory::Provider)\n                    .with_outcome(::zeroclaw_log::EventOutcome::Failure)\n                    .with_attrs(::serde_json::json!({\n                        \"model\": model,\n                        \"provider\": provider_name,\n                        \"max_iterations\": max_iterations,\n                        \"trace_id\": turn_id,\n                        \"error\": format!(\"{e}\"),\n                    })),\n                \"final summary LLM call failed after iteration exhaustion; bailing\"\n            );\n            history.pop();\n            return Err(e).context(format!(","sourceCodeStart":132,"sourceCodeEnd":168,"githubUrl":"https://github.com/zeroclaw-labs/zeroclaw/blob/88bb9c8533fc57ed7a03e36ca7c9ed2bf8336dcc/crates/zeroclaw-runtime/src/agent/turn/max_iter.rs#L132-L168","documentation":"On the graceful max-iteration exit, ZeroClaw pops in a tools-free 'summarize your work' prompt and sends one final LLM call wrapped in tokio::time::timeout(pacing.step_timeout_secs). If that call exceeds the step timeout, the summary prompt is popped back off the history and the turn bails with this error — so a slow final summary turns an otherwise complete run into a failure.","triggerScenarios":"pacing.step_timeout_secs set low relative to the model's latency; a long accumulated history making the summary call slow; provider congestion right at the end of an iteration-capped turn.","commonSituations":"Tight step timeout tuned for quick tool steps but too small for one big final completion; reasoning models with long time-to-first-token; large context after many tool rounds.","solutions":["Raise pacing.step_timeout_secs so the final summary fits comfortably (it is one full-context completion).","Reduce context before the cap is hit (prune/compact history) so the summary call is cheaper.","Switch to a faster model for summary-grade output, or lower max_iterations so the summary happens earlier.","If the partial transcript is enough, catch this error and use the accumulated display text already streamed for the turn."],"exampleFix":"# before\n# pacing.step_timeout_secs = 30 — final summary needs longer on a big context\n\n# after\n# pacing.step_timeout_secs = 120","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"Catch the timeout error and retry the turn's summary once with a raised step_timeout_secs (or a faster model); if retrying is unacceptable, degrade gracefully by returning the accumulated display text already streamed for the turn — the summary prompt is popped from history, so the transcript stays clean.","preventionTips":["Budget step_timeout_secs for one full-context completion, not just tool steps","Prune/compact history before the iteration cap so the final summary is cheap","Prefer prompt models for capped long-running turns when latency matters"],"tags":["agent-loop","timeout","pacing","llm-provider"],"backgroundTag":"llm-request-timeout","analyzedSha":"88bb9c8533fc57ed7a03e36ca7c9ed2bf8336dcc","analyzedAt":"2026-08-23T01:07:41.857Z","schemaVersion":2},"datasetVersion":"2026-08-23T08:06:27.607Z"}