Skip to main content

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