TaskWeaver — Code-First Data Analytics Agent
TaskWeaver is a Microsoft code-first agent framework for data analytics tasks. 6.1K+ stars. Planning, stateful execution, DataFrames, plugins. MIT.
Ready-to-run agent install
This asset can be installed after the agent chooses its runtime, checks the plan, and runs the matching command.
npx -y tokrepo@latest install 3d3d8d62-d64e-46b4-826b-7afe4f2c8786 --target codexRun after dry-run confirms the install plan.
What it is
TaskWeaver is a code-first agent framework by Microsoft designed for data analytics tasks. It takes natural language requests, decomposes them into a plan, generates Python code for each step, executes the code in a stateful session, and returns results with DataFrames and visualizations.
TaskWeaver targets data analysts and engineers who want an AI agent that writes and runs analytics code rather than just answering questions in text.
How it saves time or tokens
TaskWeaver generates and executes code in a persistent session. Variables, DataFrames, and computation results persist across steps. This means the agent builds on previous work instead of starting fresh each time, reducing redundant computation and token usage.
The plugin system lets you extend TaskWeaver with domain-specific functions (database connectors, API calls, custom transformations) that the agent can invoke by name.
How to use
- Clone the TaskWeaver repository
- Configure your LLM provider in the config file
- Add plugins for your data sources (SQL connectors, file readers, APIs)
- Run TaskWeaver and describe your analytics task in natural language
Example
# TaskWeaver plugin: sql_query.py
from taskweaver.plugin import Plugin, register_plugin
@register_plugin
class SQLQuery(Plugin):
def __call__(self, query: str) -> dict:
'''Execute a SQL query and return results as a DataFrame.'''
import pandas as pd
import sqlalchemy
engine = sqlalchemy.create_engine(self.config['db_url'])
df = pd.read_sql(query, engine)
return {'data': df, 'row_count': len(df)}
# User interaction:
# > Load sales data from the database and show monthly revenue trends
# TaskWeaver: Planning...
# Step 1: Query sales table using sql_query plugin
# Step 2: Group by month and calculate revenue
# Step 3: Generate a line chart
Related on TokRepo
- Database tools -- Data access and query tools
- AI agent tools -- Agent frameworks
Common pitfalls
- TaskWeaver executes arbitrary Python code; run it in a sandboxed environment, never on production machines with sensitive data access
- The planner sometimes generates overly complex plans for simple tasks; provide clear, specific instructions
- Plugin configuration requires matching the exact function signature that TaskWeaver expects; follow the plugin template
Frequently Asked Questions
ChatGPT Code Interpreter runs in a sandboxed cloud environment. TaskWeaver runs locally with access to your actual databases, files, and APIs through plugins. This makes it suitable for enterprise data analytics where data cannot leave your infrastructure.
TaskWeaver supports OpenAI GPT-4, Azure OpenAI, and other providers compatible with the OpenAI API format. GPT-4 class models are recommended for reliable code generation.
Yes. TaskWeaver decomposes complex requests into sequential steps with a planner. Each step generates code, executes it, and passes results to the next step. The stateful session preserves DataFrames across steps.
Plugins are Python classes decorated with @register_plugin. They define a callable function with type hints. TaskWeaver discovers plugins automatically and lets the agent invoke them by name during task execution.
Yes. TaskWeaver is released under the MIT license by Microsoft. The source code, example plugins, and documentation are available on GitHub.
Citations (3)
- TaskWeaver GitHub— TaskWeaver is a code-first agent framework by Microsoft with 6.1K+ stars
- TaskWeaver License— MIT license for open-source use
- Microsoft Research— Code generation and execution for data analytics agents
Related on TokRepo
Source & Thanks
Created by Microsoft. MIT. microsoft/TaskWeaver — 6,100+ GitHub stars
Discussion
Related Assets
Spec-Driven Develop — Spec-First Agent Skill (2026)
Spec-Driven Develop is a spec-first skill/plugin for big agent changes; verified 715★ with installs for Claude Code, Codex marketplace, and Cursor.
CoWork OS — Local-First Agent Workspace
CoWork OS is a local-first agent workspace for code, docs, web pages, and automations, with an Electron UI and built-in support for many MCP connectors.
MoAI-ADK — Spec-First Claude Code Agent Kit
MoAI-ADK ships a Go-based Claude Code environment with 24 agents, 52 skills, 18 languages, and strong quality gates for agent-first teams.
n8n-as-code — AI Agent Superpowers for n8n
Give your AI agent n8n superpowers with 537 node schemas, 7,700+ templates, and TypeScript workflow definitions. Works with Claude Code, Cursor, VS Code, and OpenClaw. MIT license.