Skip to main content

Module agent_tool

Module agent_tool 

Source
Expand description

§Agent-as-Tool

Compose agents as tools, allowing agents to invoke other agents.

Inspired by AutoGen’s agent composition pattern.

§Features

  • Agent Wrapping: Wrap any agent as a callable tool
  • Typed I/O: Strong typing for agent input/output
  • Delegation: Hierarchical agent organization
  • Context Passing: Share context between agents

§Example

use cortex::agent_tool::{AgentTool, AgentToolBuilder};

// Create a specialized agent
let math_agent = AgentTool::builder("math_expert")
    .description("Expert at solving mathematical problems")
    .handler(|input| async {
        // Process math query
        Ok(format!("Result: {}", solve_math(&input)))
    })
    .build();

// Use it as a tool in another agent
let main_agent = Agent::new()
    .add_tool(math_agent.as_tool());

Structs§

AgentTool
An agent wrapped as a tool
AgentToolBuilder
Builder for AgentTool
AgentToolConfig
Configuration for an agent tool
AgentToolInput
Input to an agent tool
AgentToolOutput
Output from an agent tool
AgentToolRegistry
A registry for agent tools
AgentToolStats
Statistics for an agent tool
DelegationChain
Helper to create a delegation chain

Enums§

AgentToolError
Error from agent tool execution
DelegationStrategy

Traits§

AgentToolHandler
Trait for agent tool handlers

Type Aliases§

BoxedHandler
Type alias for boxed handler