Skip to content

fix(openai): capture reasoning_effort and verbosity in model parameters - #1900

Merged
hassiebp merged 1 commit into
mainfrom
hassiebbot/openai-reasoning-model-params-9abb
Sep 24, 2026
Merged

hassiebp merged 1 commit into
mainfrom
hassiebbot/openai-reasoning-model-params-9abb

Conversation

@hassiebp

@hassiebp hassiebp commented Sep 24, 2026 •

Copy link
Copy Markdown
Collaborator

What does this PR do?

The langfuse.openai wrapper builds modelParameters from a fixed list of sampling params. GPT-5 reasoning params reach the model, but they never appear under a generation's Model Parameters in the UI.

This PR adds them:

  • Chat Completions: reasoning_effort and verbosity (top-level kwargs).
  • Responses API: reasoning.effort becomes reasoning_effort, reasoning.summary becomes reasoning_summary, text.verbosity becomes verbosity, and max_output_tokens is added. The nested params are flattened to the Chat Completions key names so both APIs show the same keys, and because model parameter values must be scalars. When max_output_tokens is set, it replaces the placeholder max_tokens: inf, the same way max_completion_tokens already does.

A param is only recorded when the caller passes it; None and NOT_GIVEN are skipped.

Type of change

  • Bug fix
  • New feature
  • Breaking change
  • Refactor
  • Documentation update
  • Tooling, CI, or repo maintenance

Verification

uv run --frozen pytest tests/unit/test_openai.py -q      # 37 passed (new tests failed before the fix)
uv run --frozen pytest -n auto --dist worksteal tests/unit  # 682 passed; 18 errors in test_prompt.py also occur on main (no LANGFUSE_PUBLIC_KEY locally)
uv run --frozen ruff check .                             # All checks passed!
uv run --frozen ruff format --check langfuse/openai.py tests/unit/test_openai.py  # 2 files already formatted
uv run --frozen mypy langfuse --no-error-summary         # clean

ruff format --check . flags tests/unit/test_media.py. That file is unchanged here and fails the same way on main.

Checklist

  • I self-reviewed the diff using code_review.md.
  • I added or updated tests for behavior changes.
  • I updated docs, examples, or .env.template if needed.
  • I did not hand-edit generated files; if generated files changed, I used the upstream regeneration path.
  • I did not commit secrets or credentials.
Open in Web Open in Cursor 

RetriggerConfidence Score: 4/5

No blocking runtime defect was identified, but the module-level import requirement must be satisfied before merging.

Summary

The PR adds reasoning, verbosity, and output-token settings to OpenAI generation model parameters.

  • Chat Completions settings are captured from top-level arguments.
  • Responses settings are flattened from nested arguments, with max_output_tokens replacing the max_tokens placeholder.

Reviews (1) · Last reviewed commit: "fix(openai): capture reasoning_effort an..."

Co-authored-by: Hassieb Pakzad <hassiebp@users.noreply.github.com>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 24, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-24T13:12:55.890128Z 9999846 PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions

Copy link
Copy Markdown

@claude review

@claude claude 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.

Claude Code Review

No review was started: this request came from a bot account. Manual reviews can only be requested by someone with write access to this repository. Ask a maintainer to comment @claude review, or have your automation post the comment from a user account with write access.

Tip: disable this comment in your organization's Code Review settings.

@claude claude 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.

Looks good, straightforward addition. Checked the new _parse_reasoning_model_parameters helper and its integration into _get_langfuse_data_from_kwargs (both Chat Completions and Responses API branches), the max_output_tokens/max_tokens pop logic which mirrors the existing max_completion_tokens pattern, and correct reuse of the _get_attr_or_item/_is_not_given helpers for dict vs object and NOT_GIVEN handling. The three new unit tests cover the described cases (Chat Completions params present, params absent/NOT_GIVEN, and Responses API kwargs parsing) and match the implementation.

Extended reasoning...

Small, self-contained change to langfuse/openai.py adding a helper that extracts reasoning-model parameters (reasoning_effort, verbosity, reasoning_summary, max_output_tokens) into modelParameters, plus matching unit tests. No security-sensitive surface (auth, crypto, permissions) is touched; it only affects telemetry/model-parameter capture. The new code follows the exact pattern already used for max_completion_tokens/max_tokens handling in the same function, uses existing well-tested helpers (_get_attr_or_item, _is_not_given) correctly, and the added tests verify all three described scenarios.

@hassiebp
hassiebp merged commit 597f54f into main Sep 24, 2026
23 checks passed
@hassiebp
hassiebp deleted the hassiebbot/openai-reasoning-model-params-9abb branch September 24, 2026 13:31
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.

2 participants