Skip to content

feat: add invalid final output recovery handler - #3736

Merged
seratch merged 1 commit into
mainfrom
feat/invalid-final-output-handler
Jul 6, 2026
Merged

feat: add invalid final output recovery handler#3736
seratch merged 1 commit into
mainfrom
feat/invalid-final-output-handler

Conversation

@seratch

@seratch seratch commented Jul 6, 2026

Copy link
Copy Markdown
Member

This pull request adds an invalid_final_output run error handler for structured output validation failures and missing structured final messages.

The handler can return a schema-validated fallback, optionally append it to conversation history, and participates in the normal final-output hooks, guardrails, streaming events, and session persistence. Returning None preserves existing behavior: malformed non-empty output raises ModelBehaviorError, while empty structured output continues to another model turn.

Recovery does not retry the model request or replay completed tool side effects. Explicit error-kind dispatch also prevents unrelated ModelBehaviorError instances from being handled accidentally.

Resolves #325

@seratch seratch added this to the 0.17.x milestone Jul 6, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 20198e12c6

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/agents/run_error_handlers.py
@seratch
seratch merged commit 3d07ff1 into main Jul 6, 2026
9 checks passed
@seratch
seratch deleted the feat/invalid-final-output-handler branch July 6, 2026 06:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Retry mechanism for ModelBehaviorError

1 participant