Skip to main content

Crate cel_brief

Crate cel_brief 

Source
Expand description

cel-brief — Per-turn LLM briefing layer.

cel-brief answers one question: what should the model see this turn? It sits between an agent’s state and the LLM — every turn, sources contribute source::Contributions that the builder budgets, prunes, governs, and assembles into a provider-agnostic types::Brief plus a receipt::BriefReceipt of what was included, dropped, and redacted.

It is deliberately scoped. cel-brief does not discover live state itself — a PerceptionSource consumes a snapshot that some backend produced — and it does not store memory; a MemorySource reads from a cel_memory::MemoryProvider. cel-brief owns per-turn briefing assembly only.

Status (Phases 1 + 2 + 3 + 4): all core types, traits, sources, governance, and builder are shipped.

Phase 1 — core types (types::Brief, types::BriefMessage, types::Role, types::BriefContext, types::TokenBudget, types::Priority, types::ToolSchema, types::ImageData, types::SourceId) and the source::Source trait + supporting types (source::Contribution, source::ContributionContent, source::SourceError).

Phase 2builder::BriefBuilder, tokenizer::Tokenizer (default tokenizer::CharApproxTokenizer; opt-in TiktokenCl100k behind the tiktoken feature), budget::PruneStrategy + budget enforcement, full receipt::BriefReceipt.

Phase 3 — built-in sources::SystemPromptSource, sources::UserMessageSource, sources::ToolCatalogSource, sources::HistorySource + sources::HistoryStore under default features; MemorySource behind the memory feature; PerceptionSource + PerceptionSnapshot behind the perception feature.

Phase 4governance::Governance trait with governance::NoOpGovernance default, governance::GovernanceVerdict enum, and the receipt::RedactionRecord surface that governance::GovernanceVerdict::Redacted returns.

§Quick start

let builder = BriefBuilder::new()
    .budget(TokenBudget::new(8000, 1024));
    // .source(Arc::new(MySource)) ...

let ctx = BriefContext::new(TokenBudget::default())
    .with_user_message("hi");
let brief = builder.build(&ctx).await?;
println!("brief: {} messages, {} tokens",
    brief.messages.len(), brief.receipt.total_tokens);

Re-exports§

pub use budget::PruneStrategy;
pub use budget::WeightedContribution;
pub use builder::BriefBuilder;
pub use error::BriefError;
pub use error::Result;
pub use governance::Governance;
pub use governance::GovernanceError;
pub use governance::GovernanceVerdict;
pub use governance::NoOpGovernance;
pub use receipt::BriefReceipt;
pub use receipt::DropReason;
pub use receipt::DroppedContribution;
pub use receipt::RedactionRecord;
pub use receipt::SourceStats;
pub use receipt::Timings;
pub use source::Contribution;
pub use source::ContributionContent;
pub use source::Source;
pub use source::SourceError;
pub use sources::HistoryEntry;
pub use sources::HistorySource;
pub use sources::HistoryStore;
pub use sources::ReceiptSource;
pub use sources::SystemPromptSource;
pub use sources::ToolCatalogSource;
pub use sources::UserMessageSource;
pub use tokenizer::CharApproxTokenizer;
pub use tokenizer::Tokenizer;
pub use types::Brief;
pub use types::BriefContext;
pub use types::BriefMessage;
pub use types::ImageData;
pub use types::Priority;
pub use types::Role;
pub use types::SourceId;
pub use types::TokenBudget;
pub use types::ToolSchema;

Modules§

budget
PruneStrategy + apply_budget.
builder
BriefBuilder — orchestrates fan-out, tokenization, budget pruning, governance, and receipt assembly.
error
Error type for cel-brief.
governance
Governance trait + GovernanceVerdict + NoOpGovernance default.
receipt
BriefReceipt — auditable record of how a crate::types::Brief was assembled.
source
Source trait + Contribution + ContributionContent + SourceError.
sources
Built-in crate::source::Source implementations.
tokenizer
Tokenizer trait + default impls.
types
Core types: Brief, BriefMessage, Role, BriefContext, TokenBudget, Priority, ToolSchema, ImageData, SourceId.