rig_compose/lib.rs
1//! # rig-compose
2//!
3//! Composable agent kernel for [`rig`](https://github.com/0xplaygrounds/rig)
4//! (and any rig-shaped tool surface): stateless skills, transport-agnostic
5//! tools, registry-driven agents, and a signal-routing coordinator.
6//!
7//! Extracted from a threat-detection kernel, this crate is now domain-neutral
8//! and can wrap any tool/agent stack.
9//!
10//! ## Composability rules
11//! 1. [`Skill`] is stateless. Any skill can be assigned to any [`Agent`].
12//! 2. [`Tool`] is the only side-effectful interface. Local impls and
13//! remote transports (see `rig-mcp`) share the trait; skills cannot
14//! tell them apart.
15//! 3. [`Agent`] holds a slice of the global registries — it never
16//! hard-codes skill or tool names.
17//! 4. [`Workflow`] composes agents.
18//!
19//! ## Two paths for agent-to-agent delegation
20//!
21//! rig-compose ships **two complementary delegation primitives**. Pick
22//! the one that matches who should decide *when* a peer agent is invoked.
23//!
24//! **Default — [`delegate::DelegateTool`] (model-driven, agentic).**
25//! A child agent is exposed as a normal [`Tool`]. The parent agent's
26//! model decides when to call it, just like any other tool. This is the
27//! recommended path for autonomous agent-to-agent collaboration, because
28//! the topology stays open and transport-symmetric: the same tool call
29//! works whether the peer runs in-process via
30//! [`delegate::InProcessAgentDelegate`] or behind an MCP server via
31//! `rig_mcp::McpTool`.
32//!
33//! **Optional — [`coordinator::CoordinatorAgent`] (deterministic, host-driven).**
34//! A signal-tag router that hops to the first matching specialist with
35//! no model in the loop. Reach for it only when the routing topology is
36//! fixed up-front and you specifically want a free dispatch hop —
37//! typical use is an overseer that fans one specialist out per partition
38//! before any LLM has loaded. Not a substitute for `DelegateTool` when
39//! you want the *agents* to choose how they cooperate.
40
41pub mod agent;
42pub mod budget;
43pub mod context;
44/// Deterministic, no-LLM signal-tag router. See the crate-level
45/// "Two paths for agent-to-agent delegation" section: prefer
46/// [`delegate::DelegateTool`] for model-driven peer collaboration and
47/// reach for [`coordinator::CoordinatorAgent`] only when the topology
48/// is fixed and a free dispatch hop matters.
49pub mod coordinator;
50/// Model-driven, transport-agnostic agent delegation. The default path
51/// for autonomous agent-to-agent collaboration. See the crate-level
52/// "Two paths for agent-to-agent delegation" section.
53pub mod delegate;
54pub mod instructions;
55#[cfg(feature = "manifest")]
56pub mod manifest;
57pub mod registry;
58pub mod skill;
59pub mod tool;
60pub mod workflow;
61
62pub use agent::{Agent, AgentId, AgentStepResult, GenericAgent, GenericAgentBuilder};
63pub use budget::{
64 AtomicBudget, AtomicTokenBudget, BudgetError, BudgetGuard, TokenBudget, TokenRefund,
65 TokenReservation,
66};
67pub use context::{Evidence, InvestigationContext, NextAction, Signal};
68pub use coordinator::{CoordinatorAgent, CoordinatorBuilder, RoutingRule};
69pub use delegate::{
70 DelegateExecutor, DelegateName, DelegateRegistry, DelegateTool, InProcessAgentDelegate,
71};
72pub use instructions::Instructions;
73#[cfg(feature = "manifest")]
74pub use manifest::{
75 AgentManifest, DelegateKind, DelegateSpec, InstructionsSpec, KnowledgeSpec, ManifestError,
76 McpServerSpec, ModelSpec, ToolSpec, delegate_stub, materialize_local_and_delegate_tools,
77 materialize_local_and_delegate_tools_with_delegates,
78};
79pub use registry::{KernelError, SkillRegistry, ToolRegistry};
80pub use skill::{Skill, SkillId, SkillOutcome};
81pub use tool::{LocalTool, Tool, ToolName, ToolSchema};
82pub use workflow::Workflow;