Dynamic Workflows: feature that enabled the Bun rewrite Pydantic AI has introduced Dynamic Workflows, a new feature in its Pydantic AI Harness that allows AI models to orchestrate multiple agents by writing Python scripts at runtime. The feature was inspired by Jarred Sumner's use of a similar workflow to rewrite the Bun runtime from Zig to Rust in 11 days, using 64 Claude agents at peak to port over half a million lines of code while passing 100% of existing tests. Dynamic Workflows enable developers to hand a catalog of named agents to an orchestrator model, which then writes and executes scripts that call sub-agents as async functions, with results returned in a single tool call. TL;DR: Models are pretty good at orchestrating more of themselves. With Pydantic AI DynamicWorkflows you can easily create your swarm of agents. Bun got rewritten in Rust. Jarred took "Rewrite it in Rust bro" quite seriously. Then he published the blog post everyone was waiting for https://bun.com/blog/bun-in-rust?utm source=pydantic . A couple of things stood out to me. - Dynamic Workflows - Jarred being a cracked dev who would have guessed What Jarred actually did The numbers are silly, but I will cite them anyway. Half a million lines of Zig ported, a diff of just over a million lines. 100% of the existing test suite still passing Eleven days from first commit to merge. I would love to imagine Jarred prompting, "Yo dawg too many memory errors, can we do this in Rust?". The actual workflow however was more nuanced. He set up workflows where agents wrote plans for other agents. One workflow figured out Rust lifetimes for every struct field, another ported files. About 50 of these workflows ran over the 11 days, 64 Claudes at a time at peak, every file reviewed by two adversarial agents, you get the picture. Do this in a loop and there you have it, Bun in Rust. Models, it turns out, are pretty damn good at orchestrating more of themselves. Can I get some of that in Pydantic AI? Yes. Absolutely You could already get pretty close. We've had Code Mode https://pydantic.dev/articles/your-agent-would-rather-write-code for a while: instead of picking tools off a menu one call at a time, the model writes a Python script that calls them. Wire your agents in as tools, and you'd get part of the way there. You don't have to do that plumbing anymore. Dynamic workflows are now a first-class capability in the Pydantic AI Harness https://pydantic.dev/docs/ai/harness/ . How does it work? DynamicWorkflow is Code Mode moved up a level. Code Mode gives the model a script for its tools . DynamicWorkflow gives it a script for its agents . You hand it a catalog of named agents. It hands the model a single tool. Inside that tool the model writes ordinary Python, where each sub-agent is an async function it can call, loop over, and combine or even graph if you know you know . The whole script runs in one tool call, and only the last line finds its way back into context. It looks something like this: python import logfire from pydantic ai import Agent from pydantic ai harness.experimental.dynamic workflow import DynamicWorkflow logfire.configure logfire.instrument pydantic ai reviewer = Agent 'anthropic:claude-sonnet-5', name='reviewer', description='Reviews code for bugs.' summarizer = Agent 'anthropic:claude-sonnet-5', name='summarizer', description='Summarizes findings.' orchestrator = Agent 'anthropic:claude-opus-4-8', capabilities= DynamicWorkflow agents= reviewer, summarizer , The script the orchestrator writes at runtime looks something like this. It fans out, chains the results, and only the result survives: python import asyncio reports = await asyncio.gather reviewer task="Review auth.py for bugs:\n