Repository navigation
Conversation
The agno agent occasionally drops the terminal SSE event (TEXT_MESSAGE_END / RUN_FINISHED / RUN_ERROR) after emitting TEXT_MESSAGE_CONTENT, leaving the stream open until the client timeout fires. This surfaced as ~20+ /api/smoke 502s per night with stage="timeout" despite the agent producing valid output. Raising the timeout (PR #4089, 25s to 45s) does not help — any finite timeout still 502s because the stream never closes on the affected requests. Instead, read the SSE stream incrementally and bail as soon as we see a TEXT_MESSAGE_CONTENT event containing "OK", canceling the reader rather than awaiting a stream close that may never come. Verified against production: curl -m 35 https://showcase-agno-production.up.railway.app/api/smoke Before: 20+ seconds, 502 (stage:"timeout") After (simulated via node fetch with same logic): 7-16 seconds, 200 ok Only the agno production endpoint exhibits this behavior; spring-ai, langroid, llamaindex, pydantic-ai, and mastra all close their streams cleanly in under 1.5s, so their identical \`await res.text()\` smoke routes are not vulnerable in practice and are left untouched. A deeper fix belongs in the agno SDK's AGUI interface (it appears to not guarantee a terminal event when the model emits its final token without subsequent activity). Follow-up tracked separately.
jpr5
requested review from
marthakelly,
mme,
ranst91 and
tylerslaton
as code owners
April 19, 2026 14:50
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.
|
8 of 9 tasks
jpr5
added a commit
that referenced
this pull request
Apr 19, 2026
## Summary Bumps the `agno` Python SDK pin from `>=1.7.8` to `>=2.5.17` (latest stable on PyPI) in `showcase/packages/agno/requirements.txt`. ## Why The agno 1.x AGUI interface had a known bug where the terminal SSE event (`RUN_FINISHED` / `TEXT_MESSAGE_END`) was never emitted, causing consumers that block on stream close (such as `/api/smoke` calling `await res.text()`) to hang until AbortSignal fired (25-45s). Agno 2.5.17 emits the terminal `RUN_FINISHED` frame and closes the stream cleanly, even when the underlying LLM call fails (dummy API key -> 401). ## Version | | Before | After | |---|---|---| | Pin | `agno>=1.7.8` | `agno>=2.5.17` | | Installed | 1.7.x | 2.5.17 | ## Breaking changes encountered None in this package. All existing imports continue to resolve without change: - `from agno.os import AgentOS` - `from agno.os.interfaces.agui import AGUI` - `from agno.agent.agent import Agent` - `from agno.models.openai import OpenAIChat` - `from agno.tools import tool` No API adaptation was required. ## Relationship to PR #4093 PR #4093 works around the 1.x SSE bug in the consumer (`/api/smoke`) by reading the stream incrementally and bailing on `TEXT_MESSAGE_CONTENT "OK"`. With this upstream fix, that workaround becomes defense-in-depth rather than load-bearing. **Recommendation:** leave #4093 in place after this merges. It's cheap, it's already written, and it protects against future agno regressions in stream termination. ## Local verification evidence All tests ran against a local `docker build -t agno-test .` of this package (`agno==2.5.17`, Python 3.12.13). ### Imports ``` $ docker exec agno-test python -c "import agno; print(agno.__version__)" 2.5.17 $ docker exec agno-test python -c "from agno.os.interfaces.agui import AGUI; ..." all imports OK ``` ### /api/smoke timing (three consecutive runs) ``` run 1: time=0.256s code=200 run 2: time=0.157s code=200 run 3: time=0.151s code=200 {"status":"ok","integration":"agno","latency_ms":12,"timestamp":"2026-04-19T15:03:36.057Z"} ``` Previously: 25-45s hang ending in `AbortError`. ### Raw SSE stream inspection (dummy OpenAI key -> 401) ``` data: {"type":"RUN_STARTED","threadId":"test-thread","runId":"test-run",...} data: {"type":"RUN_FINISHED","threadId":"test-thread","runId":"test-run"} ``` Stream closes immediately after `RUN_FINISHED`. Terminal event is present. ### Demos (homepage + 9 demo routes) ``` / 200 0.008s /demos/agentic-chat 200 0.010s /demos/hitl 200 0.005s /demos/tool-rendering 200 0.005s /demos/gen-ui-tool-based 200 0.006s /demos/subagents 200 0.004s /demos/shared-state-read 200 0.005s /demos/shared-state-write 200 0.006s /demos/shared-state-streaming 200 0.005s /demos/gen-ui-agent 200 0.005s ``` ### Agent object ``` agent loaded: Agent tool count: 8 model: gpt-4o ``` ## Test plan - [x] `docker build` succeeds with new pin - [x] `import agno` reports 2.5.17 - [x] All existing `from agno...` imports resolve unchanged - [x] `/api/health` returns 200 - [x] `/api/smoke` returns 200 in <1s (was 25-45s hang) - [x] Raw SSE stream contains `RUN_FINISHED` terminal event - [x] Homepage + all 9 demo routes return 200 - [x] Agent object loads with 8 tools - [ ] CI green on PR
Contributor
Author
|
Superseded by #4095 — agno 2.5.17 upgrade fixes the SSE stream termination bug at the source. This workaround is no longer needed. |
jpr5
added a commit
that referenced
this pull request
Apr 20, 2026
…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.
2 of 4 tasks
jpr5
added a commit
that referenced
this pull request
Apr 20, 2026
…und agno SDK success-path hang (#4105) ## 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 - [x] Visual inspection of the diff matches the pattern from PR #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 #4093.
zeekay
pushed a commit
to Dream-AI-4444/CopilotKit
that referenced
this pull request
Sep 11, 2026
## Summary Bumps the `agno` Python SDK pin from `>=1.7.8` to `>=2.5.17` (latest stable on PyPI) in `showcase/packages/agno/requirements.txt`. ## Why The agno 1.x AGUI interface had a known bug where the terminal SSE event (`RUN_FINISHED` / `TEXT_MESSAGE_END`) was never emitted, causing consumers that block on stream close (such as `/api/smoke` calling `await res.text()`) to hang until AbortSignal fired (25-45s). Agno 2.5.17 emits the terminal `RUN_FINISHED` frame and closes the stream cleanly, even when the underlying LLM call fails (dummy API key -> 401). ## Version | | Before | After | |---|---|---| | Pin | `agno>=1.7.8` | `agno>=2.5.17` | | Installed | 1.7.x | 2.5.17 | ## Breaking changes encountered None in this package. All existing imports continue to resolve without change: - `from agno.os import AgentOS` - `from agno.os.interfaces.agui import AGUI` - `from agno.agent.agent import Agent` - `from agno.models.openai import OpenAIChat` - `from agno.tools import tool` No API adaptation was required. ## Relationship to PR CopilotKit#4093 PR CopilotKit#4093 works around the 1.x SSE bug in the consumer (`/api/smoke`) by reading the stream incrementally and bailing on `TEXT_MESSAGE_CONTENT "OK"`. With this upstream fix, that workaround becomes defense-in-depth rather than load-bearing. **Recommendation:** leave CopilotKit#4093 in place after this merges. It's cheap, it's already written, and it protects against future agno regressions in stream termination. ## Local verification evidence All tests ran against a local `docker build -t agno-test .` of this package (`agno==2.5.17`, Python 3.12.13). ### Imports ``` $ docker exec agno-test python -c "import agno; print(agno.__version__)" 2.5.17 $ docker exec agno-test python -c "from agno.os.interfaces.agui import AGUI; ..." all imports OK ``` ### /api/smoke timing (three consecutive runs) ``` run 1: time=0.256s code=200 run 2: time=0.157s code=200 run 3: time=0.151s code=200 {"status":"ok","integration":"agno","latency_ms":12,"timestamp":"2026-04-19T15:03:36.057Z"} ``` Previously: 25-45s hang ending in `AbortError`. ### Raw SSE stream inspection (dummy OpenAI key -> 401) ``` data: {"type":"RUN_STARTED","threadId":"test-thread","runId":"test-run",...} data: {"type":"RUN_FINISHED","threadId":"test-thread","runId":"test-run"} ``` Stream closes immediately after `RUN_FINISHED`. Terminal event is present. ### Demos (homepage + 9 demo routes) ``` / 200 0.008s /demos/agentic-chat 200 0.010s /demos/hitl 200 0.005s /demos/tool-rendering 200 0.005s /demos/gen-ui-tool-based 200 0.006s /demos/subagents 200 0.004s /demos/shared-state-read 200 0.005s /demos/shared-state-write 200 0.006s /demos/shared-state-streaming 200 0.005s /demos/gen-ui-agent 200 0.005s ``` ### Agent object ``` agent loaded: Agent tool count: 8 model: gpt-4o ``` ## Test plan - [x] `docker build` succeeds with new pin - [x] `import agno` reports 2.5.17 - [x] All existing `from agno...` imports resolve unchanged - [x] `/api/health` returns 200 - [x] `/api/smoke` returns 200 in <1s (was 25-45s hang) - [x] Raw SSE stream contains `RUN_FINISHED` terminal event - [x] Homepage + all 9 demo routes return 200 - [x] Agent object loads with 8 tools - [ ] CI green on PR
zeekay
pushed a commit
to Dream-AI-4444/CopilotKit
that referenced
this pull request
Sep 11, 2026
…und agno SDK success-path hang Reimplements the approach from the now-closed PR CopilotKit#4093 (which I closed after CopilotKit#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 CopilotKit#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.
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.
Root cause
The agno agent, when driven by our
/api/copilotkit→agent/runsmoke payload, emits valid AG-UI SSE events:...and then hangs with the connection open indefinitely — no
TEXT_MESSAGE_END, noRUN_FINISHED, noRUN_ERROR./api/healthstays 200 because it's a trivial route that never touches the agent.For comparison, spring-ai (identical payload) closes cleanly in ~500ms; langroid/llamaindex/pydantic-ai/mastra all close cleanly in under 1.5s.
Live repro against production (before this PR):
Direct POST to
/api/copilotkitconfirms the stream hang (observed repeatedly this afternoon):RUN_STARTED+TEXT_MESSAGE_START+TEXT_MESSAGE_CONTENT "OK", then stream hangs until client timeout.Why PR #4089 (25s → 45s timeout) does not cure this
Any finite client timeout still produces a 502 because the server never closes the stream. Raising the timeout only changes how long we wait before the inevitable
AbortErrorfires and we emitstage:"timeout". This PR fixes the actual mechanism rather than stretching the window.Phase A (this PR) — workaround in the smoke route
showcase/packages/agno/src/app/api/smoke/route.tsnow:/api/copilotkitand readsres.bodyincrementally with the Web StreamsgetReader()API (notawait res.text(), which only resolves when the server closes the stream)."type":"TEXT_MESSAGE_CONTENT"and"OK". Once seen, cancels the reader and returns 200 immediately — does not wait for the (possibly never-arriving) terminal event.TEXT_MESSAGE_CONTENT "OK", returns 502 with a newstage:"response_incomplete"so we can distinguish this failure mode from genuine timeouts or empty responses in future alerts.Verified via a Node repro that mirrors the new route logic against the production agno agent:
Before the fix all three of those would have hung until timeout and returned 502.
Scope — other packages
All 17 showcase
/api/smoke/route.tsfiles use the sameawait res.text()pattern, so in principle any of them could exhibit this class of bug. In practice only agno does today:/api/smoketimeLeaving the other packages untouched. If/when another integration starts dropping terminal SSE events, we can generalize this pattern across all 17 routes in one sweep.
Phase B — agno agent_server investigation (not shipped)
Read
showcase/packages/agno/src/agent_server.pyandsrc/agents/main.py. Server is a thin wrapper:The terminal-event emission lives inside the agno SDK's
agno.os.interfaces.agui.AGUIclass — third-party code, not in our tree.Findings from a short investigation:
agno>=1.7.8inrequirements.txt. Current PyPI release is 2.5.17 (major version bump since we pinned). Recent versions include2.5.5..2.5.17. No cursory evidence that the 1.x → 2.x jump fixes this specific bug.RUN_STARTED+RUN_FINISHEDwith noTEXT_MESSAGE_*events at all (agent silently produces no output). Distinct from the hang-on-content case, but same user-visible result (smoke reports 502). This PR's Phase A covers both viastage:"response_incomplete".Phase B is intentionally deferred to a separate follow-up once Phase A stabilizes the alerts.
Alert references from tonight
Recovery events from the
Showcase: Smoke Monitorworkflow (these ran after agno transient recoveries matching the PDT timestamps in the alerts):Test plan
/api/smokehangs 20s+ (status quo 502 loop)/api/copilotkitPOST emits valid content then hangs (matches earlier diagnostic)Showcase: Smoke Monitorruns for agno stability