agent-deadline 0.1.0

Cooperative per-task deadline primitive for AI agent workflows.
Documentation
  • Coverage
  • 100%
    17 out of 17 items documented1 out of 16 items with examples
  • Size
  • Source code size: 26.0 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 156.4 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 3s Average build duration of successful builds.
  • all releases: 3s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • MukundaKatta/agent-deadline-rs
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • MukundaKatta

agent-deadline

Crates.io License: MIT

Cooperative per-task deadline primitive for AI agent workflows.

Agent loops chain LLM calls and tool calls. Each step has its own network timeout, but rarely is there a single wall-clock cap on the whole task. This crate is a small zero-dependency Deadline type that the loop checks between steps and hands to downstream calls as their remaining timeout.

Cooperative model: code checks the deadline. Nothing is preempted.

Install

[dependencies]
agent-deadline = "0.1"

Use

use std::time::Duration;
use agent_deadline::{Deadline, DeadlineExceeded};

let deadline = Deadline::after(Duration::from_secs(30));

// Between steps, check whether the cap has passed.
deadline.check_or_err().unwrap();

// Plug the remaining time into per-call timeouts.
let remaining = deadline.remaining();

// Tighten for a nested operation: pick the earlier of the two.
let retry = deadline.intersect(&Deadline::after(Duration::from_secs(5)));
assert!(retry.remaining() <= Duration::from_secs(5));

check_or_err() returns Err(DeadlineExceeded) once the clock has passed the deadline. Catch it at the top of the loop to return a partial result instead of hanging on the next call.

License

MIT