Skip to content

fix(stream_events): cap tool-call arguments on done and after overflow - #872

Open
leseb wants to merge 2 commits into
praxis-proxy:mainfrom
leseb:leseb/fix-issue-559
Open

fix(stream_events): cap tool-call arguments on done and after overflow#872
leseb wants to merge 2 commits into
praxis-proxy:mainfrom
leseb:leseb/fix-issue-559

Conversation

@leseb

@leseb leseb commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Summary

The openai_stream_events filter capped accumulated function-call arguments from function_call_arguments.delta events, but two paths bypassed the limit: an oversized function_call_arguments.done payload 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 in StreamEventsState, validates the done payload against the same max_tool_call_argument_bytes cap, 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

  • Unit tests — cargo test -p praxis-ai-apis stream_events (82 passed), including new tool_call_argument_bytes_cap_rejects_oversized_done_payload and tool_call_argument_bytes_cap_rejects_restart_after_overflow
  • Integration or functional tests — n/a (filter-state hardening; covered by unit tests above)
  • make lint
  • make build

Checklist

  • I reviewed every changed line and can explain the change.
  • New capabilities include an example config and functional example test. — n/a (hardening of an existing filter, no new capability)
  • User-facing behavior and generated documentation are updated (docs/filters/openai_stream_events.md).
  • Performance-sensitive changes include appropriate benchmark or load-test evidence. — n/a
  • Commits are signed and include a Signed-off-by trailer.

Breaking changes

None. The cap already applied to delta events (default 1 MiB); this closes the bypasses so the documented limit is enforced consistently.

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>
@leseb
leseb requested review from a team and nerdalert September 2, 2026 09:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

function_call_arguments.done bypasses the configured argument-size cap

1 participant