Repository navigation
fix(showcase/agno): read SSE incrementally in smoke route to work around agno SDK success-path hang - #4105
Merged
Conversation
…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.
jpr5
requested review from
marthakelly,
mme,
ranst91 and
tylerslaton
as code owners
April 20, 2026 04:07
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
📣 Social Copy GeneratorGenerate social media copies (Twitter/X, LinkedIn, Blog Post) for this PR using Claude.
|
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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/smokewith real API keys still hangs because the agno SDK does not reliably emitTEXT_MESSAGE_END/RUN_FINISHEDon the success path.Documented in Notion page
3473aa38-1852-815b-9765-fd28fa53275a, item #5.Change
showcase/packages/agno/src/app/api/smoke/route.ts— swapawait res.text()for an incremental reader:res.bodyviagetReader()+TextDecoder+ string buffer accumulator."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.stage:"response_incomplete"so regressions surface clearly in the smoke monitor.AbortSignal.timeout(45000)as the final safety net.Scope
Only the agno
/api/smoke/route.tsis touched. The other 16 showcase starters use the sameawait 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
tsc --noEmitagainstroute.tswith DOM + ES2017 libs — clean (only missing@types/nodeforprocess, expected in dry-run; code compiles cleanly otherwise)https://showcase-agno-production.up.railway.app/api/smokeonce deployedShowcase: Smoke Monitorruns for agno stabilityCloses/replaces the approach from #4093.