Skip to main content

Module request_gap

Module request_gap 

Source
Expand description

Shared idle-gap tracker for detecting when the provider prompt cache has likely expired between dispatched LLM requests. Shared tracker for detecting idle gaps between dispatched LLM requests.

Both the interactive session state (SessionStats in src/agent/runloop/unified/state.rs, in the vtcode binary crate) and the headless session state (AgentSessionState in crate::core::agent::session) need to answer the same two questions: “has a request been dispatched yet this session” and “how long has it been since the last one”. Both use that signal to warn when the provider’s server-side prompt cache has likely expired, so the next request may unexpectedly re-pay full input cost. This tracker holds the single piece of state (last_request_at) and the logic derived from it, so each embedding site only has to delegate its existing public methods rather than reimplement the same Option<Instant> bookkeeping.

Structs§

RequestGapTracker
Tracks the wall-clock time of the most recently dispatched LLM request.

Functions§

format_gap
Formats an elapsed cache gap for the advisory message. Sub-minute gaps are shown in seconds (e.g. “45s”) rather than rounding down to “0 min”, which would otherwise happen for any threshold under 60 seconds.