-
Notifications
You must be signed in to change notification settings - Fork 0
Quick Start
The shortest path from zero to a running TinyAgents graph, plus the crate layout you will navigate as you go deeper. TinyAgents is a recursive language-model (RLM) harness for Rust — see Recursion and RLM for what that means once you are up and running.
Add the crate to your project. The default build is offline (no hosted providers, no network):
[dependencies]
tinyagents = "0.1"Hosted model providers live behind the openai Cargo feature. Enable it to use
OpenAI and OpenAI-compatible endpoints:
[dependencies]
tinyagents = { version = "0.1", features = ["openai"] }Then export your key (and optionally point at a different model or base URL):
export OPENAI_API_KEY=...
export OPENAI_MODEL=gpt-4.1-mini # optional
export OPENAI_BASE_URL=https://api.openai.com/v1 # optionalThe same feature powers other providers (Anthropic, Ollama, DeepSeek, Groq, xAI, OpenRouter, Together, Mistral, and compatible endpoints) through provider specs and helper constructors. See Providers.
- crates.io: https://crates.io/crates/tinyagents
- docs.rs: https://docs.rs/tinyagents
To work against the source or run the bundled examples, clone the canonical repository:
git clone https://github.com/tinyhumansai/tinyagents.git
cd tinyagents
cargo testUseful local checks (these mirror CI):
cargo fmt --check
cargo clippy --all-targets -- -D warnings
cargo build --all-targets
cargo testThe basic graph example needs no provider credentials and runs fully offline:
cargo run --example basic_graphIt threads typed Rust state through a small two-node graph, routes conditionally
after the agent node, and exits when the state no longer needs the tool:
flowchart TD
Start((START)) --> Agent[agent]
Agent -->|needs_tool| Tool[tool]
Tool --> Agent
Agent -->|done| End((END))
OpenAI-backed examples need the openai feature and OPENAI_API_KEY:
export OPENAI_API_KEY=...
cargo run --features openai --example openai_chatOther offline examples include complex_graph, durable_graph, and
agent_loop_tools; other hosted examples include openai_tools,
openai_structured, openai_graph_agent, orchestrator_subagents,
openai_self_blueprint, and rag_blueprint. See Examples.
TinyAgents is organized around five surfaces. Knowing where each lives makes the source easy to navigate:
-
src/harness/— Harness: provider-neutral model calls, typed tools, middleware, structured output, streaming, usage/cost, retry/limits, cache, memory/embeddings, sub-agents, steering, summarization, and testkit doubles. -
src/graph/— Graph runtime: durable typed state graphs withSTART/END, nodes, edges, conditional routing, commands,Sendfanout, reducers/channels, checkpoints, interrupts, subgraphs, and topology export. -
src/registry/— Registry: the named capability catalog (models, tools, agents, graphs, stores, middleware, policy) that.rag/.ragshbind by name. -
src/language/— Expressive language.rag: declarative, side-effect-free blueprints that compile (lexer → parser → compiler) into the same runtime. -
src/repl/— REPL language.ragsh: imperative, capability-bound interactive orchestration — the RLM/CodeAct loop surface.
Supporting paths:
-
examples/— runnable examples (offline and OpenAI-backed). -
docs/spec/— contributor-facing system specification. -
wiki/— this GitHub wiki source.
- Recursion and RLM — the execution model that makes TinyAgents an RLM harness, with the concrete recursive surfaces and research lineage.
-
Examples — work through the runnable examples, including the
self-authoring
.ragblueprint demos. - Architecture — how the five surfaces compose end to end.
Recursive language-model (RLM) harness for Rust.
Getting started
Concepts
Modules
Providers
Contributing