Repository navigation
fix(showcase): extend watchdog grace to claude-sdk-typescript and mastra - #4124
Merged
Merged
Conversation
…mastra Two more starters are restart-looping with the same pattern #4123 fixed for langgraph-*: the 90s (3-strike) watchdog budget is shorter than the cold-start path on a fresh Railway container, so the agent gets killed before it ever reports healthy, and the loop never breaks. Railway evidence: - claude-sdk-typescript (package, :8000): restart-looping since 04-20 16:54 UTC. Runs compiled `node /app/agent_server.js` which spins up the full @anthropic-ai/claude-agent-sdk. Package entrypoint is hand- written (not generator-emitted), so add the same grace block inline matching #4123's shape. - mastra (starter, :8123/api): restart-looping since 04-20 18:18 UTC. Runs `mastra dev` on :8123 alongside Next.js on ${PORT:-10000}. `mastra dev` performs a tsx build + Mastra server boot on first request — legitimate supervised process, grace is the right fix. Package-level mastra has no watchdog (the entire package IS the Next.js app; no separate agent to watchdog) — PR #4116's classification of "N/A" was correct for the package. The starter has a separate Mastra dev server, so the generator-emitted watchdog is legitimate there. Per-framework grace (not universal) preserves the #4123 design: uvicorn and express agents are responsive within the 2-3s sleep before AGENT_HEALTH_CHECK, so adding grace elsewhere would only delay legitimate restart on true hangs. This commit covers the generator mapping + the hand-written package entrypoint. The regenerated starter entrypoints land in the next commit.
Regenerated via `cd showcase/scripts && npx tsx generate-starters.ts` after the getWatchdogGraceSeconds() mapping update in the previous commit. Only these two starters change — every other framework still returns 0s from the grace mapping, so their entrypoints are byte-for- byte identical to main.
jpr5
requested review from
marthakelly,
mme,
ranst91 and
tylerslaton
as code owners
April 21, 2026 18:48
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
…tra (CopilotKit#4124) ## Incident Two more showcase starters are in a Railway restart loop with the same shape that CopilotKit#4123 fixed for langgraph-*: - **`claude-sdk-typescript`** (package, :8000) — restart-looping since **04-20 16:54 UTC**. Runs compiled `node /app/agent_server.js`. - **`mastra`** (starter, :8123/api) — restart-looping since **04-20 18:18 UTC**. Runs `npx mastra dev` on :8123 alongside Next.js on ${PORT:-10000}. ## Root cause Same as CopilotKit#4123: PR CopilotKit#4116's watchdog has a 90s (3-strike) kill budget. For agents whose cold-start path on a fresh Railway container exceeds 90s, the watchdog kills the agent before it ever reports healthy, and the loop never breaks. - `node /app/agent_server.js` cold-starts the full `@anthropic-ai/claude-agent-sdk` bundle. - `mastra dev` performs a tsx build + Mastra server boot on first request. Both exceed 90s on cold-start consistently enough to kill-loop in production. ## Fix Extend the `getWatchdogGraceSeconds()` mapping in `showcase/scripts/generate-starters.ts` to return 180s for `mastra` and `claude-sdk-typescript` in addition to `langgraph-*`. Regenerate the two starter entrypoints. Also apply the same grace block inline to the **package-level** `claude-sdk-typescript` entrypoint (hand-written, not generator-emitted). ## Scope decision **Per-framework grace, not universal.** Cite the alternative for the record: > Universal 180s would avoid future "which framework class needs > grace" debate and cost basically nothing on fast cold-starts > (uvicorn < 10s) — a 180s grace just delays the first probe from > 30s to 180s. Kept per-framework for this PR: 1. Smaller diff, smaller review surface (4 files vs regenerating all 17 starters). 2. Matches the existing design comment in `getWatchdogGraceSeconds()` which explicitly argues that uvicorn- responsive agents should keep 0s so legitimate hangs restart quickly. 3. We now have 3 framework classes needing grace; if a 4th appears, universalizing becomes cheap and justified on aggregate data. ## Mastra starter — watchdog kept, not dropped PR CopilotKit#4116's finisher classified **package-level** mastra as N/A (correct — the package IS the Next.js app, no separate agent). The **starter** is different: `mastra dev` runs as a legitimate separate process on :8123 alongside Next.js on :10000. The watchdog there is correctly supervising that process — grace is the right fix, not a revert. ## Files - `showcase/scripts/generate-starters.ts` — mapping + justification comment - `showcase/packages/claude-sdk-typescript/entrypoint.sh` — inline grace block (package uses :8000, hand-written entrypoint) - `showcase/starters/claude-sdk-typescript/entrypoint.sh` — regenerated - `showcase/starters/mastra/entrypoint.sh` — regenerated Package-level `mastra/entrypoint.sh` is intentionally unchanged (no watchdog, just `exec npx next start`). ## Test plan - [x] `bash -n` clean on all 3 modified `.sh` files - [x] `pnpm -C showcase/scripts test` — 1079/1079 pass - [x] `npx tsc --noEmit` in `showcase/scripts` — clean - [x] `npx tsx generate-starters.ts` is idempotent after the regen commit (no further diff) - [x] `validate-pins` — pre-existing failures on main unchanged; no new failures introduced by this PR - [ ] Railway redeploy of `claude-sdk-typescript` package service shows `[watchdog] Agent healthy after Ns — arming strike counter` and exits the restart loop - [ ] Railway redeploy of `mastra` starter service shows the same grace log line and exits the restart loop ## Refs - CopilotKit#4123 — prior langgraph grace fix (same pattern) - CopilotKit#4116 — origin of the generalized watchdog - CopilotKit#4114 / CopilotKit#4115 — original crewai-crews watchdog
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.
Incident
Two more showcase starters are in a Railway restart loop with the same
shape that #4123 fixed for langgraph-*:
claude-sdk-typescript(package, :8000) — restart-looping since04-20 16:54 UTC. Runs compiled
node /app/agent_server.js.mastra(starter, :8123/api) — restart-looping since04-20 18:18 UTC. Runs
npx mastra devon :8123 alongsideNext.js on ${PORT:-10000}.
Root cause
Same as #4123: PR #4116's watchdog has a 90s (3-strike) kill budget.
For agents whose cold-start path on a fresh Railway container exceeds
90s, the watchdog kills the agent before it ever reports healthy, and
the loop never breaks.
node /app/agent_server.jscold-starts the full@anthropic-ai/claude-agent-sdkbundle.mastra devperforms a tsx build + Mastra server boot on firstrequest.
Both exceed 90s on cold-start consistently enough to kill-loop in
production.
Fix
Extend the
getWatchdogGraceSeconds()mapping inshowcase/scripts/generate-starters.tsto return 180s formastraandclaude-sdk-typescriptin addition tolanggraph-*.Regenerate the two starter entrypoints. Also apply the same grace
block inline to the package-level
claude-sdk-typescriptentrypoint (hand-written, not generator-emitted).
Scope decision
Per-framework grace, not universal. Cite the alternative for the
record:
Kept per-framework for this PR:
17 starters).
getWatchdogGraceSeconds()which explicitly argues that uvicorn-responsive agents should keep 0s so legitimate hangs restart
quickly.
universalizing becomes cheap and justified on aggregate data.
Mastra starter — watchdog kept, not dropped
PR #4116's finisher classified package-level mastra as N/A
(correct — the package IS the Next.js app, no separate agent). The
starter is different:
mastra devruns as a legitimate separateprocess on :8123 alongside Next.js on :10000. The watchdog there is
correctly supervising that process — grace is the right fix, not a
revert.
Files
showcase/scripts/generate-starters.ts— mapping + justificationcomment
showcase/packages/claude-sdk-typescript/entrypoint.sh— inlinegrace block (package uses :8000, hand-written entrypoint)
showcase/starters/claude-sdk-typescript/entrypoint.sh—regenerated
showcase/starters/mastra/entrypoint.sh— regeneratedPackage-level
mastra/entrypoint.shis intentionally unchanged(no watchdog, just
exec npx next start).Test plan
bash -nclean on all 3 modified.shfilespnpm -C showcase/scripts test— 1079/1079 passnpx tsc --noEmitinshowcase/scripts— cleannpx tsx generate-starters.tsis idempotent after the regencommit (no further diff)
validate-pins— pre-existing failures on main unchanged; nonew failures introduced by this PR
claude-sdk-typescriptpackage serviceshows
[watchdog] Agent healthy after Ns — arming strike counterand exits the restart loopmastrastarter service shows the samegrace log line and exits the restart loop
Refs