mirror of
https://github.com/BerriAI/litellm.git
synced 2026-12-05 01:59:27 +00:00
* fix(a2a): run guardrails on streamed A2A replies and A2A 1.0 parts
* fix(a2a): scan each streamed A2A event before sending it and read every artifact
A2A streams now scan every event with text and release it once clean, instead of
holding the whole stream until the task ends. The stream scan reads every status
message and artifact in an event, joining the parts of one artifact, and
message/send also scans multi-part text joined. /v1/a2a/{agent}/message/send is
mapped to the A2A call types, and a blocked stream ends with code -32000 plus the
guardrail name and mode
* fix(a2a): mask held A2A streams, scan each text container once, and join split parts on input
A guardrail that holds an A2A stream releases it at the end again, so a masked reply reaches tasks/resubscribe clients masked. Each message, status message and artifact reaches the guardrail as one text, on message/send, on streams and on input, and a changed text is written into the first part of its container
* fix(a2a): return the masked reply on message/send instead of masking a copy
* fix(a2a): parse each streamed event once, keep -32603 for failed guardrails, mask the logged send reply
* perf(guardrails): compare only new entries when syncing guardrail logs
A guardrail that scans every streamed A2A event re-synced its whole log list
each scan and compared every entry with every other, so a 1,600-event stream
spent most of a worker's CPU in the duplicate check. Entries already logged are
now skipped by identity, and only new ones get the equality check
* fix(a2a): join message parts with a newline, log one guardrail entry per stream, warn when a stream mask is dropped
Message and status message parts are joined with a newline so a word-boundary
pattern still matches a value sent in its own part. Artifact parts stay joined
with nothing, since the a2a-sdk stores each streamed chunk as its own part.
A guardrail's consecutive clean scans of one A2A stream fold into one log
entry, so a long stream no longer grows the spend log row by one entry per
event. A block or failed scan keeps its own entry.
The unified guardrail logs one warning per A2A stream when a scan changes text
it cannot send, covering tasks/resubscribe masks.
* fix(a2a): mask multi-part messages per part and keep one priced log entry per guardrail on streams
Split a pre_call rewrite of a multi-part A2A message back across its parts and drop
a part the rewrite empties, so a2a-sdk never rejects an empty text part. Send the
message to the generic guardrail API as a chat user message. Fold stream scan log
entries per guardrail name and sum their usage and cost. Clear masked_entity_count
when a stream rewrite cannot reach the client, and keep a tag map mode out of the
error detail
* docs(a2a): drop handler README methods the stream guardrail change removed
* fix(a2a): refuse a message a guardrail empties and give per-chunk hooks the A2A reply so far
* fix(a2a): apply a mask a guardrail returns only as a chat message on A2A input
* fix(a2a): keep later stream scans on the sent text and refuse rewrites the agent cannot take
The A2A handler reports a streamed rewrite through StreamTransformSink instead
of rewriting the reply history in place, so a later event is still scanned
against the text the client got. The per-chunk scan passes the sink only on
A2A streams, so chat translations get the same call as on the base branch
streaming_buffer_release_on_scan now defaults to true on A2A only when
streaming_buffer_until_moderated is unset, so a configured hold still holds
A guardrail refusal raised while a message/stream or tasks/resubscribe reply
is being sent ends the stream with a JSON-RPC error event
A pre_call guardrail that empties an A2A message, or answers with more than
one chat message, raises UnappliableRequestRewrite. The route maps it to a
JSON-RPC -32000 with a 400 after the failure hook runs, so the refusal gets a
spend log row, and a pipeline step with on_fail allow cannot send the original
text on. A generic guardrail API answer with rows given as plain dicts is read
like chat reads it
|
||
|---|---|---|
| .. | ||
| chat | ||
| __init__.py | ||
| test_common_utils.py | ||