Skip to content

Comments

FEAT: add reasoning_effort and reasoning_summary to OpenAIResponseTarget#1385

Open
romanlutz wants to merge 7 commits intoAzure:mainfrom
romanlutz:romanlutz/response_api_reasoning
Open

FEAT: add reasoning_effort and reasoning_summary to OpenAIResponseTarget#1385
romanlutz wants to merge 7 commits intoAzure:mainfrom
romanlutz:romanlutz/response_api_reasoning

Conversation

@romanlutz
Copy link
Contributor

Adds first-class support for the OpenAI Responses API reasoning parameter. Users can now control reasoning effort (minimal/low/medium/high) and optionally request reasoning summaries (auto/concise/detailed).

Uses ReasoningEffort type from the OpenAI SDK directly.

Closes #1384

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 PR adds first-class support for OpenAI's reasoning parameters to the OpenAIResponseTarget class, enabling users to control the depth of reasoning and request reasoning summaries for compatible models (o1, o3, o4-mini, GPT-5).

Changes:

  • Added reasoning_effort and reasoning_summary parameters to OpenAIResponseTarget.__init__(), supporting values from the OpenAI Responses API
  • Implemented _build_reasoning_config() helper method to construct the reasoning configuration for API requests
  • Enhanced console printer to display reasoning summaries when include_reasoning_trace=True
  • Added comprehensive unit and integration tests covering all reasoning parameter combinations

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.

Show a summary per file
File Description
pyrit/prompt_target/openai/openai_response_target.py Added reasoning parameters to constructor, request body building, and target identifier; improved defensive checks in _find_last_pending_tool_call()
tests/unit/target/test_openai_response_target.py Added 8 new unit tests covering initialization and request body construction with reasoning parameters
tests/integration/targets/test_openai_responses_gpt5.py Added integration tests for reasoning parameters; fixed roleapi_role for consistency
tests/integration/targets/test_entra_auth_targets.py Added integration tests for reasoning parameters with Entra authentication
pyrit/executor/attack/printer/console_printer.py Added _extract_reasoning_summary() method and logic to display reasoning summaries in console output
doc/code/targets/2_openai_responses_target.py Added documentation section explaining reasoning configuration with usage example
doc/code/targets/2_openai_responses_target.ipynb Jupyter notebook version of documentation with executed example output

romanlutz and others added 7 commits February 21, 2026 06:27
Adds first-class support for the OpenAI Responses API reasoning parameter.
Users can now control reasoning effort (minimal/low/medium/high) and
optionally request reasoning summaries (auto/concise/detailed).

Uses ReasoningEffort type from the OpenAI SDK directly.

Closes Azure#1384

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
… type, add Entra integration tests

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…notebook

Adds a new section demonstrating reasoning_effort and reasoning_summary
parameters with a working example. Regenerated .ipynb from .py.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Console printer now shows reasoning summaries (with 💭 emoji) when
  available, and silently skips reasoning pieces with empty summaries.
- Updated notebook to use high reasoning_effort + detailed summary with
  a thinking-heavy prompt to demonstrate reasoning output.
- Removed gpt-4.1 from reasoning Entra tests (not a reasoning model).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Reasoning with summary: always shown
- Reasoning without summary + include_reasoning_trace=True: show raw trace
- Reasoning without summary + include_reasoning_trace=False: skip (default)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Gate reasoning summary display on include_reasoning_trace flag
- Use blank line + color contrast (cyan vs yellow) to distinguish
  reasoning summary from text response (no separator line that could
  be confused with turn boundaries)
- Notebook passes include_reasoning_trace=True to show summaries

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…ion tests

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@romanlutz romanlutz force-pushed the romanlutz/response_api_reasoning branch from 74ff735 to 3482fbe Compare February 21, 2026 14:30
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.

FEAT: OpenAIResponseTarget should support reasoning levels

1 participant