Skip to content

Simplify chat route: passthrough SSE stream#4

Merged
stevez merged 1 commit into
mainfrom
refactor/passthrough-sse-stream
Apr 13, 2026
Merged

Simplify chat route: passthrough SSE stream#4
stevez merged 1 commit into
mainfrom
refactor/passthrough-sse-stream

Conversation

@stevez

@stevez stevez commented Apr 13, 2026

Copy link
Copy Markdown
Owner

Summary

  • Replace the decode-then-reencode SSE pattern in chat/route.ts with a raw fetch passthrough — the LangGraph SSE stream is forwarded directly to the client without deserialization
  • Use eventsource-parser on the client to parse the raw SSE format, replacing the manual line-by-line parser
  • Reduces route.ts from 113 lines to 65 lines (-48 lines, -56 insertions net)

Test plan

  • Build passes (yarn build)
  • Chat streaming works end-to-end with LangGraph backend
  • Source citations display correctly from updates events
  • Query routing (retrieve vs direct) works

Closes #3

🤖 Generated with Claude Code

Replace the decode-then-reencode pattern with a raw fetch passthrough.
The API route now forwards the LangGraph SSE stream directly to the
client without deserializing and re-serializing each chunk.

Use eventsource-parser on the client to handle raw SSE parsing,
replacing the manual line-by-line parser.

Closes #3

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@stevez stevez merged commit 2651958 into main Apr 13, 2026
1 check passed
@stevez stevez deleted the refactor/passthrough-sse-stream branch April 13, 2026 00:45
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.

Simplify chat route: passthrough SSE stream instead of decode/reencode

1 participant