Skip to content

Add Google ADK integration (auto-instrumentation + Penelope Target) - #2010

Open
Ayush7614 wants to merge 2 commits into
rhesis-ai:mainfrom
Ayush7614:feature/google-adk-integration
Open

Add Google ADK integration (auto-instrumentation + Penelope Target)#2010
Ayush7614 wants to merge 2 commits into
rhesis-ai:mainfrom
Ayush7614:feature/google-adk-integration

Conversation

@Ayush7614

@Ayush7614 Ayush7614 commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

Purpose

Add Google ADK auto-instrumentation and a Penelope target for multi-turn agent testing with session continuity.

Closes #1868

What Changed

  • Implemented GoogleADKIntegration injecting a global RhesisADKPlugin into ADK Runner instances
  • Patched Runner.run for latency and I/O spans with session_id attributes
  • Added GoogleADKTarget supporting Runner or Agent (auto-builds Runner + in-memory sessions)
  • Registered integration in get_all_integrations() and added google-adk optional deps
  • Added SDK and Penelope unit tests

Testing

  • cd sdk && uv run pytest ../tests/sdk/telemetry/integrations/test_google_adk_integration.py ../tests/sdk/telemetry/integrations/test_langgraph_integration.py -q
  • cd penelope && uv run pytest ../tests/penelope/targets/test_google_adk.py -q

Implement GoogleADKIntegration with Runner plugin injection and run
tracing, add GoogleADKTarget for multi-turn Penelope testing via
session_id, and add unit tests for issue rhesis-ai#1868.

@peqy peqy Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two small issues to address before shipping:

  • Penelope target: asyncio.run() in GoogleADKTarget.send_message() will fail when called under an existing event loop.
  • SDK integration: runner run wrapper records input twice; output event should be added without repeating input.

) as span:
add_agent_io_events(span, new_message, None)
result = await original(self, *args, **kwargs)
add_agent_io_events(span, new_message, result)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Improvement: add_agent_io_events(span, new_message, result) will record the input a second time (you already recorded input at line 114).

Fix: change the second call to only add the output event, e.g. add_agent_io_events(span, None, result) (or add a dedicated add_agent_output_event).

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in d202e83: second add_agent_io_events now only records the output (add_agent_io_events(span, None, result)).

session_id = conversation_id or "default"
try:
if inspect.iscoroutinefunction(self.runner.run):
return asyncio.run(self._async_send_message(message, session_id, **kwargs))

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Improvement: asyncio.run(...) will raise RuntimeError: asyncio.run() cannot be called from a running event loop if Penelope is invoked from an async context (e.g., notebooks / async test harnesses).

Fix: adopt the project’s existing pattern of a safe async runner (detect running loop and run the coroutine in a separate thread / provide an async send_message_async).

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in d202e83: send_message now uses rhesis.sdk.async_utils.run_sync(...) for async runners (safe even if a loop is already running). Added test coverage for the running-loop case.

Record runner output events without duplicating input and use run_sync
for async ADK runner calls so send_message works under a running loop.
@peqy

peqy Bot commented Jun 19, 2026

Copy link
Copy Markdown

Re-reviewed after d202e83: the two items I flagged are addressed (no duplicate input event in Runner.run span; GoogleADKTarget now uses run_sync so it works under an already-running event loop). No further issues from me.

@Ayush7614

Copy link
Copy Markdown
Contributor Author

cc: @harry-rhesis

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Google ADK integration (auto-instrumentation + Penelope Target)

1 participant