Skip to content

Filter 6: stream_events #25

Description

@leseb

Purpose

Process native Responses API SSE events from the backend. Pass through with minimal transformation. Accumulate state (output items, tool calls, usage) and write metadata for downstream filters. Assign sequence numbers.

Note: Chat Completions → Responses SSE transformation is handled by #36. This filter only handles native /v1/responses backends.

Behavior

  • Pass through native Responses SSE events from backend
  • Assign monotonic sequence_number to every event (only valid for translation to chat_completion, we don't do that we fw to vLLM directly and send the SSEs back to the client untouched)
  • Accumulate state from events:
    • Track output items from output_item.added / output_item.done
    • Accumulate tool calls from function_call_arguments.delta / function_call_arguments.done
    • Track finish_reason, model, service_tier, usage
  • Write responses.tool_calls, responses.response_object, responses.output_items, responses.usage, responses.status to metadata
  • Every lifecycle event carries a full ResponseResource snapshot

Future work

  • Chat Completions → Responses SSE transformation (#500)

Praxis trait methods

  • on_response_body — process each SSE event, accumulate state, write metadata

Dependencies

  • Stateful streaming parser and buffering (#374) — shared SSE parsing/buffering infrastructure for chunk reassembly, fail-closed semantics, and buffer limits. Also consumed by tool_dispatch (#434).
  • SSE Streaming Inspection (MCP SSE stream merging from multiple backends #143)

Reference

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Fields

No fields configured for Task.

Projects

Status
In Progress

Relationships

None yet

Development

No branches or pull requests

Issue actions