Agent engineering · AutoGen
DataPilot
Ask a business question in plain English. A team of four agents writes and runs real code on the data, repairs its own errors, and answers only once an independent Reviewer approves.
- 4agents: Planner, Coder, Executor, Reviewer
- 12agent messages allowed per run
- 5 / 5live evaluations passed
- 0network access inside the sandbox
01The problem
An AI analyst that writes code needs to prove it works.
Asking an AI to analyse a spreadsheet is easy to do and hard to trust: the code can fail, the answer can be wrong, and nobody sees which. Letting model-written code run next to real systems is a risk in its own right.
DataPilot is built around two questions. Can the agents find and fix their own mistakes without a human debugging, and can they do it safely enough to trust the answer?
02What I built
A data analyst that checks its own work.
- 01Four agents, one loopA Planner, Coder, Executor and Reviewer work in AutoGen. A failed run goes back to the Coder with the real error, and only the Reviewer can approve.
- 02An isolated sandboxGenerated code never runs in the app. A broker starts one throw-away container per execution: no network, read-only filesystem, limited memory, CPU and processes.
- 03Verified outputsThe answer, charts, the exact analysis.py that ran, and a one-page PDF. The script can be re-run in a fresh container to check it reproduces.
- 04A human decisionReviewer approval is not the end: a person approves or rejects the report, and a follow-up question starts a new run with a fresh budget.
Built with AutoGen AgentChat, an OpenAI model, Docker, Streamlit and Plotly. Built with an agentic coding workflow using Claude Code.
03How it works
A question, an error, a repair, an approval.
The run stops at the first Reviewer approval or after 12 agent messages, whichever comes first.
- QuestionPlain English
- Planner and CoderPlan, then code
- Sandbox runOne container each time
- Repair loopReal error back to the Coder
- Reviewer approvalThen a human decides
04Decisions that mattered
What I chose, and why.
The reasoning behind the build, not just the parts list.
- 01Only the Reviewer approves, within a hard limitThe run ends at the first Reviewer approval or after 12 agent messages. An approval counts only after a successful execution; the word appearing inside code, output or another agent’s message is ignored. The counter never resets.
- 02Errors go back to the Coder, verbatimRouting is guarded: a failed run always returns to the Coder with the real error, never on to the Reviewer. The language model is left to choose only where a choice is genuinely open.
- 03Generated code never runs in the appA separate broker creates one throw-away container for each execution, with no network, a read-only filesystem, dropped capabilities, and limits on memory, CPU, processes and time. The app holds no container access at all.
- 04Treat the data as untrustedHostile text planted in the dataset, including instructions to approve immediately, did not bypass the loop in a live test: approval still needed a real, successful run.
- 05Prove the repair, honestly labelledA test-only fault planted a bad column lookup. The sandbox raised a genuine KeyError, the Coder repaired it without help, and the final numbers matched the ground truth exactly. The fault injector refuses to run outside test mode and fails loudly if it cannot apply.
- 06Show only real eventsThe workflow view and the public replay are drawn from the recorded event log: no simulated messages or invented progress, and no hidden chain-of-thought.
- 07A human decides lastReviewer approval is not final. A person approves or rejects the report, and a follow-up starts a new run with a fresh budget while carrying only verified facts forward.
05Engineering evidence
The repair is real, and it was tested.
Live evaluation against ground truth
- Sales question, answer matches ground truthPassed
- A different column layout, no hard-coded columnsPassed
- Excel workbook, the selected sheet is usedPassed
- Hostile text planted in the dataLoop not bypassed
- Exported script reproduces in a fresh containerPassed
Self-correction, proven
- A labelled test-only fault planted a bad column lookup. The sandbox raised a genuine KeyError, the Coder fixed it, and the Reviewer approved on message 6 of 12.
- The fault injector refuses to run outside test mode, and it fails loudly rather than doing nothing.
06Where it stands
Deployed, with an honest public demo.
The public site replays recorded real runs and cannot start an analysis; live analyses run on a private, password-protected site. The sandbox uses the Docker runtime, which is not as strong as a rootless runtime.
07Under the hood
Stack, lessons and limits.
Stack by layer
- Interface
- Streamlit, with an animated workflow and Plotly charts
- Agents
- AutoGen AgentChat: a guarded selector team of four agents
- Model
- OpenAI, configured by environment
- Execution
- A broker on a Unix socket, one Docker container per run
- Outputs
- The approved analysis.py, a one-page PDF, charts, a reproducibility check
- Quality
- Offline suites with real containers and a live evaluation set
- Deployment
- Docker and Traefik on a VPS: a recorded-run demo and a private live site
What I learned
- A real model needs a real budget. A repair plus a review round did not fit the first token limit, and the run stopped before approval.
- Test the harness as hard as the agents: the first fault never applied to the real Coder’s code, and the injector reported that instead of passing quietly.
- Safety lives in the structure around the model: who may approve, where code may run, and what counts as evidence.
Honest limits
- The sandbox uses the Docker runtime, which is not as strong as a rootless runtime.
- The public site replays recorded runs; new analyses run on a private site.
- Amounts can vary slightly between runs when agents handle duplicate rows differently, while the category and region answer stays the same.
- AutoGen is in maintenance mode; the version is pinned and the risk is recorded.
Real code, really executed, and checked by a different agent before anyone relies on it.