Skip to content

fix(server): a workflow hook starts at most 60 runs a minute - #41989

Merged
juliusmarminge merged 1 commit into
mainfrom
t3code/workflow-hook-pacing
Nov 24, 2026
Merged

juliusmarminge merged 1 commit into
mainfrom
t3code/workflow-hook-pacing

Conversation

@juliusmarminge

Copy link
Copy Markdown
Member

What changes

A workflow's webhook now starts at most 60 new runs a minute, the same per-hook limit the relay keeps and the one scheduled-task webhooks already keep on the server. A request past the limit is answered 429 with retry-after: 60 and the rate_limited outcome, so a sender that retries is served a minute later.

A retry of a delivery that already has a run (same key or delivery header) starts nothing, so it does not count toward the minute and is still answered with that run.

The count is kept in memory per hook, so it starts over when the server restarts or the workflow files are reloaded.

For the reviewer

  • The new WorkflowHookBusyError is part of WorkflowError, so deliver keeps its signature and existing callers need no change.
  • docs/user/workflows.md states the limit next to the existing body-size and retry sentences.

Tested

  • Workflows.test.ts: with time held still, 60 requests to one hook start runs, the 61st is refused, a retry of the first is answered with its run, and after a minute a new request starts a run. Run once without the change, where the 61st started a run.
  • webhookRoute.test.ts: the route answers 429 with retry-after: 60.
  • vp run check:changed passes.

🤖 Generated with Claude Code

A workflow's hook now keeps the same per-minute limit the relay and scheduled-task
webhooks keep. Requests past it are answered 429 with retry-after; a retry of a
delivery that already has a run is still answered with that run.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@github-actions github-actions Bot added vouch:trusted Author is trusted by repo permissions or the VOUCHED list. size:M 30-99 changed lines (additions + deletions). labels Nov 24, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Thread transfer impact

✅ Thread transfer remains within every enforced ceiling.

Provider Metric Main baseline This PR Impact PR ceiling
Codex Total thread wire 5.0 KiB 5.0 KiB 0 B (0.0%) 6.8 KiB ✅
Codex Thread snapshot wire 3.8 KiB 3.8 KiB 0 B (0.0%) 4.9 KiB ✅
Codex Live turn WebSocket wire 1.2 KiB 1.2 KiB 0 B (0.0%) 2.0 KiB ✅
Codex Live turn WebSocket decoded 21.5 KiB 21.5 KiB 0 B (0.0%) 24.4 KiB ✅
Codex Live turn messages 1 1 0 (0.0%) 8 ✅
Claude Total thread wire 5.0 KiB 5.0 KiB 0 B (0.0%) 6.8 KiB ✅
Claude Thread snapshot wire 3.8 KiB 3.8 KiB 0 B (0.0%) 4.9 KiB ✅
Claude Live turn WebSocket wire 1.2 KiB 1.2 KiB 0 B (0.0%) 2.0 KiB ✅
Claude Live turn WebSocket decoded 21.9 KiB 21.9 KiB 0 B (0.0%) 24.4 KiB ✅
Claude Live turn messages 1 1 0 (0.0%) 8 ✅

Other scenarios

All 64 scenario measurements match main.

All 64 scenario measurements
Provider Scenario Metric Main baseline This PR Impact PR ceiling
Codex short turn resume WebSocket decoded 10.5 KiB 10.5 KiB 0 B (0.0%) 12.7 KiB ✅
Codex short turn resume WebSocket messages 2 2 0 (0.0%) 2 ✅
Codex long turn running, cold open HTTP decoded 281.7 KiB 281.7 KiB 0 B (0.0%) 302.7 KiB ✅
Codex long turn running, cold open rows 75 75 0 (0.0%) 75 ✅
Codex long turn running, history page HTTP decoded 92.4 KiB 92.4 KiB 0 B (0.0%) 107.4 KiB ✅
Codex long turn running, history page rows 75 75 0 (0.0%) 75 ✅
Codex long turn finished, cold open HTTP decoded 381.5 KiB 381.5 KiB 0 B (0.0%) 410.2 KiB ✅
Codex long turn finished, cold open rows 151 151 0 (0.0%) 151 ✅
Codex long turn finished, socket cold open WebSocket decoded 381.6 KiB 381.6 KiB 0 B (0.0%) 410.2 KiB ✅
Codex long turn finished, socket cold open WebSocket messages 2 2 0 (0.0%) 2 ✅
Codex long turn finished, socket cold open rows 151 151 0 (0.0%) 151 ✅
Codex long turn finished, work page HTTP decoded 186.2 KiB 186.2 KiB 0 B (0.0%) 200.2 KiB ✅
Codex long turn finished, work page rows 150 150 0 (0.0%) 150 ✅
Codex idle thread resume WebSocket decoded 65 B 65 B 0 B (0.0%) 200 B ✅
Codex idle thread resume WebSocket messages 1 1 0 (0.0%) 1 ✅
Codex fleet shell snapshot HTTP decoded 42.4 KiB 42.4 KiB 0 B (0.0%) 53.7 KiB ✅
Codex fleet shell snapshot rows 27 27 0 (0.0%) 27 ✅
Codex fleet shell subscribe WebSocket decoded 65 B 65 B 0 B (0.0%) 200 B ✅
Codex fleet shell subscribe WebSocket messages 1 1 0 (0.0%) 1 ✅
Codex fleet shell resume check HTTP decoded 18 B 18 B 0 B (0.0%) 100 B ✅
Codex fleet shell resume check rows 0 0 0 0 ✅
Codex stale shell reload HTTP decoded 42.4 KiB 42.4 KiB 0 B (0.0%) 53.7 KiB ✅
Codex stale shell reload rows 27 27 0 (0.0%) 27 ✅
Codex stale shell resume WebSocket decoded 140 B 140 B 0 B (0.0%) 400 B ✅
Codex stale shell resume WebSocket messages 2 2 0 (0.0%) 2 ✅
Codex stale todo list cold open HTTP decoded 72.4 KiB 72.4 KiB 0 B (0.0%) 83.0 KiB ✅
Codex stale todo list cold open rows 75 75 0 (0.0%) 75 ✅
Codex stale todo list cold open nodes 2 2 0 (0.0%) 4 ✅
Codex stale todo list cold open subagents 2 2 0 (0.0%) 4 ✅
Codex stale todo list cold open plans 1 1 0 (0.0%) 2 ✅
Codex stale todo list cold open providerTurns 1 1 0 (0.0%) 2 ✅
Codex stale todo list cold open checkpoints 1 1 0 (0.0%) 2 ✅
Claude short turn resume WebSocket decoded 10.6 KiB 10.6 KiB 0 B (0.0%) 12.7 KiB ✅
Claude short turn resume WebSocket messages 2 2 0 (0.0%) 2 ✅
Claude long turn running, cold open HTTP decoded 283.3 KiB 283.3 KiB 0 B (0.0%) 302.7 KiB ✅
Claude long turn running, cold open rows 75 75 0 (0.0%) 75 ✅
Claude long turn running, history page HTTP decoded 93.4 KiB 93.4 KiB 0 B (0.0%) 107.4 KiB ✅
Claude long turn running, history page rows 75 75 0 (0.0%) 75 ✅
Claude long turn finished, cold open HTTP decoded 384.2 KiB 384.2 KiB 0 B (0.0%) 410.2 KiB ✅
Claude long turn finished, cold open rows 151 151 0 (0.0%) 151 ✅
Claude long turn finished, socket cold open WebSocket decoded 384.3 KiB 384.3 KiB 0 B (0.0%) 410.2 KiB ✅
Claude long turn finished, socket cold open WebSocket messages 2 2 0 (0.0%) 2 ✅
Claude long turn finished, socket cold open rows 151 151 0 (0.0%) 151 ✅
Claude long turn finished, work page HTTP decoded 188.1 KiB 188.1 KiB 0 B (0.0%) 200.2 KiB ✅
Claude long turn finished, work page rows 150 150 0 (0.0%) 150 ✅
Claude idle thread resume WebSocket decoded 66 B 66 B 0 B (0.0%) 200 B ✅
Claude idle thread resume WebSocket messages 1 1 0 (0.0%) 1 ✅
Claude fleet shell snapshot HTTP decoded 43.0 KiB 43.0 KiB 0 B (0.0%) 53.7 KiB ✅
Claude fleet shell snapshot rows 27 27 0 (0.0%) 27 ✅
Claude fleet shell subscribe WebSocket decoded 66 B 66 B 0 B (0.0%) 200 B ✅
Claude fleet shell subscribe WebSocket messages 1 1 0 (0.0%) 1 ✅
Claude fleet shell resume check HTTP decoded 18 B 18 B 0 B (0.0%) 100 B ✅
Claude fleet shell resume check rows 0 0 0 0 ✅
Claude stale shell reload HTTP decoded 43.0 KiB 43.0 KiB 0 B (0.0%) 53.7 KiB ✅
Claude stale shell reload rows 27 27 0 (0.0%) 27 ✅
Claude stale shell resume WebSocket decoded 140 B 140 B 0 B (0.0%) 400 B ✅
Claude stale shell resume WebSocket messages 2 2 0 (0.0%) 2 ✅
Claude stale todo list cold open HTTP decoded 73.4 KiB 73.4 KiB 0 B (0.0%) 83.0 KiB ✅
Claude stale todo list cold open rows 75 75 0 (0.0%) 75 ✅
Claude stale todo list cold open nodes 2 2 0 (0.0%) 4 ✅
Claude stale todo list cold open subagents 2 2 0 (0.0%) 4 ✅
Claude stale todo list cold open plans 1 1 0 (0.0%) 2 ✅
Claude stale todo list cold open providerTurns 1 1 0 (0.0%) 2 ✅
Claude stale todo list cold open checkpoints 1 1 0 (0.0%) 2 ✅

Baseline: bb0862e · PR result: 062e4fe · Source CI: success

Scenario and decoded snapshot size

10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.

  • Codex decoded thread snapshot: 108.5 KiB
  • Claude decoded thread snapshot: 108.8 KiB

Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.

@coderabbitai

coderabbitai Bot commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Workflow delivery now limits each hook to 60 new runs in a rolling 60-second window. Idempotency retries do not count toward the limit. Busy hooks return HTTP 429 with a Retry-After value of 60.

Changes: Hook delivery rate limiting

Layer / File(s) Summary
Per-hook limit and idempotency handling
apps/server/src/workflows/Workflows.ts, apps/server/src/workflows/WorkflowEngine.ts, apps/server/src/workflows/Workflows.test.ts
WorkflowHookBusyError is added to the workflow error types. The engine limits each hook to 60 new runs in 60 seconds, while existing idempotency retries do not consume capacity. Tests cover the limit, retries, and acceptance after a minute.
Webhook response for busy hooks
apps/server/src/scheduledTasks/webhookRoute.ts, apps/server/src/scheduledTasks/webhookRoute.test.ts, docs/user/workflows.md
The webhook route returns HTTP 429, a rate_limited error, and a 60-second Retry-After header for busy hooks. The route test and Webhooks documentation cover this behavior.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Feature

Merge Risk: Minimal · up to 062e4

Adds a per-hook limit of 60 new workflow runs per minute, returning 429 with Retry-After 60. Retries for existing runs are unaffected. No merge-blocking risk remains; a rare burst of concurrent duplicate deliveries may briefly use extra capacity.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title states the main change: a workflow hook now starts at most 60 runs per minute. It follows conventional commit form with the fix(server) scope. The title is specific and matches the changeset…
Description check Passed The description follows the template. It has a 'What changes' section that explains the 60-runs-per-minute limit, the 429 and retry-after response, and the retry exemption. It has a 'For the reviewer'…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title states the main change: a workflow hook now starts at most 60 runs per minute. It follows conventional commit form with the fix(server) scope. The title is specific and matches the changeset, which adds the per-hook limit in WorkflowEngine, the 429 response in the webhook route, the error class, tests, and docs.

Full details: Description check

Explanation

The description follows the template. It has a 'What changes' section that explains the 60-runs-per-minute limit, the 429 and retry-after response, and the retry exemption. It has a 'For the reviewer' section covering the WorkflowError change and docs. It has a 'Tested' section with focused test results. The template sections Problem and Scope are missing or unlabeled. The description does not name a linked issue or say why no issue is needed, and it does not state a bug report. The template asks for these in Scope, and the description does not give a Problem statement. The description is mostly complete, so the check passes, but the author should add a Problem section and a Scope section that links the issue or explains why none is needed.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between bb0862e and 062e4fe.

Files selected for processing: 6

  • apps/server/src/scheduledTasks/webhookRoute.test.ts
  • apps/server/src/scheduledTasks/webhookRoute.ts
  • apps/server/src/workflows/WorkflowEngine.ts
  • apps/server/src/workflows/Workflows.test.ts
  • apps/server/src/workflows/Workflows.ts
  • docs/user/workflows.md

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 1 remain after this review.

@juliusmarminge
juliusmarminge merged commit 27c2d01 into main Nov 24, 2026
37 checks passed
@juliusmarminge
juliusmarminge deleted the t3code/workflow-hook-pacing branch November 24, 2026 07:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M 30-99 changed lines (additions + deletions). vouch:trusted Author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant