Skip to content

[OPIK-1812] Implement a function for recursive callback passing in adk #2495

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

alexkuzmik
Copy link
Collaborator

@alexkuzmik alexkuzmik commented Jun 16, 2025

Details

Implemented a new experimental feature - track_adk_agent_recursive function. It allows to not pass the callback function to every agent component manually. Instead it iterates over subagents and tools, searches for BaseAgent or AgentTool instances and recursively propagates opik callbacks to them.

    opik_tracer = OpikTracer()

    translator_to_english = adk_agents.Agent(
        name="Translator",
        model=MODEL_NAME,
        description="Translates text to English.",
    )
    summarizer = adk_agents.Agent(
        name="Summarizer",
        model=MODEL_NAME,
        description="Summarizes text to 1 sentence.",
    )
    root_agent = adk_agents.SequentialAgent(
        name="TextProcessingAssistant",
        sub_agents=[translator_to_english, summarizer],
        description="Runs translator to english then summarizer, in order.",
    )

    track_adk_agent_recursive(root_agent, opik_tracer)

The calls of track_adk_agent_recursive are idempotent so it should be safe to call it multiple times or to call it for the agent which already contains OpikTracer callbacks (or which has subagents/agent tools already containing OpikTracer callbacks)

Testing

Added integration tests.

Documentation

Added docstrings.

@alexkuzmik alexkuzmik requested a review from a team as a code owner June 16, 2025 15:26
@alexkuzmik alexkuzmik marked this pull request as draft June 16, 2025 15:26
@alexkuzmik alexkuzmik self-assigned this Jun 16, 2025
@alexkuzmik alexkuzmik changed the title [OPIK-1812] Implement a function for recursive callback passing in adk [OPIK-1812] [IN PROGRESS] Implement a function for recursive callback passing in adk Jun 16, 2025
@alexkuzmik alexkuzmik requested a review from yaricom June 17, 2025 11:55
@alexkuzmik alexkuzmik marked this pull request as ready for review June 17, 2025 11:58
@alexkuzmik alexkuzmik changed the title [OPIK-1812] [IN PROGRESS] Implement a function for recursive callback passing in adk [OPIK-1812] Implement a function for recursive callback passing in adk Jun 17, 2025
@alexkuzmik alexkuzmik merged commit 6f63bc6 into main Jun 17, 2025
53 checks passed
@alexkuzmik alexkuzmik deleted the OPIK-1812-p-sdk-implement-a-function-for-recursive-callback-passing-in-adk branch June 17, 2025 15:35
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.

2 participants