Skip to main content

Module managers

Module managers 

Source
Expand description

Manager bundle — capability traits and runtime infrastructure for agent loops.

Two categories of types govern how agent loops interact with their infrastructure:

§Capability Traits

Capability traits are composable interfaces that represent distinct infrastructure concerns. Each trait describes a single ability — observing lifecycle events, detecting loops, falling back to alternate models, etc. The LoopManagers struct implements all capability traits, providing a concrete, all-in-one infrastructure bundle.

TraitPurpose
ObservableEmit lifecycle events to registered observers
DetectableDetect repetitive loops and convergence
FallbackCapableCircuit-breaker fallback to alternate models
CompactableAutomatic context compaction when tokens exceed
StreamCapableResilient streaming with retries and timeouts
HookableBidirectional hooks that can block actions
PipelineAwareDispatch tools through a middleware pipeline
HealthTrackablePer-tool health tracking with circuit breakers

§LoopManagers

LoopManagers is the framework’s default infrastructure bundle. It bundles all managers, observers, hooks, and middleware into a single struct that can be passed to any agent loop implementation:

LoopManagers
  ├── ObserverHost           → Observable
  ├── DetectionManager       → Detectable
  ├── FallbackManager        → FallbackCapable
  ├── Option<ContextManager> → Compactable
  ├── Option<StreamHandler>  → StreamCapable
  ├── Option<HookExecutor>   → Hookable
  ├── Option<ToolPipeline>   → PipelineAware
  └── Option<ToolHealthReg>  → HealthTrackable

§Design Philosophy

The trait hierarchy separates what the managers can do (capability traits) from how it’s composed (the LoopManagers struct). This allows:

  • Generic programming — agent loops can be written against impl Observable + Detectable rather than a concrete type.
  • Testing — swap LoopManagers for a stub that implements only the traits under test.
let managers = LoopManagers::new()
    .with_fallback(FallbackManager::for_model("llm-70b"))
    .with_detection(DetectionManager::default())
    .with_observer(Arc::new(logging_observer));

let agent = BareLoop::new_with_managers(client, tools, config, managers);

Every capability is optional. A bundle with no .with_*() calls still works — it just has no observers, no hooks, no pipeline, etc. This means you only pay for (and configure) the infrastructure you actually use.

Re-exports§

pub use crate::capabilities::*;

Structs§

LoopManagers
The framework’s default infrastructure bundle for agent loops.