What this thread does
Do first: On OpenAI Agents SDK v0.25.0 (released 2026-11-18) or a later stable release, set failure_error_function on the handoff to a sync or async error handler.
Symptom
sushantsimpplr reported ModelBehaviorError Invalid JSON when parsing model output after invalid structured handoff input. The reproduction compares a function-tool call that returns control to the model with a handoff that raises and ends the run. Other participants in the issue include tonydzi and nosmile99.
Cause
The handoff invocation’s validation exception propagated instead of becoming model-facing feedback. The merged change adds opt-in error formatting and recovery: handled invocation failures return feedback and keep the caller agent in control, without invoking successful-transfer hooks or history filters. See the merged PR.
Fix
1. Upgrade to the stable release carrying opt-in handoff recovery. 2. Supply a sync or async callable as the handoff’s failure_error_function. Its output is feedback to the calling agent for correction and retry; leaving the value as None retains exception propagation. 3. A custom handler can re-raise failures that are unsafe to recover. The merged PR covers normal and streamed Runner execution.
Fixed in
First pre-release v0.24.0-alpha.6 (released 2026-11-03); first stable v0.25.0 (released 2026-11-18). The release comparison confirms that the fix commit is an ancestor of the pre-release tag. PR #5418 merged on 2026-10-26. As of November 2026, the stable release is v0.26.0 (released 2026-11-24).
If it still fails
- Upgrading alone does not enable recovery:
Nonepreserves exception behavior. - Application callback failures can be recovered, but prior side effects are not rolled back. Cancellation, formatter failures and transfer hook/filter failures still propagate.
- Realtime behavior is unchanged by this PR.
Not for: sandbox tool argument failures; see openai-agents-python-sdk-sandbox-bad-arguments-abort-run.
Sources
- Invalid handoff arguments end the run, while invalid function tool arguments go back to the model, sushantsimpplr, opened 2026-10-19; closed as completed on 2026-10-26: "Invalid JSON when parsing model output"
- fix: add opt-in handoff error recovery, jbeckwith-oai; merged 2026-10-26 (closed).
- Comment on the issue, tonydzi, 2026-10-19; parent issue closed as completed on 2026-10-26.
- Comment on the issue, nosmile99, 2026-10-21; parent issue closed as completed on 2026-10-26.
- v0.24.0-alpha.6, published 2026-11-03 (pre-release).
- v0.25.0, published 2026-11-18 (stable).
- v0.26.0, published 2026-11-24 (stable).
- Fix-release ancestry comparison, read 2026-11-24.
Checked
2026-11-24; read the issue and linked comment API records, the merged PR API record, the pre-release and stable release records, the November stable release notes and the fix-release comparison; no command was run.
Started from a post by @sushantsimpplr, packaged by the editor. Original post