agent-context 0.1.0

Multi-backend agent context manager with three-zone memory model
Documentation

agent-context

Multi-backend LLM conversation context manager built on the kameo actor model.

Three-Zone + Scratch Memory

Messages are split into three storage zones plus a transient scratch layer:

Zone Mutability Purpose
immutable Read-only System prompts, preset context
compressed Write-once (during compression) Summaries of older messages
incremental Full CRUD Active conversation
scratch Not stored Per-turn metadata (time, cwd, etc.)

Concatenation order: immutable → compressed → incremental → scratch.

Usage

use agent_context::{AgentContext, AppendMsg, SendMsg, ContextBackend};

// 1. Implement ContextBackend for your LLM backend
// 2. Spawn the actor
let actor = AgentContext::spawn(AgentContext::new(backend, vec![system_prompt]));

// 3. Append user message and send to LLM
actor.ask(AppendMsg { message: user_msg }).await?;
actor.ask(SendMsg { opts: my_opts }).await?;

// 4. Read all messages
let messages = actor.ask(MessagesMsg).await?;

ContextBackend

The core trait — implement it to support any LLM provider. Provides message factories, format conversion, response parsing, and streaming.

Compression

Use CompressMsg with CompressStrategy::Summarize to compress older messages into a summary when the conversation gets too long.

License

MIT OR Apache-2.0