{"record":{"id":"29121c075d8b8c4d","repo":"google-gemini/gemini-cli","slug":"agent-role-execution-failed-e","errorCode":null,"errorMessage":"Agent '{role}' execution failed: {e}","messagePattern":"Agent '(.+?)' execution failed: (.+?)","errorType":"exception","errorClass":"AgentRunnerError","httpStatus":null,"severity":"error","filePath":"tools/caretaker-agent/cloudrun/pr-generator/workflow/agent_runner.py","lineNumber":251,"sourceCode":"\n                        # Accumulate outputs\n                        for step_idx in sorted(step_contents.keys()):\n                            stdout_list.append(step_contents[step_idx])\n\n                        for step_idx in sorted(step_thoughts.keys()):\n                            thinking_list.append(step_thoughts[step_idx])\n\n            full_output = \"\\n\".join(stdout_list)\n            if thinking_list:\n                joined_thoughts = \"\\n\".join(thinking_list)\n                full_output += f\"\\nThoughts:\\n{joined_thoughts}\"\n\n            logging.info(\"Agent '%s' execution completed successfully.\", role)\n            return full_output\n\n        except Exception as e:\n            logging.exception(\"Failed to execute agent loop for role: %s\", role)\n            raise AgentRunnerError(f\"Agent '{role}' execution failed: {e}\") from e\n","sourceCodeStart":233,"sourceCodeEnd":252,"githubUrl":"https://github.com/google-gemini/gemini-cli/blob/5024443c7217464a66e98f80d73172a26440bd8f/tools/caretaker-agent/cloudrun/pr-generator/workflow/agent_runner.py#L233-L252","documentation":"AgentRunnerError 'Agent \\'X\\' execution failed: e' wraps ANY exception raised inside the agent conversation loop (after `if Agent is None` has passed). The original exception is chained via `from e`, and an 'unexpected error' log line is emitted. The message tells you which role failed and the underlying error text.","triggerScenarios":"Inside run()'s try block: LocalAgentConfig build, `async with Agent(config)`, `agent.conversation.send(prompt)`, or `receive_steps()` raises -> except Exception as e -> raise AgentRunnerError(f\"Agent '{role}' execution failed: {e}\") from e.","commonSituations":"Vertex AI auth/permission errors; project_id or location misconfigured; model_name invalid or unavailable in the region; the Antigravity SDK raised on a malformed step; rate limit / quota during receive_steps.","solutions":["Read the chained `__cause__` (the original Exception) — the wrapped message is the real diagnosis.","Verify Vertex config: project_id, location, model_name are valid and the SA has aiplatform permissions.","Check AgentRunner logs: logging.exception('Failed to execute agent loop for role: %s') prints the full traceback.","Retry on transient errors (rate limits); fix config on persistent ones."],"exampleFix":"# before\nexcept Exception as e: raise AgentRunnerError(...) from e  # original swallowed\n# after\nexcept Exception as e:\n    logging.exception('underlying cause')\n    raise AgentRunnerError(...) from e  # inspect e.__cause__ in caller","handlingStrategy":"try-catch","validationCode":"# pre-flight: auth + region\nfrom google.cloud import aiplatform\naiplatform.init(project=runner.project_id, location=runner.location)","typeGuard":"def is_agent_execution_error(e: Exception) -> bool:\n    return isinstance(e, AgentRunnerError) and 'execution failed' in str(e)","tryCatchPattern":"try:\n    out = runner.run(role, prompt, repo_path)\nexcept AgentRunnerError as e:\n    log.error('underlying: %r', e.__cause__)\n    raise","preventionTips":["Always log e.__cause__ — the wrapped error is the real signal.","Validate Vertex project/location/model before entering the agent loop."],"tags":["agent-runner","antigravity-sdk","error-wrapping","python"],"backgroundTag":null,"analyzedSha":"5024443c7217464a66e98f80d73172a26440bd8f","analyzedAt":"2026-08-12T06:01:53.711Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}