5 releases (breaking)
Uses new Rust 2024
| new 0.4.0 | Mar 3, 2026 |
|---|---|
| 0.3.0 | Feb 24, 2026 |
| 0.2.0 | Feb 22, 2026 |
| 0.1.0 | Feb 22, 2026 |
| 0.0.1 | Feb 22, 2026 |
#2185 in Asynchronous
145KB
2K
SLoC
neuron
Composable async agentic AI framework for Rust
Overview
neuron is the umbrella re-export crate for the neuron workspace. It provides a single
dependency entry point for the most common combination of crates, controlled by feature flags.
The framework is built on a 6-layer protocol model where each layer is a Rust trait:
layer0: Operator | StateStore | Environment | Orchestrator | Hook | Observable
↓ ↓ ↓ ↓ ↓ ↓
operators state credentials workflows middleware events
Every layer is independently replaceable. You can use the Anthropic provider with the OpenAI operator interface, swap in-memory state for filesystem state, plug in Vault secrets without changing your operator code, and so on.
Quick start
[dependencies]
neuron = { version = "0.4", features = ["op-react", "provider-anthropic", "state-memory", "env-local"] }
tokio = { version = "1", features = ["full"] }
use neuron::prelude::*;
use std::sync::Arc;
#[tokio::main]
async fn main() -> anyhow::Result<()> {
let provider = AnthropicProvider::from_env()?;
let operator = ReactOperator::new(
Arc::new(provider),
Arc::new(ToolRegistry::new()),
Arc::new(HookRegistry::new()),
);
let env = LocalEnv::new(Arc::new(EnvResolver));
let input = OperatorInput::new("What is 2 + 2?");
let output = operator.invoke(input, &env).await?;
println!("{}", output.content.as_text().unwrap_or_default());
Ok(())
}
Feature flags
| Flag | Includes | Description |
|---|---|---|
core (default) |
layer0, neuron-context, neuron-tool, neuron-turn |
Protocol + wiring |
hooks (default) |
core + neuron-hooks |
Hook middleware |
op-react |
hooks + neuron-op-react |
ReAct loop operator |
op-single-shot |
hooks + neuron-op-single-shot |
Single-turn operator |
mcp |
core + neuron-mcp |
MCP bridge |
orch-kit |
core + neuron-orch-kit |
Orchestration wiring |
orch-local |
orch-kit + neuron-orch-local |
In-process orchestrator |
env-local |
core + neuron-env-local |
Local environment |
state-memory |
core + neuron-state-memory |
In-memory state store |
state-fs |
core + neuron-state-fs |
Filesystem state store |
provider-anthropic |
core + neuron-provider-anthropic |
Anthropic Claude |
provider-openai |
core + neuron-provider-openai |
OpenAI GPT |
provider-ollama |
core + neuron-provider-ollama |
Ollama local models |
providers-all |
all three providers | All built-in providers |
Workspace crates
The workspace is split into focused crates you can depend on individually:
Core protocol
layer0— foundational protocol traits (no implementations)neuron-turn— Provider trait + LLM typesneuron-tool— Tool + ToolRegistryneuron-context— context window strategies
Operators
neuron-op-react— ReAct reasoning loopneuron-op-single-shot— single model call
Providers
neuron-provider-anthropic— Claudeneuron-provider-openai— GPTneuron-provider-ollama— Ollama
Orchestration
neuron-orch-kit— wiring kitneuron-orch-local— in-process orchestrator
Hooks & security
neuron-hooks— hook registry and middlewareneuron-hook-security— redaction + DLP hooks
State
neuron-state-memory— in-memory storeneuron-state-fs— filesystem store
Environment & credentials
neuron-env-local— local environmentneuron-secret— secret resolution traitsneuron-auth— authentication traitsneuron-crypto— cryptographic traits
MCP
neuron-mcp— Model Context Protocol bridge
License
neuron is dual-licensed under MIT and Apache 2.0.
Documentation
Dependencies
~0–15MB
~129K SLoC