{"record":{"id":"6fc37373553187bd","repo":"tinyhumansai/openhuman","slug":"agent-exceeded-maximum-tool-iterations-max","errorCode":null,"errorMessage":"Agent exceeded maximum tool iterations ({max})","messagePattern":"Agent exceeded maximum tool iterations \\((.+?)\\)","errorType":"exception","errorClass":"AgentError::MaxIterationsExceeded","httpStatus":null,"severity":"error","filePath":"src/openhuman/agent/tinyagents/mod.rs","lineNumber":953,"sourceCode":"            // here. Ordering the cap/depth mappings ahead of the slot is\n            // defense-in-depth: a run that failed on the model-call cap or a\n            // spawn-depth limit is not a provider error, so it must surface as\n            // `MaxIterationsExceeded` / the depth error rather than a leftover\n            // provider error (wrong classification, wrong Sentry suppression,\n            // wrong user message).\n            //\n            // The model-call cap (when not pausing gracefully — the channel/CLI\n            // path) maps to the typed `AgentError::MaxIterationsExceeded` so\n            // callers downcast it (Sentry skip) and render the canonical\n            // \"Agent exceeded maximum tool iterations\" message, matching the\n            // legacy `ErrorCheckpoint`.\n            if let tinyagents::TinyAgentsError::LimitExceeded(msg) = &e {\n                if msg.contains(\"model call\") {\n                    tracing::debug!(\n                        model,\n                        \"[tinyagents] run hit the model-call cap; mapping to MaxIterationsExceeded (not consulting error_slot) — #4457 defect B\"\n                    );\n                    return Err(anyhow::Error::new(\n                        crate::openhuman::agent::error::AgentError::MaxIterationsExceeded {\n                            max: max_iterations,\n                        },\n                    ));\n                }\n            }\n            if let Some(depth_err) = tinyagents_depth_error(&e) {\n                return Err(anyhow::Error::new(depth_err));\n            }\n            // Otherwise prefer the original typed provider error (preserves\n            // `AgentError` downcasts the caller relies on) over the harness's\n            // string wrap — this is where a genuine model/provider failure that\n            // halted the run is re-surfaced with its real classification.\n            // #4469 item 3: `into_inner` recovers a poisoned slot so a panic in\n            // one run can't cascade into a second panic here that would mask the\n            // original typed provider error.\n            if let Some(original) = error_slot\n                .lock()","sourceCodeStart":935,"sourceCodeEnd":971,"githubUrl":"https://github.com/tinyhumansai/openhuman/blob/749120085864ce16e0f273c7b86fac7740b39c5b/src/openhuman/agent/tinyagents/mod.rs#L935-L971","documentation":"The agent harness hit its model-call/tool-iteration cap: the run consumed more model calls than the configured maximum for the turn. tinyagents reports this as TinyAgentsError::LimitExceeded containing 'model call', which the dispatcher maps to the typed AgentError::MaxIterationsExceeded so callers can downcast it (Sentry skip) and render the canonical message — it is a policy stop, not a provider failure, so it must not surface as a leftover provider error or be reported to Sentry.","triggerScenarios":"Thrown at src/openhuman/agent/tinyagents/mod.rs:953 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Tighten the prompt or tool results so the task completes within the iteration cap (e.g. reduce redundant tool round-trips)","Raise the per-turn model-call cap in the agent/harness configuration if the task legitimately needs more iterations","If a tool is failing repeatedly and burning iterations, fix the underlying tool failure the loop is retrying around"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"749120085864ce16e0f273c7b86fac7740b39c5b","analyzedAt":"2026-08-17T21:21:45.363Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}