Skip to content

refactor(streaming): adopt the shared Praxis SSE codec #842

Description

@leseb

Description

After praxis-proxy/praxis#986 provides the shared bounded SSE codec, migrate
Praxis AI's provider-neutral SSE framing code to that praxis-filter API.

Praxis AI currently has several independently evolved framing paths:

  • apis/src/openai/sse/frame.rs
  • apis/src/openai/sse/responses/parser.rs
  • apis/src/openai/responses/stream_events/
  • apis/src/anthropic/stream_events/
  • filters/src/agentic/a2a/sse.rs
  • the A2A parser reuse in filters/src/token_usage/count.rs

The refactor should share only the transport-independent SSE record framing.
Provider event schemas, JSON decoding, lifecycle validation, accumulation,
translation, failure policy, response IDs, and sequence handling remain owned
by their existing AI modules.

Acceptance Criteria

  • Update the Praxis dependency to a revision containing
    filter: add a bounded incremental SSE codec praxis#986.
  • Replace apis/src/openai/sse/frame.rs with the shared incremental decoder and
    encoder, removing the local implementation once all callers are migrated.
  • Migrate the Responses, Anthropic, A2A, and token-usage consumers where their
    framing requirements match the shared contract.
  • Do not introduce a common provider event model; each consumer retains its
    typed event parsing and lifecycle rules above the shared SSE records.
  • Preserve each consumer's existing pass-through, transformation, fail-open or
    fail-closed, terminal-event, and end-of-stream behavior.
  • Preserve raw event bytes where a pass-through consumer requires byte-exact
    forwarding. If the shared codec cannot support a required behavior, refine
    filter: add a bounded incremental SSE codec praxis#986 rather than adding another AI-local framing parser.
  • Retain consumer-specific limits such as event count, accumulated state, JSON
    size, and lifecycle timeouts; the shared framing bounds do not replace them.
  • Tests cover arbitrary chunk splits, UTF-8 splits, LF/CRLF, comments,
    multiline data, multiple events per chunk, incomplete EOF, malformed input,
    and framing-limit overflow through the migrated production callers.
  • No migrated streaming path buffers the complete response or weakens
    downstream backpressure.
  • Remove obsolete duplicate parser tests and replace them with focused adapter
    tests plus the shared codec's conformance coverage.

Non-Goals

  • Moving OpenAI ResponsesState, Anthropic translation, A2A task semantics, or
    token accounting into Praxis.
  • Implementing GET /v1/responses/{id}?stream=true, event persistence,
    starting_after, or replay journals.
  • Changing Pingora transport, BodyMode::Stream, or
    StreamingTerminalResponse.
  • Combining provider-specific stream filters into one filter.

Dependencies

Parent Epic

Related

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions