Expand description
Semantic loop detection & circuit breaking (brief Module A).
Recursive agents stuck in loops rarely repeat verbatim — they paraphrase.
Off the hot path, a worker embeds each reasoning step and computes the
semantic delta Δ = 1 − cosine(eᵢ, eᵢ₊₁) — tightened, when vector history
is available, to min(Δ, 1 − nearest-prior-step similarity) so loops
that alternate between two paraphrases still trip. The breaker trips when Δ ≈ 0
(below delta_epsilon) for window consecutive steps while the session
consumed ≥ min_tokens — exactly the brief’s rule (Δ≈0 across 3 steps
while consuming N+ tokens).
The default HashEmbedder is a deterministic char-n-gram
feature-hashing embedder: zero model downloads, air-gap-safe, catches
verbatim and paraphrase-dense loops (SLA-tested). MiniLM-class ONNX models
plug in behind the onnx feature via the same Embedder trait
(tract-onnx, pure Rust — no PyTorch/Python runtime, per the brief).
Re-exports§
pub use breaker::BreakerAction;pub use breaker::BreakerConfig;pub use breaker::BreakerState;pub use breaker::BreakerVerdict;pub use breaker::SessionLoopState;pub use embed::cosine;pub use embed::Embedder;pub use embed::HashEmbedder;pub use vector_sink::NoopVectorSink;pub use vector_sink::VectorSearchFuture;pub use vector_sink::VectorSink;pub use vector_sink::VectorSinkFuture;pub use vector_sink::QdrantVectorSink;pub use onnx_embed::OnnxEmbedder;
Modules§
- breaker
- The circuit breaker: per-session Δ window + token gate + verdicts.
- embed
- Embedding abstraction + the deterministic feature-hashing default.
- onnx_
embed - ONNX embedder via tract (pure Rust, no PyTorch/Python runtime — brief §8).
- vector_
sink - Off-path vector persistence for semantic-loop observability.