Skip to main content

Module usage_limits

Module usage_limits 

Source
Expand description

Shared types and helpers for provider usage-limit detection and auto-resume.

When a provider’s CLI hits an upstream rate / usage / weekly limit, zag wants to (a) detect the limit, (b) compute when it resets, (c) schedule a resume attempt at that moment, and (d) record the lifecycle in the session log via crate::session_log::LogEventKind::UsageLimitHit / UsageLimitResumed / UsageLimitResumeFailed.

Each provider has its own detector module (e.g. providers/claude/usage_limits.rs). All detectors return UsageLimit so the scheduler in zag-orch can treat the four providers uniformly.

Structs§

UsageLimit
A successful detection of an upstream usage / rate limit.
UsageLimitConfig
Top-level [usage_limits] config block. Loaded from zag.toml.
UsageLimitProviderOverride
Per-provider override. Any unset field falls back to the top-level value.

Enums§

UsageLimitScope

Functions§

compute_resume_at
Compute the moment zag should attempt to resume.
log_event_hit
Build a crate::session_log::LogEventKind::UsageLimitHit from a detected UsageLimit. Single source of truth for the scheduled-resume path — every site that knows a resume timer is going to fire (relay, foreground auto-resume loop) calls this so the wire shape can never drift.
to_log_event_hit
Build a UsageLimitHit log event for orphan log-only detections (e.g. the Codex TUI line parser) where no auto-resume scheduler is involved. Generates a fresh incident id; scheduling fields are left empty because nothing is scheduled.