Skip to content

fix(responses): forward url_citation annotations on streaming bridge - #43818

Open
gokay-ai wants to merge 4 commits into
BerriAI:mainfrom
gokay-ai:fix/responses-bridge-stream-annotations-43817
Open

gokay-ai wants to merge 4 commits into
BerriAI:mainfrom
gokay-ai:fix/responses-bridge-stream-annotations-43817

Conversation

@gokay-ai

Copy link
Copy Markdown

Fixes

Fixes #43817

What

OpenAiResponsesToChatCompletionStreamIterator had no branch for response.output_text.annotation.added, so Chat Completions bridged to Responses (openai/responses/...) dropped url_citation annotations when stream=True even though stream=False already returned them.

This maps that event onto delta.annotations the same way native Chat Completions streams do.

Test

  • Unit test for the annotation.added → delta.annotations path
  • Offline repro from the issue (httpx transport mock) now returns the citation on both paths

Thanks!

@gokay-ai
gokay-ai requested review from a team and a balanced review from Copilot September 30, 2026 06:26

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

response.output_text.annotation.added was unhandled in the Chat Completions
bridge, so stream=True dropped citations that stream=False already returned.

Fixes BerriAI#43817

Signed-off-by: GokayAI <[email protected]>
@gokay-ai
gokay-ai force-pushed the fix/responses-bridge-stream-annotations-43817 branch from 0351089 to ba37068 Compare September 30, 2026 06:26
@greptile-apps

greptile-apps Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 4/5

[Medium risk] Adds annotation forwarding to streaming response transformation.

This PR is not ready to merge until streamed citations use the Chat Completions shape and the explicit comment requirement is met

Findings

  1. P1 Flat citations break clients ▶
  2. P2 Redundant comments violate guidance ▶

Summary

The PR forwards Responses streaming annotation events to Chat Completions deltas and narrows proxy streaming and during-call guardrail capability checks

  • The annotation bridge preserves the Responses shape rather than producing the nested Chat Completions citation shape
  • Added explanatory comments conflict with the repository’s comment guidance

Reviews (1) · Last reviewed commit: 0351089

Comment on lines +1570 to +1573
raw_annotation = parsed_chunk.get("annotation")
annotations = LiteLLMResponsesTransformationHandler._convert_annotations_to_chat_format(
[raw_annotation] if raw_annotation is not None else None
)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Flat citations break clients Responses annotations have flat url and title fields, but this code forwards them unchanged. Chat Completions clients expecting a nested url_citation object cannot read the citation

Comment thread litellm/proxy/utils.py Outdated
Comment on lines +1199 to +1203
"""True unless the guardrail is request-only (``pre_call`` / ``pre_mcp_call``).

Streaming fast-path gates must not treat a purely pre-call guardrail as a
reason to pay the per-chunk ``async_post_call_streaming_hook`` path.
"""

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Redundant comments violate guidance These docstrings restate simple predicates. Similar comments appear in the annotation branch and tests. Repository guidance permits comments only for necessary complex logic, tool inputs, or TODOs; this requirement must be met before merging

Context Used: AGENTS.md (source)

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

@CLAassistant

CLAassistant commented Sep 30, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@codspeed

codspeed Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 31 untouched benchmarks


Comparing gokay-ai:fix/responses-bridge-stream-annotations-43817 (61e6af9) with main (6bc17f9)

Open in CodSpeed

@codecov

codecov Bot commented Sep 30, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Type-discipline gate failed: the new list wrappers for annotation.added
exceeded the LIT002 ceiling. Match existing stream-branch annotations.

Signed-off-by: GokayAI <[email protected]>
@gokay-ai

Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

Keep mutable-ok on the list-literal line and satisfy ruff format.

Signed-off-by: GokayAI <[email protected]>
Stream iterator calls the shared private converter; basedpyright budget
failed once LIT002 cleared. Match other cross-class helper ignores.

Signed-off-by: GokayAI <[email protected]>

This branch has not been deployed

No deployments
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.

[Bug]: Responses bridge drops url_citation annotations when stream=True

3 participants