Skip to content

fix(showcase/agno): read SSE incrementally in smoke route to work around agno SDK success-path hang - #4105

Merged
jpr5 merged 1 commit into
mainfrom
fix/agno-smoke-incremental-reader
Apr 20, 2026
Merged

jpr5 merged 1 commit into
mainfrom
fix/agno-smoke-incremental-reader

Conversation

@jpr5

@jpr5 jpr5 commented Apr 20, 2026

Copy link
Copy Markdown
Contributor

Summary

Reimplements the SSE incremental reader workaround from the now-closed PR #4093 on a fresh branch off main.

Background

PR #4093 was closed under the assumption that PR #4095 (agno SDK upgrade to 2.5.17) had fixed the underlying SSE stream termination bug at the source. Follow-up diagnostics on 2026-04-19 revealed that the SDK upgrade only addressed the error path; production /api/smoke with real API keys still hangs because the agno SDK does not reliably emit TEXT_MESSAGE_END / RUN_FINISHED on the success path.

Documented in Notion page 3473aa38-1852-815b-9765-fd28fa53275a, item #5.

Change

showcase/packages/agno/src/app/api/smoke/route.ts — swap await res.text() for an incremental reader:

  • Read res.body via getReader() + TextDecoder + string buffer accumulator.
  • On each chunk, check whether the accumulated buffer contains "type":"TEXT_MESSAGE_CONTENT" along with "OK" in the delta. Once seen, cancel the reader and return a 200 success envelope — do not await a terminal event that the SDK may never send on the success path.
  • If the stream closes cleanly without ever producing the confirmation payload, return a 502 with stage:"response_incomplete" so regressions surface clearly in the smoke monitor.
  • Keep AbortSignal.timeout(45000) as the final safety net.
  • Response envelope shape preserved for the smoke monitor parser.

Scope

Only the agno /api/smoke/route.ts is touched. The other 16 showcase starters use the same await res.text() pattern but none have exhibited the hang in production — no speculative fixes.

Caveat — this is a mitigation, not a fix

The real fix belongs upstream in the agno SDK's AG-UI interface. Do not merge-and-forget. Keep this PR open until upstream is addressed and the fix is verified in production with real API keys, then revisit whether this client-side workaround can be removed.

Test plan

  • Visual inspection of the diff matches the pattern from PR fix(showcase/agno): mitigate SSE stream never terminating on /api/smoke #4093
  • Standalone tsc --noEmit against route.ts with DOM + ES2017 libs — clean (only missing @types/node for process, expected in dry-run; code compiles cleanly otherwise)
  • Production curl sanity check against https://showcase-agno-production.up.railway.app/api/smoke once deployed
  • Monitor next 12h of Showcase: Smoke Monitor runs for agno stability

Closes/replaces the approach from #4093.

…und agno SDK success-path hang

Reimplements the approach from the now-closed PR #4093 (which I closed
after #4095 merged the agno 2.5.17 upgrade, on the belief that the SDK
bump had fixed the underlying SSE termination bug).

Follow-up evidence collected 2026-04-19 showed the SDK upgrade only
addressed the error path — production /api/smoke with real API keys
still hangs because the agno SDK does not reliably emit TEXT_MESSAGE_END
/ RUN_FINISHED on the success path. Documented in Notion page
3473aa381852815b9765fd28fa53275a, item #5.

Change: instead of `await res.text()` (which only resolves when the
server closes the stream), read res.body incrementally with
getReader() + TextDecoder. Short-circuit as soon as the buffer contains
`"type":"TEXT_MESSAGE_CONTENT"` with `"OK"` — the agent has produced
the expected output, so we cancel the reader and return a 200 success
envelope without awaiting a terminal event that may never arrive. If
the stream closes cleanly without confirmation, return a diagnostic
502 with stage="response_incomplete" so regressions surface clearly.
Keep the existing 45s AbortSignal timeout as a final safety net.

Response envelope shape is preserved for the smoke monitor parser.

This is a client-side mitigation, not a fix. The real fix belongs
upstream in the agno SDK's AG-UI interface. Keep this PR open until
upstream is addressed and verified in production with real keys.
@vercel

vercel Bot commented Apr 20, 2026 •

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
chat-with-your-data Ready Ready Preview, Comment Apr 20, 2026 4:10am
docs Ready Ready Preview, Comment Apr 20, 2026 4:10am
form-filling Ready Ready Preview, Comment Apr 20, 2026 4:10am
research-canvas Ready Ready Preview, Comment Apr 20, 2026 4:10am
travel Ready Ready Preview, Comment Apr 20, 2026 4:10am

Request Review

@github-actions

Copy link
Copy Markdown
Contributor

📣 Social Copy Generator

Generate social media copies (Twitter/X, LinkedIn, Blog Post) for this PR using Claude.

  • Generate social media copies

@jpr5
jpr5 merged commit e261a1f into main Apr 20, 2026
14 checks passed
@jpr5
jpr5 deleted the fix/agno-smoke-incremental-reader branch April 20, 2026 04:12
zeekay pushed a commit to Dream-AI-4444/CopilotKit that referenced this pull request Sep 11, 2026
…und agno SDK success-path hang (CopilotKit#4105)

## Summary

Reimplements the SSE incremental reader workaround from the now-closed
PR CopilotKit#4093 on a fresh branch off `main`.

## Background

PR CopilotKit#4093 was closed under the assumption that PR CopilotKit#4095 (agno SDK upgrade
to 2.5.17) had fixed the underlying SSE stream termination bug at the
source. Follow-up diagnostics on 2026-04-19 revealed that the SDK
upgrade only addressed the **error path**; production `/api/smoke` with
real API keys still hangs because the agno SDK does not reliably emit
`TEXT_MESSAGE_END` / `RUN_FINISHED` on the **success path**.

Documented in Notion page `3473aa38-1852-815b-9765-fd28fa53275a`, item
CopilotKit#5.

## Change

`showcase/packages/agno/src/app/api/smoke/route.ts` — swap `await
res.text()` for an incremental reader:

- Read `res.body` via `getReader()` + `TextDecoder` + string buffer
accumulator.
- On each chunk, check whether the accumulated buffer contains
`"type":"TEXT_MESSAGE_CONTENT"` along with `"OK"` in the delta. Once
seen, cancel the reader and return a 200 success envelope — do not await
a terminal event that the SDK may never send on the success path.
- If the stream closes cleanly without ever producing the confirmation
payload, return a 502 with `stage:"response_incomplete"` so regressions
surface clearly in the smoke monitor.
- Keep `AbortSignal.timeout(45000)` as the final safety net.
- Response envelope shape preserved for the smoke monitor parser.

## Scope

Only the agno `/api/smoke/route.ts` is touched. The other 16 showcase
starters use the same `await res.text()` pattern but none have exhibited
the hang in production — no speculative fixes.

## Caveat — this is a mitigation, not a fix

The real fix belongs upstream in the agno SDK's AG-UI interface. **Do
not merge-and-forget.** Keep this PR open until upstream is addressed
and the fix is verified in production with real API keys, then revisit
whether this client-side workaround can be removed.

## Test plan

- [x] Visual inspection of the diff matches the pattern from PR CopilotKit#4093
- [x] Standalone `tsc --noEmit` against `route.ts` with DOM + ES2017
libs — clean (only missing `@types/node` for `process`, expected in
dry-run; code compiles cleanly otherwise)
- [ ] Production curl sanity check against
`https://showcase-agno-production.up.railway.app/api/smoke` once
deployed
- [ ] Monitor next 12h of `Showcase: Smoke Monitor` runs for agno
stability

Closes/replaces the approach from CopilotKit#4093.

This branch was successfully deployed

5 active deployments
Preview – research-canvas — 4d1147d0 Deployed Apr 20, 2026 by vercel[bot]
Preview – travel — 4d1147d0 Deployed Apr 20, 2026 by vercel[bot]
Preview – docs — 4d1147d0 Deployed Apr 20, 2026 by vercel[bot]
Preview – form-filling — 4d1147d0 Deployed Apr 20, 2026 by vercel[bot]
Preview – chat-with-your-data — 4d1147d0 Deployed Apr 20, 2026 by vercel[bot]
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.

1 participant