rig-cat
An LLM agent framework built on comp-cat-rs. No async, no tokio. All effects are Io<Error, A>, all concurrency is Fiber, all streaming is Stream.
Installation
[]
= "0.1"
Quick start
use ;
use AgentBuilder;
let model = new;
let agent = new
.preamble
.temperature
.build;
// Nothing runs until .run()
let response = agent.prompt.run;
Architecture
model/ CompletionModel trait, Message, Request/Response types
embedding/ EmbeddingModel trait, Embedding type, cosine similarity
tool/ Tool trait, generic Toolbox<T>
vector_store/ VectorStoreIndex trait, InMemoryVectorStore
agent/ Agent<M, T> with builder pattern
pipeline/ RAG pipeline via Io::flat_map chains
provider/ OpenAI, Anthropic implementations
error/ Hand-rolled Error enum
Every function that touches the network returns Io<Error, A>. Composition happens via map, flat_map, zip. Side effects only happen when you call .run().
Providers
OpenAI
use ;
let completion = new;
let embedding = new;
Anthropic
use ;
let model = new;
Tools
Tools are generic over a concrete type. For heterogeneous tools, define an enum:
use ;
use Io;
use Value;
;
let toolbox = new.with_tool;
let result = toolbox.invoke.run;
RAG pipeline
The pipeline::rag function composes embedding, search, and generation into a single Io chain:
use Rc;
use rag;
let response = rag.run;
Concurrency
Use comp-cat-rs Fiber for parallel LLM calls:
use par_zip;
let task_a = agent.prompt;
let task_b = agent.prompt;
// Both run on separate threads
let = par_zip.run?;
Why no async?
LLM API calls are high-latency (1-30 seconds) and low-concurrency (a handful of calls, not thousands). Thread-per-request via Fiber is perfectly adequate. The benefit: no tokio, no Pin<Box<dyn Future>>, no colored functions. Everything composes with flat_map.
The categorical foundation
This crate is the practical application of the thesis proved in comp-cat-theory (Lean 4):
Iois a monad, which is a pair of Kan extensionsStreamis a colimit, which is a left Kan extensionFiber::forkis a coproduct,Fiber::joinis a limit- The RAG pipeline is a composition of monadic effects
The proofs are in Lean 4 with zero sorrys. The Rust code is the runtime implementation.
Status
Alpha. The core architecture is stable, but:
- Streaming responses are not yet implemented (providers return
Stream::empty()) - Tool-calling loop (agent calls tool, feeds result back, repeats) is not yet implemented
- Only two providers (OpenAI, Anthropic); more planned
- Only in-memory vector store; external stores planned
License
MIT