Add optional whole-run wall-clock deadline to graph execution#29
Conversation
|
Warning Review limit reachedYou’ve reached a temporary PR review limit under our Fair Usage Limits Policy. Next review available in: 42 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: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (5)
Comment |
CompiledGraph::with_run_deadline(d) bounds the whole run by a wall clock, checked at every super-step boundary. When the elapsed run time first reaches the deadline, the run stops *between* super-steps with TinyAgentsError::Timeout, leaving the last committed boundary checkpoint intact and resumable. This is the durable alternative to wrapping run() in an external tokio::time::timeout, which aborts mid-super-step and cannot leave a clean checkpoint. The deadline bounds scheduling, not a single in-flight node — pair it with with_node_timeout to also bound individual handlers. Tests: deadline trips between super-steps (Timeout); a run that finishes in time is unaffected; a deadline trip on a checkpointed thread leaves the last boundary checkpoint intact and the run resumes to completion. fmt + clippy -D warnings clean; full suite green. Docs: builder.md.
1945739 to
1982d9e
Compare
💡 Codex ReviewWhen tinyagents/src/graph/compiled/executor.rs Line 427 in 1945739 When a checkpointed run trips the new deadline after at least one super-step, ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Whole-run wall-clock deadline for graph execution
Adds an optional per-run deadline to
CompiledGraph, checked at every super-step boundary.Motivation
Today the only way to bound a whole graph run by wall clock is to wrap
run()/run_with_thread()in an externaltokio::time::timeout. That aborts the run mid-super-step, which cannot leave a clean checkpoint — so a durable graph that times out loses the in-flight super-step's boundary and the caller can't cleanly resume or inspect it. (This bit a downstream: a cron-driven reflection loop wrapped each run in an outertokio::time::timeout; a slow run left no resumable state.)What this does
CompiledGraph::with_run_deadline(d)stops the run between super-steps: when the elapsed run time first reachesd, the executor fails with the existingTinyAgentsError::Timeoutbefore scheduling the next super-step, so the last committed boundary checkpoint stays intact and resumable.TinyAgentsError::Timeout(already documented as "the run exceeded its wall-clock deadline") — no new error variant, no breaking change.RecursionLimitboundary check in the superstep loop;None(default) is a no-op.with_node_timeoutto bound individual handlers. (A future composition with the cancellation token could add best-effort in-flight cancellation; deliberately out of scope here to keep the primitive small and the checkpoint guarantee clean.)Tests (
graph/compiled/test.rs)run_deadline_stops_between_supersteps— a deadline shorter than the run trips withTimeout.run_deadline_allows_a_run_that_finishes_in_time— no false trip when the run completes in time.run_deadline_leaves_last_checkpoint_resumable— on a checkpointed thread, a deadline trip leaves the last boundary checkpoint intact, and resuming (no deadline) runs the remaining super-steps to completion.cargo fmt --check,cargo clippy --all-targets --features sqlite -- -D warnings, and the full suite are green. Public API doc updated indocs/modules/graph/builder.md.