fix(openai): capture reasoning_effort and verbosity in model parameters - #1900
Conversation
Co-authored-by: Hassieb Pakzad <hassiebp@users.noreply.github.com>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
@claude review |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
What does this PR do?
The
langfuse.openaiwrapper buildsmodelParametersfrom 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:
reasoning_effortandverbosity(top-level kwargs).reasoning.effortbecomesreasoning_effort,reasoning.summarybecomesreasoning_summary,text.verbositybecomesverbosity, andmax_output_tokensis 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. Whenmax_output_tokensis set, it replaces the placeholdermax_tokens: inf, the same waymax_completion_tokensalready does.A param is only recorded when the caller passes it;
NoneandNOT_GIVENare skipped.Type of change
Verification
ruff format --check .flagstests/unit/test_media.py. That file is unchanged here and fails the same way onmain.Checklist
code_review.md..env.templateif needed.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.
max_output_tokensreplacing themax_tokensplaceholder.Reviews (1) · Last reviewed commit: "fix(openai): capture reasoning_effort an..."