Skip to main content

zeph_agent_context/
lib.rs

1// SPDX-FileCopyrightText: 2026 Andrei G <bug-ops>
2// SPDX-License-Identifier: MIT OR Apache-2.0
3
4//! Agent context-assembly service for Zeph.
5//!
6//! This crate provides [`service::ContextService`] — a stateless façade for all
7//! context-assembly operations that were previously implemented directly on `Agent<C>`
8//! in `zeph-core`. Extracting this logic means that editing context-assembly code does
9//! not trigger recompilation of the tool dispatcher (`zeph-agent-tools`) or the
10//! persistence layer (`zeph-agent-persistence`).
11//!
12//! # Architecture
13//!
14//! `zeph-agent-context` depends on `zeph-memory`, `zeph-llm`, `zeph-context`,
15//! `zeph-config`, `zeph-common`, `zeph-skills`, and `zeph-sanitizer`. It does **not**
16//! depend on `zeph-core` — this is the core invariant that keeps context-assembly
17//! changes from triggering full workspace rebuilds.
18//!
19//! `zeph-core` depends on this crate and constructs narrow borrow-lens views
20//! ([`state::MessageWindowView`], [`state::ContextAssemblyView`],
21//! [`state::ContextSummarizationView`]) from `Agent<C>` field projections, then
22//! delegates to `ContextService`.
23//!
24//! # Features
25//!
26//! - `index` — enables `zeph-index` integration via the `IndexAccess` trait.
27
28pub mod compaction;
29pub mod error;
30pub mod helpers;
31pub mod memory_backend;
32pub mod retrieved;
33pub mod service;
34pub mod state;
35pub mod summarization;
36
37pub use compaction::{
38    BlockScore, ContentDensity, SubgoalExtractionResult, SubgoalId, SubgoalRegistry, SubgoalState,
39    classify_density, extract_scorable_text, partition_by_density, run_focus_auto_consolidation,
40    score_blocks_mig, score_blocks_subgoal, score_blocks_subgoal_mig, score_blocks_task_aware,
41};
42pub use error::ContextError;
43pub use helpers::BudgetHint;
44pub use service::{ContextService, SemanticRecallParams};
45pub use state::{
46    CompactionOutcome, CompactionPersistence, CompactionProbeCallback, ContextAssemblyView,
47    ContextDelta, ContextSummarizationView, MessageWindowView, MetricsCallback, MetricsCounters,
48    ProbeOutcome, ProviderHandles, QdrantPersistFuture, SecurityEventSink, StatusSink,
49    ToolOutputArchive, TrustGate,
50};
51
52pub use retrieved::{RetrievedContext, collect_retrieved_context};