Skip to content

fix: #3055 surface model refusals during run resolution#3057

Merged
seratch merged 1 commit intomainfrom
fix/model-refusal-handling
May 1, 2026
Merged

fix: #3055 surface model refusals during run resolution#3057
seratch merged 1 commit intomainfrom
fix/model-refusal-handling

Conversation

@seratch
Copy link
Copy Markdown
Member

@seratch seratch commented May 1, 2026

This pull request resolves #3055 by making model refusals a first-class run error instead of letting structured-output runs retry until MaxTurnsExceeded.

It adds ModelRefusalError, detects ResponseOutputRefusal during final-output resolution, and supports error_handlers["model_refusal"] so applications can return a controlled fallback final output. It also threads refusal handling through streaming and non-streaming runs, updates tests for default refusal exits and handler fallbacks, and documents the new error handler key in docs/running_agents.md.

Behavior note: model refusals now default to ModelRefusalError rather than becoming an empty plain-text output or an unproductive structured-output retry loop.

@seratch seratch added this to the 0.15.x milestone May 1, 2026
@github-actions github-actions Bot added bug Something isn't working documentation Improvements or additions to documentation feature:core labels May 1, 2026
@seratch seratch merged commit 2d40c09 into main May 1, 2026
10 checks passed
@seratch seratch deleted the fix/model-refusal-handling branch May 1, 2026 05:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working documentation Improvements or additions to documentation feature:core

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Model refusals with structured output aren't handled

1 participant