docs.rs failed to build lingshu-core-0.10.0
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.
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.
lingshu-core
Why this crate? Reasoning + tools alone don't make an agent. You need a loop that knows
when to call a tool, when to stop, how to compress a 200-message history without losing
context, and which of 16 LLM providers to route to.lingshu-coreis that loop — the
orchestration brain that turns raw LLM calls and tool results into coherent, goal-directed
behaviour.
Part of Lingshu — the Rust SuperAgent.
What's inside
| Module | Responsibility |
|---|---|
agent.rs |
AgentBuilder + Agent — hot-swap model, streaming, session binding |
conversation.rs |
execute_loop() — the ReAct tool-call loop (max 90 iterations) |
prompt_builder.rs |
System prompt assembly from ~12 sources (identity, memory, skills, AGENTS.md …) |
compression.rs |
Context compression: structural fallback + LLM-based summarisation |
model_catalog.rs |
16 providers × 200+ models — single source of truth, user-overridable YAML |
model_router.rs |
Provider factory + smart routing |
pricing.rs |
Token cost calculation per provider |
sub_agent_runner.rs |
Sub-agent delegation runner |
Add to your crate
[]
= { = "../lingshu-core" }
Simple usage
use ;
use ToolRegistry;
let registry = default; // all built-in tools
let agent: Agent = new
.tools
.build?;
// One-shot chat
let reply: String = agent.chat.await?;
println!;
Streaming usage
use StreamEvent;
use mpsc;
let = ;
agent.chat_streaming.await?;
while let Some = rx.recv.await
ReAct loop in brief
while turns < max_iterations && budget.ok() {
if context > threshold → compress_with_llm()
response = provider.chat(model, messages, tools)
if response.has_tool_calls() → dispatch tools → push results
else → return final text
}
Prompt caching note
The system prompt is assembled once per session and cached.
Do not rebuild or mutate it mid-conversation — this invalidates Anthropic's prompt cache and multiplies costs. The only sanctioned mid-session mutation is /compress.
Model catalog
# ~/.lingshu/models.yaml (user overrides — merged on top of defaults)
providers:
- name: anthropic
models:
- id: claude-opus-4.6
context_window: 200000
cost_per_1m_input: 15.00
cost_per_1m_output: 75.00
Full docs, guides, and release notes → lingshu.com