Skip to content

Commit b727583

Browse files
caohy1988claude
andcommitted
test(plugins): add runner-level regression for plugin failure during on_run_error_callback
Adds end-to-end test through Runner.run_async() verifying that a crashing on_run_error_callback plugin does not mask the original application exception. Symmetric with the existing agent-level test. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 36804af commit b727583

1 file changed

Lines changed: 43 additions & 0 deletions

File tree

tests/unittests/plugins/test_error_callbacks.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -569,3 +569,46 @@ async def on_agent_error_callback(self, **kwargs):
569569
# NOT the plugin's ValueError.
570570
with pytest.raises(RuntimeError, match="agent crashed"):
571571
_ = [e async for e in agent.run_async(ctx)]
572+
573+
@pytest.mark.asyncio
574+
async def test_original_exception_propagates_despite_run_plugin_failure(
575+
self,
576+
):
577+
"""End-to-end: a crashing plugin on_run_error_callback does not mask
578+
the original agent exception seen by the runner caller."""
579+
from google.adk.runners import Runner
580+
581+
class _FailingRunPlugin(BasePlugin):
582+
__test__ = False
583+
584+
def __init__(self, name):
585+
super().__init__(name)
586+
587+
async def on_run_error_callback(self, **kwargs):
588+
raise ValueError("plugin internal error")
589+
590+
plugin = _FailingRunPlugin(name="bad_plugin")
591+
agent = _CrashingAgent(name="crash_agent")
592+
runner = Runner(
593+
agent=agent,
594+
app_name="test_app",
595+
session_service=InMemorySessionService(),
596+
plugins=[plugin],
597+
)
598+
session = await runner.session_service.create_session(
599+
app_name="test_app", user_id="test_user"
600+
)
601+
602+
# The caller must see the original RuntimeError("agent crashed"),
603+
# NOT the plugin's ValueError.
604+
with pytest.raises(RuntimeError, match="agent crashed"):
605+
_ = [
606+
e
607+
async for e in runner.run_async(
608+
user_id="test_user",
609+
session_id=session.id,
610+
new_message=types.Content(
611+
parts=[types.Part(text="hello")]
612+
),
613+
)
614+
]

0 commit comments

Comments
 (0)