Skip to content

feat: add response_format to CallModelInputFilter callback#3586

Open
Oxygen56 wants to merge 1 commit into
openai:mainfrom
Oxygen56:feat/response-format-filter-3563
Open

feat: add response_format to CallModelInputFilter callback#3586
Oxygen56 wants to merge 1 commit into
openai:mainfrom
Oxygen56:feat/response-format-filter-3563

Conversation

@Oxygen56
Copy link
Copy Markdown

@Oxygen56 Oxygen56 commented Jun 5, 2026

Allows CallModelInputFilter to modify response_format, enabling dynamic structured output control per model call.

Closes #3563

Allows modifying response_format dynamically in the model input
filter callback, enabling per-call structured output control.

Closes openai#3563

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Copy link
Copy Markdown

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

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: 796b285d84

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines +197 to +202
js = self._response_format.get("json_schema")
if isinstance(js, dict):
schema = js.get("schema")
if isinstance(schema, dict):
return schema
return {}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve non-nested response_format schemas

When a filter supplies a raw response format that is not the Chat Completions nested shape, such as Responses-style {"type": "json_schema", "schema": ...} or JSON mode {"type": "json_object"}, this wrapper only looks under json_schema.schema and falls back to {}. The downstream converters then send an unconstrained json_schema request instead of the requested format, so dynamic structured-output filtering silently drops the schema for those supported response_format shapes.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add custom ResponseFormat support in CallModelInputFilter callback

1 participant