Skip to main content

Crate modular_agent_core

Crate modular_agent_core 

Source
Expand description

§Modular Agent Core

A Rust framework for building modular multi-agent orchestration systems.

This crate provides tools and abstractions to create, configure, and run agents in a stream-based architecture. It supports defining agent behaviors, managing agent flows, and handling agent input/output through a channel-based messaging system.

§Core Concepts

§ModularAgent

ModularAgent is the central orchestrator that manages agent lifecycle, connections, and message routing. It maintains agent instances, connection maps, and handles events.

§Agents

Agents are processing units that receive messages via channels and process them asynchronously. Implement the AsAgent trait to create custom agents, or use the #[modular_agent] macro for declarative agent definitions.

§Presets

Presets are collections of agents and their connections, defined in JSON format. They can be loaded from files and managed via ModularAgent methods.

§Quick Start

See the CLI example for a complete working example of loading a preset and running agents from the command line.

§Feature Flags

  • file - File handling support (enabled by default)
  • image - Image processing with photon-rs (enabled by default)
  • llm - LLM integration with Message/ToolCall types (enabled by default)
  • mcp - Model Context Protocol integration (enabled by default)
  • test-utils - Testing utilities including TestProbeAgent

Re-exports§

pub extern crate self as modular_agent_core;
pub use llm::Message;
pub use llm::ToolCall;
pub use llm::ToolCallFunction;
pub use photon_rs;
pub use im;
pub use inventory;
pub use fnv;
pub use indexmap;

Modules§

llm
LLM message types for agent-based workflows.
mcp
Model Context Protocol (MCP) integration for external tool servers.
tool
Tool registry and agents for LLM function calling.

Structs§

AgentConfigSpec
Specification for a configuration entry.
AgentConfigs
Configuration container for an agent.
AgentContext
Event-scoped context that identifies a single flow across agents and carries auxiliary metadata.
AgentData
Core data structure for an agent.
AgentDefinition
The definition (blueprint) of an agent type.
AgentRegistration
Registration entry emitted by the #[modular_agent] macro.
AgentSpec
The runtime specification of an agent instance.
ConnectionSpec
A connection between two agent ports.
ModularAgent
The central orchestrator for the modular agent system.
PhotonImage
Provides the image’s height, width, and contains the image’s raw pixels. For use when communicating between JS and WASM, and also natively.
Preset
A runtime instance of a workflow preset.
PresetInfo
Summary information about a preset.
PresetSpec
The serializable specification of a preset (workflow).

Enums§

AgentError
Errors that occur during agent operations.
AgentStatus
The lifecycle status of an agent.
AgentValue
The value type passed between agents.
ModularAgentEvent
Events emitted by ModularAgent during operation.

Traits§

Agent
The core trait for all agents.
AgentOutput
Trait for sending output values and emitting events from agents.
AsAgent
Simplified trait for implementing custom agents.
HasAgentData
Trait for types that contain AgentData.

Type Aliases§

AgentConfigSpecs
A map of configuration keys to their specifications.
AgentConfigsMap
Type alias for a map of agent configurations.
AgentDefinitions
A map of agent definition names to their definitions.
AgentValueMap
Type alias for key-value maps used in AgentValue::Object.
FnvIndexMap
FnvIndexSet
PresetSpecs
A map of preset names to their specifications.

Attribute Macros§

async_trait
modular_agent
Declare agent metadata and generate agent_definition / register helpers.