litellm/tests/unit/llms/github_copilot/messages
giladk1221 a8ebf477a8
fix(github_copilot): convert plain-text documents for native messages (#53554)
* fix(github_copilot): convert plain-text documents for native messages

* fix(github_copilot): skip empty text documents and honor drop_params for citations

An empty untitled text document turned into an empty text block, which Anthropic rejects with a 400 ("text content blocks must be non-empty"). The block is now left out, and a title or context still goes through on its own

With drop_params on, document citations are dropped from every document and the text documents are converted, instead of failing the request with UnsupportedParamsError. Without drop_params the request still fails with the same error

Tool result content is read one level deep instead of recursively, since a tool result never holds another tool result

* fix(github_copilot): keep a turn of only empty text documents non-empty

Anthropic accepts a user turn that holds only an empty text document,
but once the Copilot adapter leaves that document out the turn has no
content and Copilot answers 400. Such a turn now gets the empty-content
placeholder text LiteLLM already sends on Anthropic routes, keeping the
last cache breakpoint.

* fix(github_copilot): pass request params through and keep cache breakpoints of dropped documents

The Copilot override handed the shared transformer a copy of the request
params, so max_tokens and the translated thinking no longer reached the
shared handler the way they do on every other Anthropic-shaped adapter.
It now passes the caller's dicts through, as the merge base did.

An untitled text document holding only whitespace is now left out like
an empty one, since Anthropic rejects a whitespace-only text block. A
left-out document's cache breakpoint moves to the block before it, the
block after it, or the tool result holding it, so the cached prefix stays
where the caller put it.

* fix(github_copilot): give a tool result left with only empty text documents the placeholder text

* fix(github_copilot): keep document citations under drop_params when converting shifts no index

---------

Co-authored-by: Gilad Katz <29776916+giladk1221@users.noreply.github.com>
Co-authored-by: mateo-berri <277851410+mateo-berri@users.noreply.github.com>
2026-11-23 15:06:36 -08:00
..
__init__.py test(unit): make every tests/unit directory a package so pytest collection is unique 2026-09-20 11:50:59 +00:00
test_github_copilot_messages_transformation.py fix(github_copilot): convert plain-text documents for native messages (#53554) 2026-11-23 15:06:36 -08:00