feat: add response_format to CallModelInputFilter callback#3586
feat: add response_format to CallModelInputFilter callback#3586Oxygen56 wants to merge 1 commit into
Conversation
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>
There was a problem hiding this comment.
💡 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".
| js = self._response_format.get("json_schema") | ||
| if isinstance(js, dict): | ||
| schema = js.get("schema") | ||
| if isinstance(schema, dict): | ||
| return schema | ||
| return {} |
There was a problem hiding this comment.
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 👍 / 👎.
Allows CallModelInputFilter to modify response_format, enabling dynamic structured output control per model call.
Closes #3563