ChainWeaver: Compile Deterministic Agent Tool Flows, No LLM Between Steps
Last Updated on August 19, 2026 by Editorial Team
Author(s): Diogo Santos
Originally published on Towards AI.
Your agent keeps re-deciding the same tool path on every turn. Compile it once into a typed, LLM-free flow — and watch the data-corruption rate drop from 61–96% to 0%.
Your agent works. It also does something quietly wasteful on every single turn.

The article explains why typical LLM-driven tool loops waste time and introduce data corruption when the tool path is deterministic: naïve chains repeatedly ask the model what to do next between steps, causing unnecessary latency and higher odds of schema/field corruption. It introduces ChainWeaver as a compiler for deterministic tool flows, using typed Tool definitions plus a FlowExecutor that enforces strict Pydantic validation on every boundary with zero model calls between steps, making intermediate data integrity structurally impossible to degrade. It then walks through how the library’s primitives (Tool, Flow, FlowExecutor) work, how offline analysis and runtime observation (ChainAnalyzer/ChainObserver) can suggest or propose compiled flows, and how to try the project quickly via PyPI install and a runnable example (including CLI utilities for validation, visualization, and auditing). Finally, it summarizes benchmark results focused on correctness and latency tradeoffs, reporting 0.0% compiled corruption versus 61–96% naïve corruption, outlines honest alpha limitations (envelope vs. truthfulness, determinism depends on tool behavior), and concludes with key takeaways: compile repeated deterministic interior tool paths, keep the model only for routing/open-ended decisions, and treat ChainWeaver as a deterministic execution layer that complements broader agent frameworks.
Read the full blog for free on Medium.
Join thousands of data leaders on the AI newsletter. Join over 80,000 subscribers and keep up to date with the latest developments in AI. From research to projects and ideas. If you are building an AI startup, an AI-related product, or a service, we invite you to consider becoming a sponsor.
Published via Towards AI
Towards AI Academy
We Build Enterprise-Grade AI. We'll Teach You to Master It Too.
15 engineers. 100,000+ students. Towards AI Academy teaches what actually survives production.
Start free — no commitment:
→ 6-Day Agentic AI Engineering Email Guide — one practical lesson per day
→ Agents Architecture Cheatsheet — 3 years of architecture decisions in 6 pages
Our courses:
→ AI Engineering Certification — 90+ lessons from project selection to deployed product. The most comprehensive practical LLM course out there.
→ Agent Engineering Course — Hands on with production agent architectures, memory, routing, and eval frameworks — built from real enterprise engagements.
→ AI for Work — Understand, evaluate, and apply AI for complex work tasks.
Note: Article content contains the views of the contributing authors and not Towards AI.