Skip to content

Merge branch 'main' into hassieb/lfe-8788-bug-langfuseresponsegenerat…

514171b
Select commit
Loading
Failed to load commit list.
Merged

fix(openai): preserve native v1 stream contract #1627

Merge branch 'main' into hassieb/lfe-8788-bug-langfuseresponsegenerat…
514171b
Select commit
Loading
Failed to load commit list.
Claude / Claude Code Review completed Apr 16, 2026 in 12m 25s

Code review found 2 potential issues

Found 5 candidates, confirmed 2. See review comments for details.

Details

Severity Count
🔴 Important 0
🟡 Nit 0
🟣 Pre-existing 1
Severity File:Line Issue
🟣 Pre-existing langfuse/openai.py:1230-1241 LangfuseResponseGeneratorSync/Async _finalize missing idempotency guard causes double generation.end()

Annotations

Check notice on line 1241 in langfuse/openai.py

See this annotation in the file changed.

@claude claude / Claude Code Review

LangfuseResponseGeneratorSync/Async _finalize missing idempotency guard causes double generation.end()

The `LangfuseResponseGeneratorSync._finalize()` and `LangfuseResponseGeneratorAsync._finalize()` methods lack an idempotency guard, so `generation.end()` (via `_finalize_stream_response`) can be called twice on the same wrapper object. This is a pre-existing issue: the bug predates this PR, and the PR's refactoring of `_finalize` to delegate to the shared `_finalize_stream_response` helper did not add the `is_finalized` guard that the new `_instrument_openai_stream`/`_instrument_openai_async_str