Skip to content

Add deep-research routing and GPT-5.2 model support to OpenAI client#550

Merged
phenobarbital merged 7 commits intoui-implementationfrom
codex/update-openaiclient-for-new-models
Feb 4, 2026
Merged

Add deep-research routing and GPT-5.2 model support to OpenAI client#550
phenobarbital merged 7 commits intoui-implementationfrom
codex/update-openaiclient-for-new-models

Conversation

@phenobarbital
Copy link
Owner

Motivation

  • Support OpenAI "deep research" workflows by allowing the client to route requests to the new deep-research models and include research-specific tooling and payload flags.
  • Ensure structured-output support for the new gpt-5.2 model so JSON/structured outputs work as expected.

Description

  • Add GPT5_2 = "gpt-5.2" to the OpenAIModel enum and include OpenAIModel.GPT5_2.value in STRUCTURED_OUTPUT_COMPATIBLE_MODELS so structured output is allowed with that model.
  • Add a static helper OpenAIClient._resolve_deep_research_model to pick between o3-deep-research and o4-mini-deep-research and use it when deep_research is requested.
  • Update ask and ask_stream routing to honor the deep_research flag by switching models when appropriate, merging research tools into the request, and always including a code_interpreter tool container with "memory_limit": "4g" when enable_code_interpreter is set.
  • Ensure the background flag is propagated into Responses API payloads by adding it to _prepare_responses_args and setting args['background'] = True when deep_research and background are both true.

Testing

  • No automated tests were executed for these changes.

Codex Task

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request adds support for OpenAI's GPT-5.2 model and implements deep-research routing capabilities, enabling the client to automatically switch to specialized deep-research models (o3-deep-research and o4-mini-deep-research) when the deep_research flag is enabled. The changes also introduce a background execution flag for long-running research tasks and enhance the code interpreter tool with configurable memory limits.

Changes:

  • Added GPT-5.2 model enum and marked it as structured-output compatible
  • Implemented _resolve_deep_research_model helper to intelligently route requests to appropriate deep-research models based on the source model
  • Updated both ask and ask_stream methods to honor the deep_research flag with automatic model switching and specialized tool configuration
  • Added background flag propagation to Responses API payloads for async research execution
  • Configured code interpreter tools with 4GB memory limits when used in deep-research mode

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
parrot/models/openai.py Added GPT5_2 enum value for the "gpt-5.2" model
parrot/clients/gpt.py Added GPT-5.2 to structured output compatible models, implemented deep-research model resolution logic, updated tool configurations with memory limits, and added background flag support to Responses API

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +232 to +241
@staticmethod
def _resolve_deep_research_model(model_str: str) -> str:
"""Resolve the deep research model based on the requested model."""
normalized = (model_str or "").strip()
if normalized in {
OpenAIModel.O4_MINI.value,
OpenAIModel.O4_MINI_DEEP_RESEARCH.value,
}:
return OpenAIModel.O4_MINI_DEEP_RESEARCH.value
return OpenAIModel.O3_DEEP_RESEARCH.value
Copy link

Copilot AI Feb 4, 2026

Choose a reason for hiding this comment

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

The new GPT-5.2 model support and updated deep research routing logic lack test coverage. The codebase has comprehensive test coverage for OpenAI client functionality (see tests/test_openai_client.py), including existing deep research tests. New tests should be added to verify: 1) GPT-5.2 is properly added to STRUCTURED_OUTPUT_COMPATIBLE_MODELS and structured outputs work with it, 2) the _resolve_deep_research_model method correctly routes o4-mini to o4-mini-deep-research and other models to o3-deep-research, 3) the background flag is properly propagated through the Responses API, and 4) the memory_limit configuration is correctly added to the code_interpreter tool when deep_research is enabled.

Copilot uses AI. Check for mistakes.
Copy link
Owner Author

Choose a reason for hiding this comment

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

@copilot open a new pull request to apply changes based on this feedback

Comment on lines 677 to +680
if enable_code_interpreter:
research_tools.append({
"type": "code_interpreter",
"container": {"type": "auto"}
"container": {"type": "auto", "memory_limit": "4g"}
Copy link

Copilot AI Feb 4, 2026

Choose a reason for hiding this comment

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

The code_interpreter tool configuration includes a "container" field with "memory_limit": "4g". This syntax should be verified against OpenAI's actual API documentation for the Responses API and deep research models. While the format appears consistent with Docker memory limits used elsewhere in the codebase (see parrot/tools/codeinterpreter/executor.py), OpenAI's API may use different syntax or may not support the container.memory_limit parameter at all. If this parameter is not supported, the API call may fail with an "unknown_parameter" error.

Copilot uses AI. Check for mistakes.
Copy link
Owner Author

Choose a reason for hiding this comment

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

@copilot open a new pull request to apply changes based on this feedback

Comment on lines 992 to +995
if enable_code_interpreter:
research_tools.append({
"type": "code_interpreter",
"container": {"type": "auto"}
"container": {"type": "auto", "memory_limit": "4g"}
Copy link

Copilot AI Feb 4, 2026

Choose a reason for hiding this comment

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

The code_interpreter tool configuration includes a "container" field with "memory_limit": "4g". This syntax should be verified against OpenAI's actual API documentation for the Responses API and deep research models. While the format appears consistent with Docker memory limits used elsewhere in the codebase (see parrot/tools/codeinterpreter/executor.py), OpenAI's API may use different syntax or may not support the container.memory_limit parameter at all. If this parameter is not supported, the API call may fail with an "unknown_parameter" error.

Copilot uses AI. Check for mistakes.
Copy link
Owner Author

Choose a reason for hiding this comment

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

@copilot open a new pull request to apply changes based on this feedback

Copy link
Contributor

Copilot AI commented Feb 4, 2026

@phenobarbital I've opened a new pull request, #555, to work on those changes. Once the pull request is ready, I'll request review from you.

Copy link
Contributor

Copilot AI commented Feb 4, 2026

@phenobarbital I've opened a new pull request, #556, to work on those changes. Once the pull request is ready, I'll request review from you.

Copy link
Contributor

Copilot AI commented Feb 4, 2026

@phenobarbital I've opened a new pull request, #557, to work on those changes. Once the pull request is ready, I'll request review from you.

[WIP] Update deep-research routing and GPT-5.2 model support
[WIP] Update routing for deep-research and GPT-5.2 model support
…-one

[WIP] Update deep-research routing and GPT-5.2 model support
@phenobarbital phenobarbital merged commit de1caae into ui-implementation Feb 4, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants