litellm/tests/test_litellm/proxy/middleware
Yassin Kortam 382d11b961 fix(proxy): stop billing bare a2a task RPCs and close the shutdown race
POST /a2a/{agent_id} multiplexes JSON-RPC methods off the request body. Only
message/send and message/stream write a SpendLogs row; tasks/get, tasks/cancel
and the pushNotificationConfig RPCs are forwarded upstream and write none.
Classifying the bare path as billable counted those task RPCs and pushed the
metric above the dashboard's successful-request count. Since a path-only
classifier cannot read the body, the bare route no longer bills; the explicit
/message/send routes still do. Missing a bare-path invoke undercounts, which is
the only direction this metric is allowed to drift. The /mcp transport keeps
billing every method because its list path logs a SpendLogs row too.

The billing middleware also sat outside InFlightRequestsMiddleware, and it
records after the inner app returns. A request could therefore be counted as
drained while its record() had not yet run, letting proxy_shutdown_event flush
and stop the exporter underneath it. Registering it before the in-flight
tracker nests it inside, so wait_for_drain covers the record
2026-07-09 12:18:20 +03:00
..
test_billable_request_metrics_middleware.py fix(proxy): stop billing bare a2a task RPCs and close the shutdown race 2026-07-09 12:18:20 +03:00
test_in_flight_requests_middleware.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_prometheus_auth_middleware.py fix(proxy): point /metrics 401 at the opt-out flag 2026-05-08 18:09:14 -07:00
test_prometheus_auth_middleware_asgi.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_security_headers_middleware.py feat(proxy): configurable response headers and login-page hint (#30792) 2026-06-18 18:12:45 -07:00