You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Question about observability tool integration #524
Originally posted by sr198 April 21, 2025
Going through the Opik integration example and couples of things stand out.
opik_tracer = OpikTracer()
root_agent = Agent(
name="weather_time_agent",
model="gemini-2.0-flash-exp",
description=("Agent to answer questions about the time and weather in a city."),
instruction=("I can answer your questions about the time and weather in a city."),
tools=[get_weather, get_current_time],
before_agent_callback=opik_tracer.before_agent_callback,
after_agent_callback=opik_tracer.after_agent_callback,
before_model_callback=opik_tracer.before_model_callback,
after_model_callback=opik_tracer.after_model_callback,
before_tool_callback=opik_tracer.before_tool_callback,
after_tool_callback=opik_tracer.after_tool_callback,
)
The callback params take a single value today - which means, if I want to add my own callback for some guardrail feature then I will have to wrap OpikTracker in my code. Should we allow callbacks to accept lists for chained execution at the framework level?
Agent(
...
before_model_callback=[my_callback, opik_tracer.before_model_callback],
)
Also can we allow observability integration at a higher/global level, so it’s not repeated per agent.
I'm struggling with a similar problem. I was using a before_model_callback and then applied Opik tracing only to realise that I had blatted over my callback handler. I believe it's possible to provide a list of callback handlers to some of the callbacks, but not all. There is code in LlmAgent, e.g. canonical_before_model_callbacks, which handles the case where before_model_callback is already a list. But if you want to apply opik tracing selectively, you need to be careful to not overwrite existing callbacks.
Also, it's really painful to apply opik tracing to a mulit-agent as you have to set the callbacks for each and every agent. And the callbacks to set depend on the type of the agent, e.g. BaseAgent only has before_agent_callback and after_agent_callback (which can be lists).
While the use of callbacks is convenient, the implementation seems clunky.
Activity
stefanadelbert commentedon May 27, 2025
I'm struggling with a similar problem. I was using a
before_model_callbackand then applied Opik tracing only to realise that I had blatted over my callback handler. I believe it's possible to provide a list of callback handlers to some of the callbacks, but not all. There is code inLlmAgent, e.g.canonical_before_model_callbacks, which handles the case wherebefore_model_callbackis already a list. But if you want to apply opik tracing selectively, you need to be careful to not overwrite existing callbacks.Also, it's really painful to apply opik tracing to a mulit-agent as you have to set the callbacks for each and every agent. And the callbacks to set depend on the type of the agent, e.g.
BaseAgentonly hasbefore_agent_callbackandafter_agent_callback(which can be lists).While the use of callbacks is convenient, the implementation seems clunky.
xuanyang15 commentedon Nov 20, 2025
We have updated callbacks to also accept a list and added plugins on the runner level.