litellm/tests/test_litellm_rust
maciej-berri d6b3c549ee
perf(rust): stop re-serializing the Messages request body in Python logging callbacks (#51440)
* perf(rust): store the sent wire bytes as the Messages request instead of re-serializing

The Rust /v1/messages path handed record_response the body as a Python dict, and
Python ran json.dumps on the whole body again to build httpx_response.request.
Rust now keeps the bytes it serialized for the final attempt and passes them
through, so the stored request is exactly what the provider received and Python
does no extra full-body serialization. The hosted transport path sends the same
Rust bytes instead of a second Python json.dumps.

This also fixes the stored request after a retry with a wide int, NaN or
Infinity, which previously carried the internal marked string instead of the
real value.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Bne5zRJx1T5sEYBcsGtvqx

* perf(rust): serialize the Messages logged input in Rust instead of json.dumps

messages_input ran json.dumps on the whole pre_call body in Python for every
Rust /v1/messages request. Rust now serializes it with the same raw_json writer
it uses for the wire, at the same point (after caller substitution, before
Logging.pre_call), so callback edits still reach the wire but not the logged
input. Python only returns the top-level key order, with the handler signature
read once, and top-level scalars keep the caller's own spelling.

The logged input string becomes compact JSON with raw UTF-8. Top-level key order
and values are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Bne5zRJx1T5sEYBcsGtvqx

* fix(rust): keep body keys missing from the order list in the Messages logged input

The logged input only wrote keys named by Python's order tuple, so a key left
out of that tuple would vanish from the log without an error. Keys the order
does not name now follow in their sent order.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Bne5zRJx1T5sEYBcsGtvqx

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 17:13:55 -08:00
..
cache feat(messages): serve anthropic messages on rust only (#51119) 2026-11-12 00:07:20 +00:00
chat_completions feat(rust): one typed decline from core up to each host (#47772) 2026-10-28 09:22:11 -07:00
embeddings refactor(rust-bridge): decide native routing in the catalog, drop the bypass predicates (#46750) 2026-10-20 15:06:24 -07:00
messages perf(rust): stop re-serializing the Messages request body in Python logging callbacks (#51440) 2026-11-12 17:13:55 -08:00
ocr fix(messages): log native messages success once, after the proxy releases it (#50420) 2026-11-09 16:06:53 -08:00
responses fix(messages): let proxy /v1/messages requests run on the rust path (#50335) 2026-11-09 16:06:52 -08:00
support feat(messages): serve anthropic messages on rust only (#51119) 2026-11-12 00:07:20 +00:00
tokenizer test: move tests/test_litellm core utils, routing, responses, caching and rust_bridge into tests/unit (#43199) 2026-09-25 17:10:13 -07:00
AGENTS.md refactor(rust-bridge): detect Python-only features in the catalog instead of Rust declines (#46714) 2026-10-20 15:06:25 -07:00
conftest.py refactor(rust-bridge): require the native extension (#48852) 2026-10-28 13:16:56 -07:00
test_clickhouse_spend.py refactor(lens): connect LiteLLM to the independent Lens service (#45529) 2026-10-09 16:17:05 -07:00
test_dispatch.py feat(messages): serve anthropic messages on rust only (#51119) 2026-11-12 00:07:20 +00:00
test_fork_guard.py refactor(router): route the router family through RoutingContext and close the outside surface (#49118) 2026-10-30 19:18:54 -07:00
test_public_entries.py fix(rust): run native async calls through python's async wrapper steps (#50423) 2026-11-10 00:24:20 +00:00