Skip to main content

Module host_env

Module host_env 

Source
Expand description

Host-environment plumbing: ID generation and time.

The framework relies on two ambient capabilities — fresh IDs and the current time — at many call sites (session_id, run_id, event timestamps, retry backoff). Defaulting both to uuid::Uuid::new_v4() / SystemTime::now() is fine for production but blocks two cluster-grade features:

  • Deterministic replay of a run on another node for failure investigation. With injectable IdGenerator / Clock impls a host can record the seed and replay it bit-identical elsewhere.
  • Time-bending tests without monkey-patching std::time.

Hosts plug a custom impl via SessionOptions::with_host_env; the framework uses [SystemHostEnv] (the wall-clock + random-UUID default) when none is supplied — observably identical to pre-P2 behaviour.

Structs§

FixedClock
Clock that returns a configured, atomically-updatable timestamp. Useful for replay (advance to recorded value) and for tests that need stable timestamps.
HostEnv
Bundle of host-environment capabilities. Used as the single Option<Arc<HostEnv>> slot on AgentConfig and SessionOptions — avoids growing two parallel Arc<dyn …> fields.
SequentialIdGenerator
Deterministic ID generator that yields a configured prefix followed by a monotonic counter (<prefix>-0, <prefix>-1, …).
SystemClock
Wall-clock time source — the framework default.
SystemIdGenerator
UUID-v4 based ID generator — the framework default.

Traits§

Clock
Source of the current time in Unix-epoch milliseconds.
IdGenerator
Generator for unique identifiers used by the framework (session_id, run_id, subagent task_id, …).