feat(openai): Add gen_ai.request.reasoning.level to OpenAI spans - #6892
Conversation
…s Api Read `effort` field from the `reasoning`request parameter from `responses.create()` and set it on the gen_ai span as `gen_ai.request.reasoning_level`. `reasoning`may be passed as a dict or as the SDK's `Reasoning`object. Refs #6878 Refs PY-2621
…ons Api Read `reasoning_effort` request parameter from `chat.completions.create()` and set it on the gen_ai span as `gen_ai.request.reasoning_level`. Refs #6877 Refs PY-2620
Codecov Results 📊✅ 98651 passed | ⏭️ 6806 skipped | Total: 105457 | Pass Rate: 93.55% | Execution Time: 360m 11s 📊 Comparison with Base Branch
➖ Removed Tests (1)View removed tests
All tests are passing successfully. ✅ Patch coverage is 100.00%. Project has 2508 uncovered lines. Coverage diff@@ Coverage Diff @@
## main #PR +/-##
==========================================
+ Coverage 89.69% 89.72% +0.03%
==========================================
Files 193 193 —
Lines 24437 24402 -35
Branches 8660 8648 -12
==========================================
+ Hits 21919 21894 -25
- Misses 2518 2508 -10
- Partials 1398 1400 +2Generated by Codecov Action |
alexander-alderman-webb
left a comment
There was a problem hiding this comment.
Can you also co-locate assertions with assertions on other request configuration such asgen_ai.request.top_p, gen_ai.request.temperature, etc ...
That way, we ensure that the attribute is set in all scenarios we test against, such as streaming and non-streaming, sync and async, etc ...
Only extract `effort` from dict `reasoning` in the Responses API. Refs #6878
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit a509b01. Configure here.
|
As discussed in person, adding the assertions to existing tests is ugly because it's not available on old |
…rom Completions API
|
You can merge whenever you've passed CI since I've approved the PR already. |

Description
Add
gen_ai.request.reasoning.levelto OpenAI spans for:reasoning.effortreasoning_effortIssues
Refs: #6877 & #6878; PY-2620 & PY-2621
Reminders
uv run ruff.feat:,fix:,ref:,meta:)