Skip to content

feat(adk): pass telemetry attributes through toolbox-adk#720

Open
AjmeraParth132 wants to merge 3 commits into
googleapis:mainfrom
AjmeraParth132:feat/adk-telemetry-attributes-integration
Open

feat(adk): pass telemetry attributes through toolbox-adk#720
AjmeraParth132 wants to merge 3 commits into
googleapis:mainfrom
AjmeraParth132:feat/adk-telemetry-attributes-integration

Conversation

@AjmeraParth132

Copy link
Copy Markdown
Contributor

Background

toolbox-core now supports TelemetryAttributes and sends them through MCP _meta for extended telemetry / SQLCommenter (#632, #634). toolbox-adk did not expose that flow, so ADK users could not attach model, user ID, or agent ID metadata when invoking Toolbox tools through ToolboxToolset.

This PR adds ADK pass-through support for telemetry attributes.

Changes

  • Add telemetry_attributes to ToolboxToolset.
  • Pass telemetry_attributes into each wrapped ToolboxTool.
  • Add telemetry_attributes support to ToolboxTool.
  • Support static TelemetryAttributes and sync/async callbacks.
  • Support callbacks that accept ADK ToolContext, matching the existing auth token getter
    pattern from feat(adk): Support ToolContext for auth_token_getters in toolbox-adk #579.
  • Resolve telemetry attributes per invocation and apply them to a derived core tool via
    add_telemetry_attributes(...).
  • Avoid mutating the shared wrapped core tool so context-specific user/agent metadata does not
    leak between invocations.
  • Preserve telemetry configuration when bind_params(...) returns a new ADK wrapper.
  • Add regression coverage for user identity cleanup when telemetry resolution fails.

Related

@anubhav756

Copy link
Copy Markdown
Contributor

/gcbrun

@anubhav756
anubhav756 marked this pull request as ready for review July 21, 2026 06:30
@anubhav756
anubhav756 requested a review from a team as a code owner July 21, 2026 06:30
@anubhav756
anubhav756 force-pushed the feat/adk-telemetry-attributes-integration branch from 41cada5 to ced41bb Compare July 21, 2026 06:30
@anubhav756

Copy link
Copy Markdown
Contributor

/gcbrun

@AjmeraParth132
AjmeraParth132 force-pushed the feat/adk-telemetry-attributes-integration branch 2 times, most recently from 2baed48 to c69e841 Compare July 21, 2026 06:44
@anubhav756

Copy link
Copy Markdown
Contributor

/gcbrun

@anubhav756 anubhav756 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

As discussed let's add documentation to the docsite repo following this. I'm also thinking if we can optionally add some integration tests as well?

Comment thread packages/toolbox-adk/tests/unit/test_tool.py Outdated
attributes,
)
resolved = context_getter(tool_context)
else:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

optional: Is it by any chance still possible to pass a function with default arguments?

def get_telemetry(ctx: ToolContext, default_model: str = "gemini-3.5-flash") -> TelemetryAttributes:
    return TelemetryAttributes(llm_model=default_model, ...)

If so then len(sig.parameters) will be 2 and it falls through calling attributes() with 0 arguments and may complain about missing 1 required positional argument (ctx).

If it makes sense then should we also determine whether the function can accept 1 positional argument by checking parameter kinds and required parameters, or by inspecting positional parameters?

Comment thread packages/toolbox-adk/src/toolbox_adk/tool.py
telemetry_attributes: Optional[
Union[
TelemetryAttributes,
Callable[[], TelemetryAttributes],

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

optional: Curious what if the callable wants to resolve a None for user id for instance? Do we handle an empty string for that in this object or do we want to support Optional[TelemetryAttributes] as a return type of the callable? I'm fine with the former.

@anubhav756

Copy link
Copy Markdown
Contributor

/gcbrun

@anubhav756
anubhav756 force-pushed the feat/adk-telemetry-attributes-integration branch from 84265e7 to fecb875 Compare July 22, 2026 11:46
@anubhav756

Copy link
Copy Markdown
Contributor

/gcbrun

@anubhav756
anubhav756 force-pushed the feat/adk-telemetry-attributes-integration branch from fecb875 to 611a197 Compare July 23, 2026 08:24

@twishabansal twishabansal left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Approving to unblock multi approvers CI check

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.

3 participants