---
title: "Agent & Workflow Framework"
description: "Core agent architecture and workflow patterns for multi-agent systems"
---

```mermaid
graph LR
    Agent["Agent"]
    AugmentedLLM["AugmentedLLM"]
    Orchestrator["Orchestrator"]
    ParallelLLM["ParallelLLM"]
    Swarm["Swarm"]
    Router["Router"]
    IntentClassifier["IntentClassifier"]
    Executor["Executor"]
    MCPConnectionManager["MCPConnectionManager"]
    ContextDependent["ContextDependent"]

    Agent -- "Uses" --> AugmentedLLM
    Agent -- "Delegates to" --> Executor
    AugmentedLLM -- "Used by" --> Agent
    AugmentedLLM -- "Used by" --> Orchestrator
    AugmentedLLM -- "Used by" --> ParallelLLM
    AugmentedLLM -- "Used by" --> Swarm
    AugmentedLLM -- "Used by" --> Router
    AugmentedLLM -- "Used by" --> IntentClassifier
    Orchestrator -- "Coordinates" --> Agent
    Orchestrator -- "Uses" --> AugmentedLLM
    ParallelLLM -- "Coordinates" --> Agent
    ParallelLLM -- "Uses" --> AugmentedLLM
    Swarm -- "Coordinates" --> Agent
    Swarm -- "Uses" --> AugmentedLLM
    Router -- "Directs tasks to" --> Agent
    Router -- "Relies on" --> IntentClassifier
    IntentClassifier -- "Used by" --> Router
    IntentClassifier -- "Uses" --> AugmentedLLM
    Executor -- "Executes tasks for" --> Agent
    Executor -- "Manages" --> Orchestrator
    Executor -- "Manages" --> ParallelLLM
    Executor -- "Manages" --> Swarm
    MCPConnectionManager -- "Facilitates communication for" --> Agent
    MCPConnectionManager -- "Integrates with" --> Orchestrator
    MCPConnectionManager -- "Integrates with" --> Router
    ContextDependent -- "Provides context to" --> Agent
    ContextDependent -- "Provides context to" --> Orchestrator
    ContextDependent -- "Provides context to" --> ParallelLLM
    ContextDependent -- "Provides context to" --> Swarm
    ContextDependent -- "Provides context to" --> Router
    ContextDependent -- "Provides context to" --> IntentClassifier
    ContextDependent -- "Provides context to" --> Executor
    ContextDependent -- "Provides context to" --> AugmentedLLM
    ContextDependent -- "Provides context to" --> MCPConnectionManager
```

<Info>
This documentation was generated by [CodeBoarding](https://github.com/CodeBoarding/GeneratedOnBoardings) to provide comprehensive insights into the agent and workflow framework.
</Info>

## Overview

The "Agent & Workflow Framework" component is the backbone of the project, defining how AI agents are structured, how they interact, and how complex multi-agent behaviors are orchestrated. It provides the foundational abstractions and patterns necessary for building sophisticated AI systems.

## Core Components

### Agent

The fundamental building block of the AI system. It encapsulates an agent's core logic, capabilities, and interaction patterns, serving as the primary autonomous entity capable of performing tasks.

**Implementation Details:**
- [View Source](https://github.com/lastmile-ai/mcp-agent/blob/main/src/mcp_agent/agents/agent.py)

**Key Features:**
- Autonomous task execution
- Core agent logic encapsulation
- Interaction pattern management
- Capability abstraction

### AugmentedLLM

Provides a standardized and enhanced interface for interacting with various Large Language Models (LLMs) from different providers. It abstracts away provider-specific details and adds functionalities like prompt augmentation, token management, and structured output, making it the central LLM integration point for all agents and workflows.

**Implementation Details:**
- [View Source](https://github.com/lastmile-ai/mcp-agent/blob/main/src/mcp_agent/workflows/llm/augmented_llm.py)

**Key Features:**
- Multi-provider LLM abstraction
- Prompt augmentation
- Token management
- Structured output handling
- Provider-agnostic interface

### Orchestrator

A high-level workflow component responsible for coordinating multiple agents, tools, or sub-workflows to achieve complex, multi-step goals. It defines the overall flow and decision-making logic for sequential or conditional processes.

**Implementation Details:**
- [View Source](https://github.com/lastmile-ai/mcp-agent/blob/main/src/mcp_agent/workflows/orchestrator/orchestrator.py)

**Key Features:**
- Multi-agent coordination
- Sequential workflow management
- Decision-making logic
- Complex goal decomposition

### ParallelLLM

Implements a workflow pattern designed for executing multiple LLM calls or agent tasks concurrently. It efficiently manages parallel interactions, distributing tasks (fan-out) and collecting results (fan-in) for improved throughput in multi-task scenarios.

**Implementation Details:**
- [View Source](https://github.com/lastmile-ai/mcp-agent/blob/main/src/mcp_agent/workflows/parallel/parallel_llm.py)

**Key Features:**
- Concurrent task execution
- Fan-out/fan-in patterns
- Improved throughput
- Parallel LLM interactions

### Swarm

Implements a multi-agent workflow pattern where a group of agents collaborates to solve a problem, often exhibiting emergent intelligence through collective action and iterative refinement. It facilitates communication and coordination among a group of agents.

**Implementation Details:**
- [View Source](https://github.com/lastmile-ai/mcp-agent/blob/main/src/mcp_agent/workflows/swarm/swarm.py)

**Key Features:**
- Multi-agent collaboration
- Emergent intelligence
- Collective problem-solving
- Iterative refinement

### Router

A workflow component that intelligently directs incoming requests or tasks to the most appropriate agent, server, or sub-workflow. It makes dynamic routing decisions based on predefined rules or analysis of the request content.

**Implementation Details:**
- [View Source](https://github.com/lastmile-ai/mcp-agent/blob/main/src/mcp_agent/workflows/router/router_base.py)

**Key Features:**
- Intelligent request routing
- Dynamic decision making
- Rule-based routing
- Content analysis

### IntentClassifier

A workflow component designed to classify user input or system states into predefined intents. This is crucial for understanding the user's goal and enabling other workflow components (like the Router) to make informed decisions about subsequent actions.

**Implementation Details:**
- [View Source](https://github.com/lastmile-ai/mcp-agent/blob/main/src/mcp_agent/workflows/intent_classifier/intent_classifier_base.py)

**Key Features:**
- Intent classification
- User goal understanding
- Predefined intent mapping
- Decision support

### Executor

Manages and executes workflows and tasks, providing mechanisms for reliable execution, potentially integrating with durable execution systems. It ensures that complex, long-running agent processes can be reliably executed, paused, resumed, and monitored.

**Implementation Details:**
- [View Source](https://github.com/lastmile-ai/mcp-agent/blob/main/src/mcp_agent/executor/executor.py)

**Key Features:**
- Workflow execution management
- Reliable task execution
- Durable execution support
- Process monitoring

### MCPConnectionManager

Manages connections and interactions related to the Model Context Protocol (MCP). This component is crucial for enabling communication and data exchange between different parts of the agent system or with external MCP-compliant services, facilitating multi-agent collaboration.

**Implementation Details:**
- [View Source](https://github.com/lastmile-ai/mcp-agent/blob/main/src/mcp_agent/mcp/mcp_connection_manager.py)

**Key Features:**
- MCP connection management
- Inter-agent communication
- Data exchange facilitation
- External service integration

### ContextDependent

A foundational abstract base class or pattern that provides a mechanism for components to depend on and interact with a shared `Context` object. It ensures that various parts of the agent system can access common resources, configurations, and state, promoting a consistent and manageable environment.

**Implementation Details:**
- [View Source](https://github.com/lastmile-ai/mcp-agent/blob/main/src/mcp_agent/core/context.py)

**Key Features:**
- Shared context management
- Resource access control
- Configuration consistency
- State management
