Skip to content

fix(LiteLlm): recognize assistant- prefix as valid OpenAI file ID#5758

Open
nileshpatil6 wants to merge 3 commits into
google:mainfrom
nileshpatil6:fix/lite-llm-assistant-file-id-prefix
Open

fix(LiteLlm): recognize assistant- prefix as valid OpenAI file ID#5758
nileshpatil6 wants to merge 3 commits into
google:mainfrom
nileshpatil6:fix/lite-llm-assistant-file-id-prefix

Conversation

@nileshpatil6
Copy link
Copy Markdown

@nileshpatil6 nileshpatil6 commented May 19, 2026

Azure OpenAI files uploaded with purpose="assistants" receive IDs with an assistant- prefix (e.g. assistant-abc123). _looks_like_openai_file_id only checked for the file- prefix, causing Azure PDF attachments to be silently dropped from requests instead of being routed through the Responses API content block.

Fix: extend the startswith check to include "assistant-".

Also updated _redact_file_uri_for_log to return assistant-<redacted> for assistant- prefixed IDs, consistent with how file- IDs are handled.

Fixes #5664

Testing plan

Added unit tests in tests/unittests/models/test_litellm.py:

  • test_looks_like_openai_file_id (parametrized) covers:
    • file-abc123 -> True (existing behavior)
    • assistant-abc123 -> True (new behavior)
    • https://example.com/file.pdf -> False
    • not-a-file-id -> False
    • empty string -> False
    • FILE-abc123 -> False (case sensitive)
  • test_redact_file_uri_for_log_openai_prefixes (parametrized):
    • file-abc123 -> file-<redacted>
    • assistant-abc123 -> assistant-<redacted> (new behavior)
  • test_redact_file_uri_for_log_uses_display_name_when_provided confirms display_name short-circuits redaction.
  • test_redact_file_uri_for_log_http_url_keeps_scheme_and_tail confirms HTTP URLs still redact host but preserve scheme and filename.

Run locally with:

pytest tests/unittests/models/test_litellm.py -k "looks_like_openai_file_id or redact_file_uri_for_log"

@adk-bot adk-bot added the models [Component] Issues related to model support label May 20, 2026
@adk-bot
Copy link
Copy Markdown
Collaborator

adk-bot commented May 20, 2026

Response from ADK Triaging Agent

Hello @nileshpatil6, thank you for creating this PR to fix the Azure OpenAI assistant prefix issue!

To help our reviewers process this contribution more efficiently and maintain code quality, could you please address the following items from our Contribution Guidelines:

  1. Unit Tests / Testing Plan:
    • Please add or update unit tests to cover this new file ID prefix (assistant-) and verify that redaction behaves correctly under tests/unittests/.
    • Please include a testing plan section in your PR description detailing how you verified the changes (such as a summary of passed pytest results).
  2. Logs or Screenshots:
    • As this is a bug fix, please provide logs or verification output showing how the file is successfully handled now compared to before.

These details will help ensure we prevent regressions and streamline the review process. Thank you again for your contribution!

@rohityan rohityan self-assigned this May 20, 2026
@rohityan rohityan added the request clarification [Status] The maintainer need clarification or more information from the author label May 20, 2026
@rohityan
Copy link
Copy Markdown
Collaborator

Hi @nileshpatil6 , Thank you for your contribution! We appreciate you taking the time to submit this pull request. Can you please fix the failing unit tests before we can proceed with the review.

@nileshpatil6
Copy link
Copy Markdown
Author

hey @rohityan thanks for the review. added unit tests in tests/unittests/models/test_litellm.py covering both the new assistant- prefix recognition and the redact helper. all 10 new tests pass locally along with the rest of test_litellm.py (268 passed, 1 skipped).

the two failing checks on the run dont seem related to this PR:

  • test (3.10): only test_metrics in tests/unittests/telemetry/test_functional.py fails (asserts 2 == 1 on agent metric points), the file isnt touched here
  • pre-commit: formatting diff in tests/.../test_list_gcp_projects_import_error which also isnt touched

happy to look into those if you want but they seem like flakes from main. let me know if anything else needed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

models [Component] Issues related to model support request clarification [Status] The maintainer need clarification or more information from the author

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Title LiteLlm: Azure OpenAI file_id with assistant- prefix bypasses Responses-API content block

3 participants