zeph-agent-context 0.22.3

Agent context-assembly service for Zeph: system prompt rebuild, memory injection, summarization, compaction.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
# zeph-agent-context Guide

Context-assembly service (`ContextService`): system prompt rebuild, memory injection, semantic recall, summarization, and compaction. A stateless façade extracted from `Agent<C>` so context-assembly edits do not recompile the tool dispatcher or persistence layer.

- Start with crate-local checks: `cargo build -p zeph-agent-context`, `cargo nextest run -p zeph-agent-context`, `cargo clippy -p zeph-agent-context --all-targets -- -D warnings`.
- Read `specs/021-zeph-context/spec.md` before changing assembly, budget, or compaction behavior; honor its `## Key Invariants` and `NEVER` sections.
- Read `specs/004-memory/004-16-memory-type-aware-retrieval.md` (MemGuard type-aware retrieval composition, #6226/#6086) before changing `type_aware_compose.rs` or the active-`FunctionalType`-set resolution it feeds into `zeph_context::assembler::schedule_context_fetchers`. NEVER gate `fetch_corrections`/`BehavioralRule` behind the active set — past-correction recall is always composed, unconditionally, regardless of config. NEVER let an unrecognised `default_compose_types` string silently widen to "all types" — it must be a hard config-load error. Note: in-code comments previously mis-cited this as "spec 064" (a naming collision with `/specs/064-durable-execution/`); citations were corrected to "spec 004-16" in #6308.
- Core invariant: this crate MUST NOT depend on `zeph-core`. The decoupling is the whole point — never add a `zeph-core` dependency to satisfy a borrow.
- Keep the borrow-lens views (`MessageWindowView`, `ContextAssemblyView`, `ContextSummarizationView`) narrow; `zeph-core` constructs them from `Agent` field projections.
- Features: `sqlite` (default) / `postgres` forwarded to `zeph-memory`, plus `index` for `IndexAccess` integration. Run `cargo nextest run -p zeph-agent-context --features index` when touching index-backed assembly views.
- LLM serialization gate: summarization and compaction build LLM request payloads — changes to `summarization/` or `compaction.rs` require a live API session test (no 400/422, well-formed `messages` array in the debug dump) before merge.
- Multi-model: summarization and compaction call an LLM — resolve the provider via a `*_provider` field referencing a named `[[llm.providers]]` entry; never hardcode a model.