fix(stream_events): cap tool-call arguments on done and after overflow - #872
Open
leseb wants to merge 2 commits into
Open
fix(stream_events): cap tool-call arguments on done and after overflow#872leseb wants to merge 2 commits into
leseb wants to merge 2 commits into
Conversation
The openai_stream_events filter capped accumulated function-call arguments from `function_call_arguments.delta` events, but two paths bypassed the limit: - A `function_call_arguments.done` event could carry oversized `arguments` that skipped the byte cap entirely. - After an oversized delta was rejected, later delta chunks restarted accumulation from an empty buffer, re-admitting oversized data. Track rejected tool-call keys in `StreamEventsState`: once a call's arguments exceed `max_tool_call_argument_bytes`, mark it permanently rejected, validate the done payload against the same cap, and ignore all subsequent delta/done events for that call. This keeps oversized arguments out of the stored response and tool-call state. Closes praxis-proxy#559 Signed-off-by: Sébastien Han <seb@redhat.com>
Extract `reject_oversized_done` and `finalize_function_call` so `handle_function_call_done` stays under the clippy `too_many_lines` threshold after the done-event argument cap was added. No behavior change; the stream_events suite still passes. Signed-off-by: Sébastien Han <seb@redhat.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The
openai_stream_eventsfilter capped accumulated function-call arguments fromfunction_call_arguments.deltaevents, but two paths bypassed the limit: an oversizedfunction_call_arguments.donepayload skipped the cap entirely, and after a rejected delta the accumulator could restart from an empty buffer on later chunks. This change tracks rejected tool-call keys inStreamEventsState, validates thedonepayload against the samemax_tool_call_argument_bytescap, and permanently ignores further delta/done events for a rejected call — keeping oversized arguments out of the stored response and tool-call state.Related issue
Closes #559
Validation
cargo test -p praxis-ai-apis stream_events(82 passed), including newtool_call_argument_bytes_cap_rejects_oversized_done_payloadandtool_call_argument_bytes_cap_rejects_restart_after_overflowmake lintmake buildChecklist
docs/filters/openai_stream_events.md).Signed-off-bytrailer.Breaking changes
None. The cap already applied to
deltaevents (default 1 MiB); this closes the bypasses so the documented limit is enforced consistently.