litellm/litellm/a2a_protocol
joshua-berri e4759def40
fix(logging): retain streaming success logging tasks until they finish (#52067)
* fix(logging): retain streaming success logging tasks until they finish

Streaming chat, A2A, Gemini/Vertex and the proxy's deferred chat stream
logging scheduled their success dispatch with a bare asyncio.create_task.
The loop only holds weak references to tasks, so a dispatch suspended on
an awaitable nothing else reaches could be garbage collected mid-flight
and its spend log never written. Route them through spawn_logging_task,
which keeps a strong reference until completion, logs failures and is
drained at proxy shutdown.

* test(logging): release parked logging callbacks on every exit path

Wrap the garbage collection regressions in a context manager that releases
the parked callback, waits for its task and drains the logging registry even
when the test fails, assert exactly one parked callback, and leave the
orphaned closure dispatch on its original schedule.

* test(logging): cancel a parked logging callback that never finishes

Cancel and await the parked task if it is still pending after release, fail
the test in that case, and leave the streaming cache write on its original
schedule since it hands off to an already tracked write without suspending.

---------

Co-authored-by: Joshua Valluru <326636767+joshua-berri@users.noreply.github.com>
2026-11-16 11:21:05 -08:00
..
litellm_completion_bridge refactor(typing): clear about 1,100 basedpyright Any errors across 303 files (#49986) 2026-11-06 13:31:15 -08:00
providers fix(a2a)!: bill completion-bridge agents at their own prices on /a2a send and stream (#49150) 2026-10-30 19:43:45 -07:00
__init__.py chore(lint): clear grandfathered over-limit lint drift and ratchet budgets down 2026-08-05 12:18:13 -07:00
card_resolver.py refactor(typing): clear about 1,100 basedpyright Any errors across 303 files (#49986) 2026-11-06 13:31:15 -08:00
client.py feat(lint): enforce Final on locals and freeze function parameters (LIT010, LIT011) 2026-08-04 12:54:39 -07:00
cost_calculator.py refactor(typing): clear 1181 basedpyright Any errors across 431 files (#47789) 2026-10-24 11:31:09 -07:00
exception_mapping_utils.py refactor(typing): clear about 1,100 basedpyright Any errors across 303 files (#49986) 2026-11-06 13:31:15 -08:00
exceptions.py fix(a2a): keep the upstream status on card discovery failures and inject the card client in tests 2026-09-16 23:55:57 +00:00
main.py refactor(typing): clear about 1,100 basedpyright Any errors across 303 files (#49986) 2026-11-06 13:31:15 -08:00
streaming_iterator.py fix(logging): retain streaming success logging tasks until they finish (#52067) 2026-11-16 11:21:05 -08:00
utils.py fix(a2a)!: bill completion-bridge agents at their own prices on /a2a send and stream (#49150) 2026-10-30 19:43:45 -07:00