Commit 796964a
fix(LiteLlm): recognize assistant- prefix as valid OpenAI file ID
Merge #5758
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"
```
Co-authored-by: George Weale <gweale@google.com>
COPYBARA_INTEGRATE_REVIEW=#5758 from nileshpatil6:fix/lite-llm-assistant-file-id-prefix 6b2afd7
PiperOrigin-RevId: 9338987771 parent 2b7e08a commit 796964a
2 files changed
Lines changed: 45 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
395 | 395 | | |
396 | 396 | | |
397 | 397 | | |
| 398 | + | |
| 399 | + | |
398 | 400 | | |
399 | 401 | | |
400 | 402 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
| 43 | + | |
43 | 44 | | |
44 | 45 | | |
45 | 46 | | |
46 | 47 | | |
47 | 48 | | |
| 49 | + | |
48 | 50 | | |
49 | 51 | | |
50 | 52 | | |
| |||
5124 | 5126 | | |
5125 | 5127 | | |
5126 | 5128 | | |
| 5129 | + | |
| 5130 | + | |
| 5131 | + | |
| 5132 | + | |
| 5133 | + | |
| 5134 | + | |
| 5135 | + | |
| 5136 | + | |
| 5137 | + | |
| 5138 | + | |
| 5139 | + | |
| 5140 | + | |
| 5141 | + | |
| 5142 | + | |
| 5143 | + | |
| 5144 | + | |
| 5145 | + | |
| 5146 | + | |
| 5147 | + | |
| 5148 | + | |
| 5149 | + | |
| 5150 | + | |
| 5151 | + | |
| 5152 | + | |
| 5153 | + | |
| 5154 | + | |
| 5155 | + | |
| 5156 | + | |
| 5157 | + | |
| 5158 | + | |
| 5159 | + | |
| 5160 | + | |
| 5161 | + | |
| 5162 | + | |
| 5163 | + | |
| 5164 | + | |
| 5165 | + | |
| 5166 | + | |
| 5167 | + | |
| 5168 | + | |
| 5169 | + | |
0 commit comments