﻿# LiteLLM preserves caller correlation metadata when authentication or budget checks reject a request

Verify failure-row correlation and unchanged rejection semantics, while keeping caller markers separate from authenticated identity and checking cleanup between requests.

Author: Retrivium team
Updated: 2026-11-15
Canonical URL: https://retrivium.ai/journal/week46-agent-litellm-auth-failure-caller-correlation/
Language: en

LiteLLM v1.111.0-dev.4 preserves caller-provided spend-log metadata on authentication failures, including rejected keys and exceeded budgets. The November 15 prerelease leaves the rejection response itself unchanged. This helps correlate failed attempts, but metadata supplied by a rejected caller remains a claim, so observability should not confuse a useful request marker with authenticated identity.

## Give each rejected attempt a safe marker

Send synthetic requests with an invalid key, an exhausted test budget and a valid control key. Use distinctive harmless metadata for each and inspect final spend rows and callbacks. A rejection can occur before ordinary logging setup, so checking successful requests alone misses the changed path. Preserve the external request identity as well, allowing the caller to locate its failed attempt without embedding prompt content or live credentials in the marker.

## Untrusted metadata should not become identity

Include a marker that resembles a team or user field and verify the application still displays authenticated scope from its authoritative source. The feature preserves diagnostic context; it does not validate every supplied value. Keep provenance visible in downstream analytics. Otherwise a rejected caller can make its log row appear to belong to another team simply because a dashboard groups by free-form metadata without distinguishing that field from verified authentication attributes.

## Header precedence and malformed input need controls

Exercise the supported metadata header alongside any body metadata the application sends. Record the intended precedence, then submit missing and malformed header values. The rejection outcome should stay meaningful and the logger should not turn bad metadata into an unrelated server error. Use small synthetic values so the fixture tests merging and parsing rather than an accidental payload-size limit outside the release fix.

## Cleanup prevents cross-request attribution

Immediately follow a marked failure with an unmarked request on the same worker and inspect its record. No previous marker should leak through retained logging context. Repeat under bounded concurrency with distinct identities. The useful adoption result is correlated failures without changed authorization, response codes or successful-request behavior. It does not imply failed requests consumed model tokens, nor that every diagnostic field is safe to trust as a billing owner.

## Sources

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

## Related reading

- [LiteLLM virtual keys: separate access for each application](/journal/litellm-virtual-key-scopes/)
- [LiteLLM budgets: periods, shared limits and overrun tests](/journal/litellm-budget-reset/)
