{"record":{"id":"6b78b2055246eaf3","repo":"agentscope-ai/agentscope","slug":"model-call-failed-after-retries-but-no-exception","errorCode":null,"errorMessage":"Model call failed after retries, but no exception was raised.","messagePattern":"Model call failed after retries, but no exception was raised\\.","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"src/agentscope/agent/_agent.py","lineNumber":3149,"sourceCode":"                            \"Retrying (%d/%d)...\",\n                            model.model,\n                            self.name,\n                            attempt + 1,\n                            self.model_config.max_retries,\n                        )\n                    else:\n                        logger.warning(\n                            \"Model %s exhausted all %d attempt(s) \"\n                            \"for agent %s.\",\n                            model.model,\n                            self.model_config.max_retries + 1,\n                            self.name,\n                        )\n\n        if last_exception:\n            raise last_exception from None\n\n        raise RuntimeError(\n            \"Model call failed after retries, but no exception was raised.\",\n        )\n\n    def _update_tool_call_state(\n        self,\n        tool_call_id: str,\n        state: ToolCallState,\n    ) -> None:\n        \"\"\"Update the tool call state. This function is to avoid the update\n        not reflected in the context due to the shallow copy of the content\n        blocks somewhere in the code.\n\n        Args:\n            tool_call_id (`str`):\n                The tool call id to be updated.\n            state (`ToolCallState`):\n                The new state of the tool call.\n        \"\"\"","sourceCodeStart":3131,"sourceCodeEnd":3167,"githubUrl":"https://github.com/agentscope-ai/agentscope/blob/e90f1c7592896cc95f6e5ee506194f533378247d/src/agentscope/agent/_agent.py#L3131-L3167","documentation":"A defensive RuntimeError indicating the model-call retry loop exhausted without capturing an exception, which should never happen. It guards against a control-flow bug where retries completed but neither a result nor last_exception was recorded.","triggerScenarios":"Essentially unreachable in normal use; would only occur if a retry loop iteration completed without producing a result or setting last_exception (library bug or a custom retry/model wrapper that swallows exceptions).","commonSituations":"Custom model adapter or monkey-patched retry logic that returns None instead of raising on failure; version skew after upgrading agentscope internals.","solutions":["If you wrap or subclass the model call, ensure failures raise rather than return None","Report the issue to agentscope maintainers with a reproduction, since this is an internal invariant violation","Check for monkey-patches/plugins interfering with the retry loop"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"try:\n    reply = await agent.reason(...)\nexcept RuntimeError as e:\n    if \"no exception was raised\" in str(e):\n        logger.error(\"agentscope internal invariant hit\", exc_info=True)\n        raise","preventionTips":["Avoid monkey-patching model-call internals","Keep custom model adapters aligned with the base class contract"],"tags":["agentscope","model-call","retry","internal-invariant"],"backgroundTag":"unreachable-state-internal-bug","analyzedSha":"e90f1c7592896cc95f6e5ee506194f533378247d","analyzedAt":"2026-08-28T18:24:12.087Z","schemaVersion":2},"datasetVersion":"2026-08-28T21:17:43.275Z"}