microsoft/autogen · error · ValueError
Run failed: {run.last_error}
Error message
Run failed: {run.last_error} What it means
During run polling in on_messages_stream, if the Azure AI agent run reaches RunStatus.FAILED, the agent raises ValueError embedding run.last_error (the service-side error, e.g. content_filter, rate_limit, invalid tool definition). This is the service rejecting/failing the run; the message text is whatever Azure reported.
Source
Thrown at python/packages/autogen-ext/src/autogen_ext/agents/azure/_azure_ai_agent.py:719
thread_id=self.thread_id,
agent_id=self._get_agent_id,
)
)
)
# Wait for run completion by polling
while True:
run = await cancellation_token.link_future(
asyncio.ensure_future(
self._project_client.agents.runs.get(
thread_id=self.thread_id,
run_id=run.id,
)
)
)
if run.status == RunStatus.FAILED:
raise ValueError(f"Run failed: {run.last_error}")
# If the run requires action (function calls), execute tools and continue
if run.status == RunStatus.REQUIRES_ACTION and run.required_action is not None:
tool_calls: List[FunctionCall] = []
submit_tool_outputs = getattr(run.required_action, "submit_tool_outputs", None)
if submit_tool_outputs and hasattr(submit_tool_outputs, "tool_calls"):
for required_tool_call in submit_tool_outputs.tool_calls:
if required_tool_call.type == "function":
tool_calls.append(
FunctionCall(
id=required_tool_call.id,
name=required_tool_call.function.name,
arguments=required_tool_call.function.arguments,
)
)
# Add tool call message to inner messages
tool_call_msg = ToolCallRequestEvent(source=self.name, content=tool_calls)View on GitHub (pinned to 027ecf0a37)
Solutions
- Read run.last_error in the message: content_filter → adjust prompt; rate_limit → back off and retry; invalid_request → fix the referenced tool/resource.
- For rate limits, retry with exponential backoff and fewer parallel agents.
- Verify the deployment exists and the project connection has access to the tools configured on the agent.
- For content filter hits, rephrase the input or the agent instructions.
Defensive patterns
Strategy: retry
Try / catch
try:
resp = await agent.on_messages(msgs, ct)
except ValueError as e:
err = str(e)
if "rate_limit" in err:
await asyncio.sleep(backoff); retry = True
elif "content_filter" in err:
adjust_prompt(); retry = False
else:
raise Prevention
- Read run.last_error in the message to classify: rate limit vs content filter vs config.
- Back off and retry on rate_limit/quota errors.
- Keep deployment and tool-connection configuration valid; deleted deployments fail every run.
When it happens
Trigger: Any on_messages_stream call where the Azure run fails server-side: content policy violations, quota/rate limits, malformed tool definitions registered on the service agent, expired threads, or model deployment errors.
Common situations: Prompts tripping content filters; hitting token-per-minute quotas; a deployment that was disabled or deleted; tool definitions referencing invalid resources (e.g. bing grounding connection not configured).
Related errors
- Thread not initialized
- Agent not initialized
- Description not initialized
- Deployment name not initialized
- Instructions not initialized
AI-assisted analysis of microsoft/autogen@027ecf0a37 (2026-08-15).
Data as JSON: /api/errors/ed86b6f23f4652f3.
Report an issue: GitHub.