-
Notifications
You must be signed in to change notification settings - Fork 766
Description
Is your feature request related to a problem? Please describe.
I am using AgentOps as my agent observability platform, and I'm trying to build a TaskWeaver integration. Currently there are some blockers that prevent TaskWeaver from exporting the required information to AgentOps.
What is AgentOps?
AgentOps is a platform for tracking and analyzing the interactions between users and AI agents. It provides a python SDK for tracking the analytics of AI agents. and a dashboard for visualization of the collected data.
The docs are available here and the Github repo is available here.
Challenges integrating TaskWeaver with AgentOps
This PR is using the SessionEventHandler class to track the analytics of the TaskWeaver app. We want to track the information about different events in the TaskWeaver app i.e. the Session, the Round and the Post by mapping them to the AgentOps events - ActionEvent, LLMEvent, ToolEvent, and an additional ErrorEvent for reporing errors during tracking of any aforementioned events.
However, the following caveats are observed:
- When using the
SessionEventHandlerclass, we are able to track most of the information except those of the LLM calls and the associated Tool calls. Since thesend_messagefunction is not handled by theSessionEventHandlerclass, the user query is not available for tracking. Similarly, thetaskweaver_config.jsonfile is not being tracked as theapp_dirvariable is not available in theSessionEventHandlerclass. - AgentOps tracks LLM calls and events through monkey patching. It currently integrates with the official LLM provider libraries (e.g.
openai,anthropicetc) but TaskWeaver uses a custom wrapper around the LLM provider libraries using aCompletionServiceclass. I made an attempt to patch theCompletionServiceclass for each LLM provider in TaskWeaver to track the LLM calls, but no information was captured. - The TaskWeaver documentation mentions the use of OpenTelemetry for tracing, using the
Tracingmodule which is a wrapper around theopentelemetrylibrary. However, I see no detailed documentation on modifying this class to use a different tracing backend.
Describe the solution you'd like
From my observations, the TaskWeaver app is using the Injector library to manage the dependency injections in the codebase. The following proposed solutions are based on this observation:
- Modify the
Injectorclass to inject the AgentOps python SDK so that theSessionEventHandlerclass can track the analytics of the TaskWeaver app. - Modify the
CompletionServiceclass to track the LLM calls and the associated Tool calls. - Modify the
Tracingclass to use a different tracing backend.
Alternatively, I would like to know if we can expose the information ranging from the user query to the LLM provider used in the SessionEventHandler class so that we can track the analytics using the AgentOps python SDK.
Describe alternatives you've considered
One of the ways is to pass the Session object to the AgentOps handler directly and extract the required information. This is not a clean solution as changes to the TaskWeaver codebase would break the integration and thus affect scalability.
Additional context
Here is the code I used to track the analytics of the TaskWeaver app:
from taskweaver.app.app import TaskWeaverApp
from agentops.partners.taskweaver_event_handler import TaskWeaverEventHandler
# This is the folder that contains the taskweaver_config.json file and not the repo root. Defaults to "./project/"
app_dir = "TaskWeaver/project/."
app = TaskWeaverApp(app_dir=app_dir)
session = app.get_session()
handler = TaskWeaverEventHandler()
session.event_emitter.register(handler)
user_query = "hello, what can you do?"
# response_round = session.send_message(user_query, event_handler=handler)
response_round = session.send_message(user_query)
print(response_round.to_dict())This video will demonstrate the tracking on the AgentOps dashboard.