Skip to content

fix: tolerate partial LiteLLM citations#3655

Open
devin-lai wants to merge 2 commits into
openai:mainfrom
devin-lai:fix/litellm-citation-annotations
Open

fix: tolerate partial LiteLLM citations#3655
devin-lai wants to merge 2 commits into
openai:mainfrom
devin-lai:fix/litellm-citation-annotations

Conversation

@devin-lai

Copy link
Copy Markdown

Summary

Fix LiteLLM citation annotation conversion so provider-shaped partial URL citations do not raise KeyError or produce unusable empty citations. The converter now preserves valid citation data, defaults missing title and index fields safely, skips entries without citation URLs, and returns None when no usable citations remain.

Test plan

  • uv run pytest tests/models/test_litellm_annotations.py
  • PATH="/usr/bin:/bin:/usr/sbin:/sbin:/Users/ldy/.local/bin:/Users/ldy/miniforge3/bin:/opt/homebrew/bin" bash .agents/skills/code-change-verification/scripts/run.sh

Issue number

N/A

Checks

  • I've added new tests (if relevant)
  • I've added/updated the relevant documentation
  • I've run make lint and make format
  • I've made sure tests pass

@github-actions

Copy link
Copy Markdown
Contributor

This PR is stale because it has been open for 10 days with no activity.

@github-actions github-actions Bot added the stale label Jun 29, 2026
@devin-lai devin-lai marked this pull request as ready for review June 29, 2026 02:32

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0a3942c739

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +865 to +866
results.append(
Annotation(

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Propagate converted annotations to run output

When LiteLLM returns a valid message.annotations list, this helper now builds Annotation objects, but the non-streaming LitellmModel.get_response path immediately passes the message into Converter.message_to_output_items, which still creates ResponseOutputText(..., annotations=[]) in src/agents/models/chatcmpl_converter.py. As a result, users of Runner.run still receive empty annotations even though this converter accepted the citation, and the new tests miss that end-to-end path.

Useful? React with 👍 / 👎.

@github-actions github-actions Bot removed the stale label Jun 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants