agentscope-ai/agentscope · error · RuntimeError
Model call failed after retries, but no exception was raised
Error message
Model call failed after retries, but no exception was raised.
What it means
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.
Source
Thrown at src/agentscope/agent/_agent.py:3149
"Retrying (%d/%d)...",
model.model,
self.name,
attempt + 1,
self.model_config.max_retries,
)
else:
logger.warning(
"Model %s exhausted all %d attempt(s) "
"for agent %s.",
model.model,
self.model_config.max_retries + 1,
self.name,
)
if last_exception:
raise last_exception from None
raise RuntimeError(
"Model call failed after retries, but no exception was raised.",
)
def _update_tool_call_state(
self,
tool_call_id: str,
state: ToolCallState,
) -> None:
"""Update the tool call state. This function is to avoid the update
not reflected in the context due to the shallow copy of the content
blocks somewhere in the code.
Args:
tool_call_id (`str`):
The tool call id to be updated.
state (`ToolCallState`):
The new state of the tool call.
"""View on GitHub (pinned to e90f1c7592)
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
Defensive patterns
Strategy: fallback
Try / catch
try:
reply = await agent.reason(...)
except RuntimeError as e:
if "no exception was raised" in str(e):
logger.error("agentscope internal invariant hit", exc_info=True)
raise Prevention
- Avoid monkey-patching model-call internals
- Keep custom model adapters aligned with the base class contract
When it happens
Trigger: 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).
Common situations: Custom model adapter or monkey-patched retry logic that returns None instead of raising on failure; version skew after upgrading agentscope internals.
Related errors
- Invalid permission decision behavior: {decision.behavior}
- Failed to get the completed response from model {model_name}
- Failed to fetch bytes from URL `{url}` after {max_retries} r
- One or more tool calls raised an exception
- Input validation failed for tool '{tool_call.name}': {e.mess
AI-assisted analysis of agentscope-ai/agentscope@e90f1c7592 (2026-08-28).
Data as JSON: /api/errors/6b78b2055246eaf3.
Report an issue: GitHub.