Commit 37219e3
authored
fix: prevent agent Workflows exhausting subrequests (#182)
## Summary
- Raise the agent Worker subrequest allowance to Cloudflare's paid-plan
maximum.
- Prevent normal model, Daytona, database, storage, and Durable Object
traffic from terminating semantically active agent runs.
- Document why the transport budget must match the existing 25,000-step
Workflow contract.
## Context
Production QA for the pomodoro-app failure proved the prior fourth-tool
fix works: all four tool calls completed. The next model turn then
failed four times with Cloudflare's exact `Too many subrequests by
single Worker invocation` error. This PR fixes that independent
deployment boundary.
No separate Linear issue or plan document exists for this production
incident.
## Architecture
Cloudflare counts external fetches and Cloudflare-service calls against
one Workflow-instance subrequest budget. The agent loop is intentionally
completion-driven, so `apps/agent-worker/wrangler.jsonc` now pins the
paid-plan maximum while the existing 25,000-step limit, operation
timeouts, cancellation, and provider quotas remain the operational
safeguards.
## Decisions Made
| Decision | Choice | Alternatives considered | Reasoning |
| --- | --- | --- | --- |
| Budget location | Top-level agent Worker `limits.subrequests` | Model
retries or per-tool workarounds | This is the Cloudflare-owned
deployment boundary named by the runtime error. |
| Budget value | Paid-plan maximum, 10,000,000 | Arbitrary lower
ceilings | Agent work varies by sandbox and tool traffic; a lower value
would remain a hidden product limit and subrequests are not
preallocated. |
| Scope | Agent Worker only | Raise every Worker | Only the long-running
agent Workflow demonstrated this workload and failure mode. |
## Edge Cases Handled
| Scenario | Handling |
| --- | --- |
| Long app-building run uses many provider and sandbox requests | The
platform budget no longer terminates the run before its configured
Workflow-step ceiling. |
| Other Workers receive ordinary webhook or gateway traffic | Their
limits remain unchanged. |
| Runaway or abandoned run | Existing cancellation, timeouts, provider
quotas, and Workflow steps remain in force. |
## How to Review
1. Review `apps/agent-worker/wrangler.jsonc` for the deployment limit.
2. Review `apps/agent-worker/README.md` for the architectural contract.
## Verification
- [x] `pnpm lint`
- [x] `pnpm typecheck`
- [x] `pnpm turbo build --force`
- [x] `pnpm deadcode`
- [x] `pnpm architecture:check`
- [x] `pnpm turbo skills:build`
- [x] `wrangler deploy --dry-run --config
apps/agent-worker/wrangler.jsonc`
- [ ] Rerun the exact failing flow on production after merge and
Cloudflare deployment.1 parent 5fb2bac commit 37219e3
2 files changed
Lines changed: 7 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
83 | 83 | | |
84 | 84 | | |
85 | 85 | | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
86 | 90 | | |
87 | 91 | | |
88 | 92 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
9 | 12 | | |
10 | 13 | | |
11 | 14 | | |
| |||
0 commit comments