Skip to content

fix(showcase): raise /api/smoke upstream timeout from 25s to 45s - #4089

Merged
jpr5 merged 1 commit into
mainfrom
fix/smoke-timeout-45s
Apr 19, 2026
Merged

jpr5 merged 1 commit into
mainfrom
fix/smoke-timeout-45s

Conversation

@jpr5

@jpr5 jpr5 commented Apr 19, 2026

Copy link
Copy Markdown
Contributor

Summary

Cold-start 502s on showcase package smoke probes (notably agno) consistently land just over the 25s upstream budget. The Next.js /api/smoke route uses AbortSignal.timeout(25000) to call its own /api/copilotkit which proxies to the Python agent which calls the LLM. On cold start, the end-to-end round-trip takes >25s and the probe aborts with latency_ms: 25001, stage: "timeout", returning 502.

This PR raises the upstream budget from 25s -> 45s across all showcase packages that exercise a full agent round-trip on smoke, and bumps Next.js maxDuration from 30s -> 60s so the route can actually run that long. The create-integration template is bumped too so new packages inherit the new budget.

The 3 langgraph-* routes have a different (lightweight health probe) pattern and ms-agent-dotnet is already at 50s — their maxDuration is bumped for consistency but their abort budgets are left alone.

Evidence — agno 502 alerts tonight (PDT):

  • 18:40 PDT attempt 1 — HTTP 502 on /api/smoke, self-recovered
  • 19:42 PDT attempt 2 — HTTP 502 on /api/smoke, /api/health already 200

Both probes had latency_ms: 25001, stage: "timeout" — a textbook cold-start boundary trip.

Why 45s (not 60s or 90s)

The alert tells us the cold path lands just over 25s. 45s gives ~20s of headroom — enough to absorb cold starts without making slow failures look like slow successes. Tail latency beyond 45s would still alert, which is the intent. If we see tail probes >45s, we'll revisit with a post-deploy warmup ping.

Files changed (17)

  • 16 showcase/packages/*/src/app/api/smoke/route.ts (13 with both abort + maxDuration bumped, 3 langgraph-* with only maxDuration bumped, ms-agent-dotnet untouched)
  • showcase/scripts/create-integration/index.ts template (new packages inherit the new budget)

Test plan

  • Deploy to Railway, observe agno /api/smoke no longer 502s on cold start
  • Confirm other showcase services still smoke-pass
  • If cold path drifts beyond 45s for any service, add a post-deploy warmup step (deferred)

Do not merge yet — pending user review.

@vercel

vercel Bot commented Apr 19, 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 19, 2026 4:00am
docs Ready Ready Preview, Comment Apr 19, 2026 4:00am
form-filling Ready Ready Preview, Comment Apr 19, 2026 4:00am
research-canvas Ready Ready Preview, Comment Apr 19, 2026 4:00am
travel Ready Ready Preview, Comment Apr 19, 2026 4:00am

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

Cold-start on showcase packages with heavy Python agents (agno in particular)
consistently lands just over the 25s budget, producing 502s on first probe
with latency_ms: 25001 and stage: "timeout". Raise the upstream
AbortSignal.timeout on /api/smoke from 25s to 45s across all 16 showcase
packages that exercise the full agent round-trip, and bump Next.js
maxDuration from 30s to 60s so the route can actually run that long.

Also bumps the create-integration template so new packages inherit the
new budget.

Tail-latency beyond 45s will still alert — which is the intent.

Evidence: agno 502 alerts tonight at 18:40 PDT and 19:42 PDT, both with
latency_ms: 25001, stage: "timeout" on /api/smoke. /api/health already
200 on both probes — pure cold-start boundary issue.
@jpr5
jpr5 force-pushed the fix/smoke-timeout-45s branch from f46283a to df83668 Compare April 19, 2026 03:56
@jpr5
jpr5 merged commit 35a7e00 into main Apr 19, 2026
12 checks passed
@jpr5
jpr5 deleted the fix/smoke-timeout-45s branch April 19, 2026 14:23
jpr5 added a commit that referenced this pull request Apr 19, 2026
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.
zeekay pushed a commit to Dream-AI-4444/CopilotKit that referenced this pull request Sep 11, 2026
…ilotKit#4089)

## Summary

Cold-start 502s on showcase package smoke probes (notably `agno`)
consistently land just over the 25s upstream budget. The Next.js
`/api/smoke` route uses `AbortSignal.timeout(25000)` to call its own
`/api/copilotkit` which proxies to the Python agent which calls the LLM.
On cold start, the end-to-end round-trip takes >25s and the probe aborts
with `latency_ms: 25001, stage: "timeout"`, returning 502.

This PR raises the upstream budget from **25s -> 45s** across all
showcase packages that exercise a full agent round-trip on smoke, and
bumps Next.js `maxDuration` from 30s -> 60s so the route can actually
run that long. The `create-integration` template is bumped too so new
packages inherit the new budget.

The 3 `langgraph-*` routes have a different (lightweight health probe)
pattern and `ms-agent-dotnet` is already at 50s — their `maxDuration` is
bumped for consistency but their abort budgets are left alone.

**Evidence — agno 502 alerts tonight (PDT):**
- 18:40 PDT attempt 1 — HTTP 502 on `/api/smoke`, self-recovered
- 19:42 PDT attempt 2 — HTTP 502 on `/api/smoke`, `/api/health` already
200

Both probes had `latency_ms: 25001, stage: "timeout"` — a textbook
cold-start boundary trip.

## Why 45s (not 60s or 90s)

The alert tells us the cold path lands **just over** 25s. 45s gives ~20s
of headroom — enough to absorb cold starts without making slow failures
look like slow successes. Tail latency beyond 45s would still alert,
which is the intent. If we see tail probes >45s, we'll revisit with a
post-deploy warmup ping.

## Files changed (17)

- 16 `showcase/packages/*/src/app/api/smoke/route.ts` (13 with both
abort + maxDuration bumped, 3 langgraph-* with only maxDuration bumped,
ms-agent-dotnet untouched)
- `showcase/scripts/create-integration/index.ts` template (new packages
inherit the new budget)

## Test plan

- [ ] Deploy to Railway, observe agno `/api/smoke` no longer 502s on
cold start
- [ ] Confirm other showcase services still smoke-pass
- [ ] If cold path drifts beyond 45s for any service, add a post-deploy
warmup step (deferred)

Do not merge yet — pending user review.

This branch was successfully deployed

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