TaskWeaver (Microsoft) Integration for Analytical AI Agents
We've grown accustomed to an analyst spending a day on Excel, yet the task often boils down to a couple of queries. In one project, a three-person team manually prepared a monthly report — 40 hours each. TaskWeaver, a framework by Microsoft Research, turns an English description into executable Python code. We integrate such agents turnkey: connect sources, configure the sandbox, and teach the agent your business rules. As a result, a report that used to take a day is ready in half an hour, and the analyst shifts to meaningful tasks.
Problems We Solve
Errors during manual copying. Transferring formulas between Excel and reports introduces 2–3 errors per quarter. TaskWeaver generates code, eliminating the human factor: one formula once, not copied into 20 cells.
Non-reproducibility of reports. When an analyst leaves, their "recipe" is often lost. The agent stores the entire pipeline in code — it can be rerun with the same results a month later.
Slow processing of large datasets. Loading CSV via pandas in a notebook takes minutes, while the agent does it simply and quickly without a GUI.
How We Do It: Stack and Configs
We use the latest version of TaskWeaver (GitHub) with GPT-4o. The sandbox runs on Docker; allowed modules are limited to only those needed for analytics. For unstructured data, we set up RAG: the agent searches relevant documents in a vector database and uses them as context.
TaskWeaver Installation and Configuration
# Установка TaskWeaver git clone https://github.com/microsoft/TaskWeaver.git cd TaskWeaver pip install -r requirements.txt // project/taskweaver_config.json { "llm.api_base": "https://api.openai.com/v1", "llm.api_key": "sk-...", "llm.model": "gpt-4o", "planner.example_base_path": "${AppBaseDir}/examples", "code_interpreter.use_local_uri": true, "code_interpreter.allowed_modules": ["pandas", "numpy", "matplotlib", "sklearn", "scipy"] } We write custom plugins for corporate databases. Example — db_query plugin for SQL queries:
from taskweaver.plugin import Plugin, register_plugin import pandas as pd @register_plugin class DatabaseQueryPlugin(Plugin): def execute(self, query: str, database: str = "analytics") -> pd.DataFrame: conn = get_db_connection(database) return pd.read_sql(query, conn) The plugin is registered in a yaml file, but we often configure it via code.
Practical Case: Financial Analysis in 25 Minutes
Problem: our client, a fintech company, spent 2 days monthly on a report: loading data from 3 sources, calculating 15 KPIs, building 8 charts, detecting anomalies.
Solution: we deployed a TaskWeaver agent that autonomously executes the entire cycle:
- Queries to PostgreSQL (revenue, costs)
- Loading Excel files (budget)
- KPI calculation via pandas
- Charting (matplotlib/plotly)
- Markdown report generation with insights
Results:
- Report preparation time: 2 days → 25 minutes automatic + 40 minutes review
- Calculation errors: 0 (previously 2–3 per quarter with manual copying)
- Analyst shifted to meaningful interpretation instead of routine
| Metric | Before | After |
|---|---|---|
| Report preparation time | 2 days | 25 minutes |
| Calculation errors | 2-3 per quarter | 0 |
| Analyst time spent | 40 hours/month | 5 hours/month |
Why TaskWeaver is Better than Standard Code Interpreter?
ChatGPT Code Interpreter breaks context with each run. TaskWeaver maintains session state: you can do step 1, pause, view intermediate results, then command "repeat analysis only for region A". This gives 5 times more control over multi-step analysis.
from taskweaver.app.app import TaskWeaverApp app = TaskWeaverApp(app_dir="./project") session = app.get_session() # Шаг 1: загрузка и очистка session.chat("Загрузи данные продаж из БД за прошедший год, удали дубликаты") # Шаг 2: анализ сезонности session.chat("Проведи STL-декомпозицию") # Шаг 3: прогноз session.chat("Построй прогноз на следующий квартал с помощью Prophet с backtesting") # Шаг 4: отчёт result = session.chat("Сформируй markdown-отчёт с графиками") print(result.post_list[-1].get_text()) What LLM Models Can Be Used with TaskWeaver?
Any OpenAI (GPT-4o, GPT-4), Claude, LLaMA 3, Mistral are supported. We typically use GPT-4o for its high code generation accuracy. The LLM can be changed in the config without reinstalling the framework. For tasks with high latency, Mistral is suitable — it is faster but slightly less accurate. The choice of model depends on your requirements for speed and accuracy.
How TaskWeaver Handles Multi-step Tasks?
The planner breaks down the task into sub-tasks, turns each into code, executes, and analyzes the result. If an error occurs at step 2, the agent reformulates the code automatically. We ensure accuracy through chain-of-thought prompting: the agent writes a plan before code, then executes.
Implementation Process
- Audit sources and business logic. Determine required plugins, allowed modules, execution frequency.
- Design the agent. Select LLM, configure sandbox, write custom plugins.
- Development and testing on real data. 3–10 iterations.
- Production deployment. Docker, scheduler (cron/airflow), monitoring.
- Team training. 2 workshops, documentation.
Scope of Work
| Component | Description |
|---|---|
| TaskWeaver agent | Configured framework with your config |
| Custom plugins | Integration with corporate databases and APIs |
| Sandbox | Docker container with restricted permissions |
| Documentation | Agent description, prompt examples, instructions |
| Support | 1 month after launch |
Timelines and Team Experience
- Basic setup: 2–3 days.
- Full cycle with plugins and testing: 1–2 weeks.
- We have deployed TaskWeaver for 10+ companies in finance, retail, and logistics. We have been working with LLMs since the first production-ready models — we know all the nuances of prompt engineering (few-shot, chain-of-thought).
Estimate your project. Contact us, describe your task — we will send a demo session of your agent in 2 days. We guarantee the sandbox is secure and code does not leak. Contact us for a consultation and precise timeline estimate.







