Skip to content

docs: clarify wait billing and what maxDuration measures - #5175

Draft
ericallam wants to merge 1 commit into
mainfrom
docs/wait-billing-max-duration
Draft

ericallam wants to merge 1 commit into
mainfrom
docs/wait-billing-max-duration

Conversation

@ericallam

Copy link
Copy Markdown
Member

Two docs pages gave AI assistants and content writers the wrong picture.

Wait billing (snippets/paused-execution-free.mdx, shown on /wait, /wait-for, /wait-until): it didn't mention waitpoint tokens, so it read as if the 5 second rule covered every wait. It now says token and child-run waits are never billed, however long, and that a wait.for/wait.until of 5 seconds or less is billed in full.

maxDuration (runs/max-duration.mdx): it said maxDuration is compared to CPU time. The timeout manager compares cpuTime from the usage measurement, which is wallTime - totalPauses (packages/core/src/v3/usage/devUsageManager.ts), so time spent awaiting an LLM call counts. Reworded to execution time minus paused waits, and noted that wait.for/wait.until of 5 seconds or less runs in-process and counts.

🤖 Generated with Claude Code

Token and child-run waits are never billed; the 5 second rule only applies to
wait.for/wait.until (over 5s is free, 5s or less billed in full).
maxDuration compares wall time minus paused waits, not CPU time, so awaited
network calls count.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@changeset-bot

changeset-bot Bot commented Dec 3, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 627da6b

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@coderabbitai

coderabbitai Bot commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Walkthrough

The documentation now describes maxDuration as a limit on attempt execution time. It defines execution time as wall-clock time since the attempt started, excluding paused time and including network waits. It also specifies which wait calls do not count toward execution time or compute usage, and clarifies that waits of 5 seconds or less using wait.for or wait.until count in full.

Merge Risk: Low · up to 627da

The docs leave the behavior of a wait of exactly 5 seconds unstated. Readers could misjudge whether such a wait counts toward maxDuration or compute usage. The fix is a one-line wording change, and the risk of merging is low.

Pre-merge checks: Passed 3 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Description check Warning The description explains the problem in both docs pages, names the changed files, and states what the new text says. It cites the usage measurement source that supports the maxDuration change. It does… Add the template sections: a 'Closes #' line (or state that no issue applies), the checklist with each item checked or explained, a Testing section describing how the docs were checked (for example, a rendered preview or a code-path …
Passed Passed checks: 3 passed

Check name Status Explanation
Title check Passed The title "docs: clarify wait billing and what maxDuration measures" matches the two documentation changes in the PR: the wait billing snippet and the maxDuration page. It names the main change and fo…
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 "docs: clarify wait billing and what maxDuration measures" matches the two documentation changes in the PR: the wait billing snippet and the maxDuration page. It names the main change and follows a conventional docs prefix. It is concise and specific.

Full details: Description check

Explanation

The description explains the problem in both docs pages, names the changed files, and states what the new text says. It cites the usage measurement source that supports the maxDuration change. It does not follow the repository template: the Closes #<issue> line, the checklist, the Testing section, the Changelog section, and the Screenshots section are all missing. The description also lacks any statement of how the changes were tested or verified.

Resolution

Add the template sections: a 'Closes #<issue>' line (or state that no issue applies), the checklist with each item checked or explained, a Testing section describing how the docs were checked (for example, a rendered preview or a code-path check), a Changelog entry, and a Screenshots section (or mark it not applicable, since these are text-only docs changes).

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

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments

Minor 1
  1. State the five-second boundary explicitly.
Review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: ea51fe73-6a48-425c-b810-01932ec4b793
Commits

Reviewing files that changed from the base of the PR and between 6270380 and 627da6b.

Files selected for processing: 2

  • docs/runs/max-duration.mdx
  • docs/snippets/paused-execution-free.mdx

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

Review details

Context from checks skipped due to timeout: 1

  • GitHub Check: Analyze (javascript-typescript)
Additional context used

Code guidelines: 3

docs/AGENTS.md — auto-discovered
.claude/rules/docs-writing.md — auto-discovered
.cursor/rules/writing-tasks.mdc — auto-discovered
Path-based instructions: 3

Applicability reference: AGENTS.md: # AGENTS.md Docs live in `docs/` as MDX, rendered by the docs site in `apps/docs`.

CodeRabbit inference engine (docs/AGENTS.md)

Files:

  • docs/runs/max-duration.mdx
  • docs/snippets/paused-execution-free.mdx
Source excerpt: MDX rendered by the docs site in `apps/docs`; `docs/AGENTS.md` has the full guide, including what each CI check failure means.

CodeRabbit inference engine (.claude/rules/docs-writing.md)

Files:

  • docs/runs/max-duration.mdx
  • docs/snippets/paused-execution-free.mdx
Source excerpt: You MUST import from `@trigger.dev/sdk` (NEVER `@trigger.dev/sdk/v3`) Source excerpt: You MUST NEVER use `client.defineJob` Source excerpt: YOU MUST `export` every task, including subtasks Source excerpt: Key points: Each ta...

CodeRabbit inference engine (.cursor/rules/writing-tasks.mdc)

Files:

  • docs/runs/max-duration.mdx
  • docs/snippets/paused-execution-free.mdx
Additional comments: 2

docs/snippets/paused-execution-free.mdx: 1

4-4: Data Integrity & Integration

The docs claim that wait.forToken waits are not billed does not conflict with the inspected code. Token waits run through runtime.waitUntil, which wraps them in usage.pauseAsync. The usage manager removes paused time from cpuTime, and ProdUsageManager bills only that cpuTime delta. A one-second token wait is therefore excluded from billed compute, as is a 10-second wait.for. The comment's concern that a charge could apply to either wait is not supported.

docs/runs/max-duration.mdx: 1

36-36: Data Integrity & Integration

The concern does not hold for the repository-owned accounting path. The SDK sends a 10-second wait.for through runtime.waitUntil, which runs inside usage.pauseAsync. The dev measurement subtracts that paused interval, and the reported durationMs is the measured CPU sample. The docs statement that such waits are excluded matches this path. The only remaining premise is production enforcement, which this checkout does not contain, and the comment's stated 60-second rule has no source in the reviewed docs. No inspected repository source establishes that the wait exhausts maxDuration or increases durationMs.

The `maxDuration` is set in seconds, and is compared to the execution time of a single attempt (see [attempts](/runs#attempts)) of the task. Execution time is the wall-clock time since the attempt started, minus any time the run was paused. It includes time spent awaiting network calls such as LLM responses. It does not include time spent paused during the following:

- `wait.for` calls
- `wait.for` and `wait.until` calls longer than 5 seconds (shorter waits run in-process and count towards it)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor · Functional Correctness · Quick win

State the five-second boundary explicitly.

The SDK counts a wait of exactly five seconds, but “shorter waits” does not include that boundary. Say “waits of 5 seconds or less” so readers can determine how the limit applies.

This branch has not been deployed

No deployments
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