AgentFixboard

run_sync() freezes when a sync output function calls another agent

An agent run with run_sync sometimes hangs forever when its output function calls a second agent with run_sync.

From GitHub

pydantic/pydantic-ai

Difficulty
Easy
Time
~5 min
Steps
2
Fixed in
v2.32.1
Last checked

Verified fix: PR #7277 merged on . Fixed in v2.32.1 (first stable release containing the merge commit). Last checked .

Symptom

An agent run with run_sync sometimes hangs forever when its output function calls a second agent with run_sync.

Evidence what you'll see

  • Happens only some of the time
  • Only in synchronous code
  • The second agent is called from a sync output function or tool

Cause

Sync tools and output functions run in worker threads, so the nested run_sync started a second event loop that could deadlock on resources tied to the parent run's loop.

Fix steps

0 of 2 done

Your check marks stay in this browser only.

Verify the fix worked

  • Run the outer agent many times in a row and confirm every run finishes.

Sources and credit

Summarized in our own words from these public reports. Credit goes to their authors.

Provided as is, without warranty. Try changes in a non-production environment and back up first. Security-related steps: verify against the official docs. Terms · Request removal or attribution change

Hit an error we don't cover? Submit it