--- title: TaskWeaver description: "First class support for Microsoft TaskWeaver" --- import CodeTooltip from '/snippets/add-code-tooltip.mdx' import EnvTooltip from '/snippets/add-env-tooltip.mdx' [TaskWeaver](https://microsoft.github.io/TaskWeaver/) is a code-first agent framework for seamlessly planning and executing data analytics tasks. Explore TaskWeaver's comprehensive [documentation](https://microsoft.github.io/TaskWeaver/docs/overview) for more information. ## Steps to integrate TaskWeaver with AgentOps ```bash pip pip install agentops ``` ```bash poetry poetry add agentops ``` Follow the instructions on the TaskWeaver [Quick Start](https://microsoft.github.io/TaskWeaver/docs/quickstart) section in the documentation. AgentOps uses the TaskWeaver handler to handle its events. Additionally, AgentOps tracks the LLM calls made by TaskWeaver via its inbuilt module. These are used together to observe everything in the TaskWeaver session. TaskWeaver provides different [usage options](https://microsoft.github.io/TaskWeaver/docs/usage). By default, it's used as a CLI app via the `taskweaver` command but can also be used as a library. ```python python import agentops from agentops.partners.taskweaver_event_handler import TaskWeaverEventHandler from taskweaver.app.app import TaskWeaverApp agentops.init() # Your TaskWeaver code here agentops.end_session("Success") ``` ```python .env AGENTOPS_API_KEY= ``` Read more about environment variables in [Advanced Configuration](/v1/usage/advanced-configuration) Execute your program and visit [app.agentops.ai/drilldown](https://app.agentops.ai/drilldown) to observe your TaskWeaver Agent! 🕵️ After your run, AgentOps prints a clickable url to console linking directly to your session in the Dashboard
## Full Examples This is a basic example of how to use TaskWeaver as a library and observe it with AgentOps. Ensure you have configured your project directory in the TaskWeaverApp by following the documentation mentioned in step 2. When registering the TaskWeaverEventHandler, you should either use the `session.event_emitter.register` method or pass the handler object to the `event_handler` parameter in the `send_message` method. If you use both, the events will be recorded twice, resulting in a "stuttering" effect in the recorded messages. ```python python import agentops from taskweaver.app.app import TaskWeaverApp from agentops.partners.taskweaver_event_handler import TaskWeaverEventHandler agentops.init() app_dir = "" app = TaskWeaverApp(app_dir=app_dir) session = app.get_session() handler = TaskWeaverEventHandler() session.event_emitter.register(handler) user_query = "Hello, what are the capabilities of TaskWeaver?" response_round = session.send_message(user_query) user_query = "Write me a simple calculator program in python" response_round = session.send_message(user_query) agentops.end_session("Success") ```