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

  1. If you wrap or subclass the model call, ensure failures raise rather than return None
  2. Report the issue to agentscope maintainers with a reproduction, since this is an internal invariant violation
  3. 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

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


AI-assisted analysis of agentscope-ai/agentscope@e90f1c7592 (2026-08-28). Data as JSON: /api/errors/6b78b2055246eaf3. Report an issue: GitHub.