What this thread does
Do first: Make the delegating callback async def and call the inner agent with await agent.run(...).
Symptom
SuperMasterBlasterLaser reported an outer agent freezing when a synchronous output function delegates to another agent using run_sync. The report names a hang, not an error string. It lists Pydantic AI 1.39.0; the separate OpenRouter provider-selection error in the same report is outside this fix.
Other users commented on the issue; the discussion includes dsfaccini, DouweM, IgnazioDS.
Cause
Synchronous callbacks normally execute in worker threads. Starting another synchronous agent run there can create a second event loop while the parent waits. Access to an async resource owned by the parent loop can then deadlock. The merged change rejects that nested synchronous execution. Merged PR.
Fix
1. Convert the delegating tool or output function to async def and await the inner agent run. Source. 2. Keep run_sync() only at the application entry point outside an agent run. The parent can remain synchronous. Source. 3. Upgrade to v2.32.1 or a later stable release for the explicit rejection of nested run_sync() and run_stream_sync() calls. Source.
As of November 2026, v2.73.0 source retains this advice. The tagged troubleshooting guide still requires async delegation inside a run and permits a synchronous outer entry point.
Fixed in
Fixed in v2.32.1 (released 2026-08-20), the first carrying stable release; PR #7277 merged 2026-08-19.
If it still fails
- The release adds a guard and an actionable UserError; upgrading does not make nested synchronous callbacks supported. If the async callback also needs blocking work, the current documentation says to move only that part into
asyncio.to_thread().
Not for: OpenRouter returning an unsupported tool_choice value error; the original report tracks that separately from the nested-run hang.
Sources
- Tool output function with delegated another Agent inside, does not work reliably in sync environment. The
run_syncfreezes., SuperMasterBlasterLaser, opened 2026-01-02; closed as completed on 2026-08-19: "sometimes it just freezes." - Reject
Agent.run_sync()from synchronous callbacks inside agent runs, dsfaccini; merged 2026-08-19 (closed). - v2.32.1, released 2026-08-20.
- v2.73.0, released 2026-11-24.
- Tagged source: docs/troubleshooting.md, v2.73.0.
- Tagged source: docs/multi-agent-applications.md, v2.73.0.
Checked
2026-11-24; read the issue and comments API records, merged PR and changed-file records, fix and v2.73.0 release records, and the tagged source pages listed above; no command was run.
Started from a post by @SuperMasterBlasterLaser, packaged by the editor. Original post