Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
foundation_ai
A unified AI inference framework for the ewe-platform. Talk to Anthropic Claude,
OpenAI GPT, any OpenAI-compatible API (Ollama, OpenRouter, vLLM, llama.cpp
server), and run local models via llama.cpp or Candle — on CPU or GPU —
all through the same Model trait and the higher-level agentic session
system.
No tokio. No async-trait in the hot path. Built on Valtron's StreamIterator
pattern for sync APIs with threaded execution.
Getting Started
New here? These guides take you from zero to a working agent, each showing the harness shortcut and the manual setup:
| Guide | What it covers |
|---|---|
| 01. Providers | Setup for llama.cpp, OpenAI, Anthropic, OpenRouter — persistence levels, harness and manual paths |
| 02. Agent Harness | The agent lifecycle: sessions, turns, steering, memory, resume |
| 03. Tools & Presets | The read/write/edit/bash tools, ToolPreset helpers, and sub-agent delegation |
Deep Dives
Reference and how-to docs for everything the getting-started guides skim:
| Doc | Topic |
|---|---|
| 00. Overview | Module map and architecture |
| 01. The Agentic Loop | How a turn runs end to end |
| 02. Agent Types | Messages, ModelOutput, the Stream contract |
| 03. Model Providers | Provider implementations and the router |
| 04. Tools | ToolImpl, ToolShed, ToolPreset, the execution DAG |
| 05. Steering Queues | Mid-turn injection and cancellation |
| 06. Serialization | JSON and Arrow columns |
| 07. Embeddings | Embedding provider and vector integration |
| 08. AgentSession API | Using the session handle |
| 09. Customizing the Loop | Tuning loop behaviour |
| 10. Building Custom Tools | Writing your own ToolImpl |
| 11. Memory System | The memory hierarchy and memory tool |
| 12. Harness Presets | One-call model + router setup |
| 14. GPU Acceleration | CUDA, Metal, Vulkan — both backends |
Root-caused bug write-ups live in docs/fixes/.
Install
[]
= { = "0.0.1", = ["agentic"] }
= "0.0.1"
= "0.0.1"
= "1"
Feature flags
| Flag | What it does |
|---|---|
agentic |
Agent loop, sessions, tools, memory |
llamacpp |
llama.cpp GGUF inference (on by default) |
candle |
Candle pure-Rust inference (on by default) |
candle-cuda |
Candle on NVIDIA CUDA |
cuda / cuda_static |
llama.cpp on NVIDIA CUDA |
metal |
llama.cpp on Apple Silicon (Candle Metal is automatic on Apple) |
vulkan |
llama.cpp on cross-platform GPU |
multi |
Multi-threaded executor for concurrent generation |
mtmd |
Multi-modal (vision) models |
testing |
MockModelProvider / MockTool for unit tests |
GPU builds need a couple of environment variables — see the GPU Acceleration guide.
Quick Start
The shortest path to a working agent — a Claude session in a few lines:
use harness;
use KvMemoryStore;
use ;
use new_scru128;
use valtron;
use ;
type Doc = MemoryDocumentStore;
type Mem = ;
Prefer the raw Model trait, a different provider, or a manual ProviderRouter?
That's all in Getting Started: Providers.
Runnable examples
# Harness shortcuts — one-call setup:
# Manual (no helpers) — full ProviderRouter setup:
# Tools and delegation:
What you get
- Every provider through one
Modeltrait — Anthropic Messages, OpenAI Chat Completions, OpenAI Responses (o1/o3 reasoning), and any OpenAI-compatible endpoint (Ollama, OpenRouter, vLLM, LM Studio, llama.cpp server) via onebase_url. - Local inference — llama.cpp (GGUF) and Candle (safetensors), on CPU or GPU (CUDA, Metal, Vulkan). See GPU Acceleration.
- The agentic layer —
AgentSessionorchestrates generation, a memory hierarchy (working / observation / reflection), tool execution, token budgets, loop detection, and mid-turn steering. - Tools — built-in
read/write/edit(over a swappable VFS) andbash, bundled byToolPreset, plus background sub-agent delegation. Provider-specific tool formatters for Anthropic, OpenAI Completions, and OpenAI Responses, with an XML fallback for local models. - Streaming — Server-Sent Events through
StreamIterator, with automatic reconnection on 429/5xx. - Cost tracking — per-interaction costing and running totals via
CostAccumulator. - HuggingFace integration — automatic GGUF/safetensors download with
quantization parsing from IDs like
TheBloke/Llama-2-7B-GGUF:q4_k_m.
Testing & coverage
Tests live in tests/. Run them with the uat profile (the dev profile's
Cranelift backend can't do catch_unwind or coverage instrumentation):
# Offline suite — no network, no model downloads.
# Full suite, including gated live-model and external-service tests.
# GPU paths (self-skip without a device):
Coverage is measured with cargo llvm-cov under the same uat profile. Gated
tests (live vendor APIs, downloaded models, GPU) self-skip when their
prerequisites are absent, so the offline suite always runs clean.
Latest measured: ~86% lines / ~87% regions, ~1,760 tests, across the
offline, live-model, and external-service features (via
cargo llvm-cov --profile uat -p foundation_ai --features "testing live-model-tests external-service-tests"). Every source file is above the
reviewed bar; no file sits at 0%. GPU paths are additionally covered by the
gated candle-cuda / cuda suites.
Design notes
- Sync API, threaded execution. No tokio, no async-trait on the hot path;
the streaming APIs are
StreamIterators driven on the Valtron pool. - Provider parity. Tool calling, streaming, and cost tracking behave the same across providers; differences are confined to per-provider formatters.
- VFS-backed tools. File tools go through
AsyncVfsFileSystem, so the same agent runs against real disk, an in-memory FS (tests), or a remote FS — and on wasm.
See docs/00-overview.md for the full architecture.