In short.
This guide explains scripted coordination of Pydantic AI sub-agents for Python developers, but adoption requires careful budget controls and work within a restricted Python sandbox. DynamicWorkflow lets a parent agent write a script that calls specialist agents, processes their results and returns a final value without sending every intermediate result through the parent's context. The documentation distinguishes an exact agent-call ceiling from best-effort shared token limits and explains failure handling, structured outputs and Temporal integration. Pricing and measured performance are unknown; nothing was executed or tested.
Researched and written by an AI model and checked by a second AI model. How it works
Covers the complete documentation page at [https://pydantic.dev/docs/ai/harness/dynamic-workflow/index.md], including setup, examples, output handling, budgets, sandbox restrictions, runtime agent discovery, deferred loading, Temporal integration, observability and the API reference. Includes the 0.x compatibility warning and deprecated duration-option notice. Linked pages, repository files, external articles and separate image assets are excluded. No code was executed; performance, security, compatibility, monetary costs and runtime behavior remain untested.
The overview
What the resource is
Dynamic Workflow is a Pydantic AI Harness documentation guide at [https://pydantic.dev/docs/ai/harness/dynamic-workflow/index.md]. It teaches the DynamicWorkflow capability, which gives an orchestrating agent a run_workflow tool for coordinating named specialist agents through Python scripts.
The resource is a guide to a library feature. Its examples cover installation, agent configuration, scripted coordination and operational limits.
When it fits
The guide is useful when coordinating specialists is itself a substantial task: reviewing several files concurrently, filtering findings, passing results to another agent or implementing repeated attempts. It explains enough of the API and its constraints to help a developer judge whether this approach suits an existing Pydantic AI application.
Its practical advantage is that intermediate coordination happens inside a script instead of requiring the parent to inspect every result between steps. This can reduce information entering the parent's context, but the page provides no measurements of token savings, speed, accuracy or reliability. The benefit depends on the workload and models.
Who it is for
The main audience is Python developers already building with Pydantic AI agents who need parallel specialist work or several dependent delegation steps. Readers benefit from understanding async functions, await, asyncio.gather and basic Pydantic output models.
Beginners get a small reviewer-and-summarizer example, but the page does not provide a complete introduction to Python, model-provider configuration or agent development. It recommends starting with SubAgents when delegations are occasional or each result needs the parent's judgment before proceeding.
What it supports
The model can write scripts that call specialists concurrently, chain their results, loop, vote or retry. Sub-agents can return strings or structured data; a Pydantic output model becomes a dictionary in the sandbox, with fields accessed by subscript.
WorkflowAgent can override a specialist's exposed name and description. reveal() adds agents during a run and validates their names immediately. Deferred loading keeps the capability initially collapsed and requires a stable id. inherit_model=True makes dispatched sub-agents follow the parent's resolved per-run model override.
The page also describes Logfire tracing, per-agent event streaming and TemporalDurability integration. Temporal use requires attaching durability to the relevant agents and registering each through its own AgentPlugin.
Using it
Requirements
The documented installation is pydantic-ai-harness[dynamic-workflow], which includes the extra needed for the Monty sandbox. The host application supplies Pydantic AI agents and models. Each exposed agent needs a name that is a valid Python identifier; its description explains its role to the orchestrator.
The page does not specify a minimum Python version, an exact package release, hardware requirements, provider credentials or a complete provider compatibility list. Third-party libraries cannot be imported inside the orchestration sandbox.
How it works
DynamicWorkflow exposes a catalog of agents as async functions inside Monty. The parent writes a script for run_workflow, and each specialist call must pass its work through the keyword argument task. Every call starts a full Agent.run with separate history, tools, model loop and output. Calls do not remember earlier calls, so each task must contain the information it needs.
The script's last expression supplies its result. Printed text is returned alongside a non-None result, or by itself when the final value is None; without printing, a None result becomes an empty object. Intermediate values stay inside the sandbox unless the script returns or prints them, with bounded completed-result previews also available after failure or budget exhaustion.
Static type checking catches provable mistakes before sandbox execution or sub-agent calls, consuming a retry rather than the agent-call budget. Sub-agent failures surface as RuntimeError and can be caught in the script. An uncaught failure aborts the script and prompts a retry; completed-result previews may help avoid repeating work.
Getting started
Install the extra with pip install "pydantic-ai-harness[dynamic-workflow]" or uv add "pydantic-ai-harness[dynamic-workflow]". Define named specialist Agent instances, then add DynamicWorkflow(agents=[reviewer, summarizer]) to the orchestrator's capabilities.
The examples use the model identifier openai:gpt-6.1-sol. Its availability, account setup and pricing are not established by this page. The API reference lists defaults including tool_name='run_workflow', max_agent_calls=50, max_retries=3, forward_usage=True and inherit_model=False; applications should choose limits deliberately.
Example workflow
The documented example defines a reviewer and a summarizer. The orchestrator generates a script that awaits asyncio.gather over two reviewer(task=...) calls, one containing auth.py and one containing parser.py, then passes the combined reports to summarizer(task=...). The summarizer's output is the last expression and therefore the workflow result.
This illustrates parallel review followed by a dependent summarization step. It does not demonstrate review accuracy, actual runtime or successful execution. A separate structured-output example shows a critic returning a Score model whose value is accessed as result["value"].
Assessment & evidence
Important limitations
Monty implements a subset of Python with no filesystem or environment access and no third-party imports. Available standard-library modules are restricted. Current-time functions and unseeded randomness fail. asyncio.gather accepts positional awaitables without keyword arguments, including return_exceptions=True; other task-creation and wait APIs are unavailable.
The sandbox defaults to a 256 MB memory backstop and no time limit, with a separate 10 MiB printed-output cap. max_duration_seconds measures sandbox execution time and excludes time waiting for sub-agents, so it is not a total workflow deadline. It also caps cumulative script sleep time. These resource limits apply to the script, not the specialists it calls.
Workflows cannot nest: a specialist running inside a workflow is not offered its own run_workflow tool. DeferredToolRequests and PendingModelResponse cannot be handled by the script; such specialist outcomes raise RuntimeError, with best-effort cancellation of pending model work.
For Temporal, a script close to its duration limit can stop at a different point during replay and cause NondeterminismError. The page does not establish security guarantees for the tools available to individual specialists.
Practical tradeoffs
This approach is most compelling when a script can decide how to combine intermediate results without requiring the parent's judgment at every step. Returning only useful final data can limit parent-context growth, while parallel calls can overlap independent work. These are architectural advantages described by the mechanism, not measured performance results.
The tradeoff is that the model must generate valid orchestration code, and failures may occur after some paid specialist work has completed. Exact call limits, explicit token budgets, error handling and clear task inputs matter. Moving coordination into one tool call does not remove the underlying model requests or their uncertainty.
Related approaches
The page recommends SubAgents for occasional delegation or steps that need the parent's judgment between results. Its delegate_task(agent_name, task) interface exposes delegations individually. Existing specialist agents can be reused in a DynamicWorkflow catalog. Further documentation is linked at [https://pydantic.dev/docs/ai/harness/subagents/].
Code Mode uses the same Monty sandbox but exposes the agent's tools rather than whole specialist agents. It is the related option when the script needs to coordinate tool calls directly. Its documentation is linked at [https://pydantic.dev/docs/ai/harness/code-mode/]. Neither linked page was assessed here.
Evidence and confidence
The evidence is the complete Dynamic Workflow documentation page at [https://pydantic.dev/docs/ai/harness/dynamic-workflow/index.md], captured on 15 November 2026 at 03:37:49.539 UTC. It contains installation commands, code examples, operational caveats and an API reference.
The findings describe documented behavior. Nothing was executed, and no independent benchmarks, runtime traces, package contents or implementation files were assessed. The illustration's accompanying text explains the intended architecture; it does not demonstrate execution.
Access & freshness
Costs and budget controls
Monetary cost is unknown. The page provides no model prices, representative token totals, subscription charges or measured workflow costs. Each specialist call uses its own model loop and consumes tokens and time; one orchestration tool call can therefore contain substantial model usage.
max_agent_calls defaults to 50 and is an exact, host-enforced ceiling shared across all run_workflow calls in one parent run, including concurrent calls. sub_agent_usage_limits applies UsageLimits to specialist runs. With forward_usage=True, usage is shared across the tree, but concurrent calls can pass a token-budget check before other calls update the counter, making that cap best-effort.
With forward_usage=False, limits apply separately to each specialist run. The page describes a per-run token limit T and call ceiling N as giving roughly N × T tokens. Without explicit sub-agent limits, shared usage follows the parent's run limits; separate usage falls back to a default request_limit of 50 per run. These controls do not establish an exact monetary ceiling.
Licensing and rights
The page links to the implementation at [https://github.com/pydantic/pydantic-ai/tree/main/src/pydantic_ai_harness/pydantic_ai_harness/dynamic_workflow/], but it does not include licence terms for the library, documentation or examples. Redistribution rights and attribution requirements are unknown from this evidence.
Model-provider terms and rights relating to submitted code or generated outputs are also not established. A repository link alone does not establish those permissions.
Version and freshness limits
The page warns that Pydantic AI Harness APIs may change between minor releases while the project is on 0.x versions, with deprecation warnings and release-note migration guidance. It does not identify an exact package version or publication date. The capture timestamp establishes when this text was acquired, not when the feature last changed.
max_duration_secs is documented as a deprecated alias for max_duration_seconds that still works with a warning. Compatibility with any particular installed release remains unassessed.
How to evaluate adoption
Start by deciding whether delegations are occasional or whether each result needs the parent agent's judgment before the next step. If so, or if you are unsure, follow the page's recommendation to begin with SubAgents. If the work naturally forms parallel branches or scripted chains, use the reviewer-and-summarizer example as a small starting point.
Before relying on a workflow, verify the installed API version, model access and applicable licence terms. Set an explicit call ceiling and token limits, decide whether usage should be shared, and supply complete context in each task. Use the documented Logfire trace, which nests each sub-agent run under the run_workflow span and records the exact script the model wrote, or set event_stream_handler on each sub-agent to watch its runs inside the single tool call. Actual behavior and costs still require evaluation in the intended application.
