﻿# LiteLLM Rust Messages logging preserves wire bytes and changes JSON formatting

Compare parsed values and exact wire bytes as separate contracts; compact UTF-8 logging can preserve meaning while invalidating custom bytewise assumptions.

Author: Retrivium team
Updated: 2026-11-15
Canonical URL: https://retrivium.ai/journal/week46-agent-litellm-messages-rust-wire-byte-logging/
Language: en

LiteLLM v1.111.0-dev.2, released on November 13 as a prerelease, avoids rebuilding Messages request JSON in Python callbacks. Rust passes already prepared strings and bytes into logging. Logged input becomes compact raw UTF-8 JSON while values and top-level key order remain stable. Custom callbacks comparing byte strings therefore need a compatibility review even when the parsed request means the same thing.

## Unicode and spacing expose the visible change

Send a synthetic request containing non-ASCII text, nested objects and a deliberate top-level key order. Parse the logged input and compare values, then compare its raw bytes with an owned provider fixture’s received body. This distinguishes semantic preservation from exact formatting. An ASCII-only example without spaces can accidentally look identical before and after the change, leaving a custom callback’s incompatible comparison undiscovered until real multilingual traffic arrives.

## A callback may depend on the wrong equality

Inspect custom logging consumers for string equality, hashes or signatures over the logged input. Decide which genuinely requires exact provider bytes and which should compare parsed JSON. Do not silently normalize an audit record that is intended to preserve wire evidence. The release makes a concrete formatting change; applications must choose their comparison contract explicitly rather than assume all JSON serializers produce interchangeable strings for every downstream use.

## Retries must preserve the request actually sent

Force a harmless controlled retry and compare each recorded attempt with the corresponding received request. The PR also addresses stored placeholders after difficult numeric serialization cases. Use only values valid for the protocol and keep malformed-value refusal tests separate. One correct first-attempt log does not establish later retry evidence. Correlate attempts by their request identity so a callback cannot appear correct merely by repeating the original body after a modified dispatch.

## Performance evidence stays scoped to its fixture

The maintainers report reduced Python serialization work for a large request fixture. Measure the application’s actual body sizes and callback mix before extrapolating that result to end-to-end latency. Provider time and other hooks remain separate costs. A useful migration record includes parsed equality, wire-byte equality, retry coverage and callback compatibility, then reports local timing with payload size and tested path instead of promising the same gain for every gateway request.

## Sources

- [LiteLLM v1.111.0-dev.2 prerelease notes](https://github.com/BerriAI/litellm/releases/tag/v1.111.0-dev.2)
- [LiteLLM implementation and review #51440](https://github.com/BerriAI/litellm/pull/51440)

## Related reading

- [LiteLLM Proxy: when to operate your own model gateway](/journal/litellm-proxy-guide/)
- [Retrying generation POSTs: idempotency must be explicit](/journal/provider-post-retry-idempotency-ledger/)
