feat: enforce per-task execution budgets - #59
Conversation
|
Warning Review limit reached
Next review available in: 52 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (5)
Comment |
milind-soni
left a comment
There was a problem hiding this comment.
Execution budgets need a few semantic fixes before they can safely enforce limits. thread.token-usage.updated is cumulative provider or thread telemetry for some drivers, so treating its absolute snapshot as current-task usage can exhaust a new task because of earlier turns; establish a per-turn baseline or consume turn-scoped deltas. A duration limit can also fire during provisioning before sendTurn exists, after which the code still dispatches the turn and the already-exhausted guard cannot stop it again. Finally, a failed tool is not necessarily a retry. Please make the counters truthful, prevent dispatch after pre-turn exhaustion, and add integration tests for resumed sessions, provisioning timeout, user interruption, and exact one-time exhaustion.
|
Addressed the requested budget semantics in b29f8fe. The guard now snapshots known per-thread provider telemetry at task start and counts only the task-local delta, so resumed/cumulative sessions do not consume a new task's token budget. A failed tool becomes a retry only when that same tool is invoked again. Deadline exhaustion during provisioning is checked immediately before sendTurn, preventing any provider dispatch after the task has already stopped; exhaustion remains one-time. Added coverage for cumulative baselines, retry classification, and exact one-time provisioning-time deadline exhaustion. Verified: corepack pnpm exec vitest run server/task-budget.test.ts server/index.test.ts (19 passed) and corepack pnpm typecheck. |
Summary
Adds optional, per-task execution budgets to the harness. Existing turns remain unlimited unless a caller explicitly supplies a
budgetonPOST /api/bots/:id/messages.task.budget.updated(approaching) andtask.budget.exhaustedeventsArchitecture
TaskBudgetGuardis a small erasable-TypeScript module compatible with the repository's native Node type-strip execution. It has explicit fields and constructor assignments—no parameter properties and no new transpiler/runtime dependency.The guard consumes only the existing canonical event stream. Token usage uses monotonic provider-reported snapshots; absent token dimensions stay absent, so a token limit is never enforced from a fabricated estimate. Computer and delegation budgets are applied only where tool titles make those actions observable.
Overlap avoided
Open PR #57 records usage and improves replay compaction. This PR does not duplicate its storage/UI accounting: it uses the canonical events to enforce explicit task limits and introduces separate budget-status events. It does touch the shared contracts/index lifecycle, so it should be merged or rebased thoughtfully with #57.
Validation
pnpm typecheckpnpm test— 69 passed, 39 skippedpnpm buildserver/index.test.ts) — passed; this is the path that previously surfaced the parameter-property failurenode --experimental-strip-types server/computer-proxy.tsLimitations