Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
103 changes: 62 additions & 41 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,74 +1,95 @@
# TaskMesh
================

![License](https://img.shields.io/badge/license-Apache--2.0-blue)
![Python](https://img.shields.io/badge/python-3.9+-blue)
![Status](https://img.shields.io/badge/build-experimental-orange)
[![License](https://img.shields.io/badge/license-Apache--2.0-blue)](LICENSE)
[![Python](https://img.shields.io/badge/python-3.9+-blue)](https://www.python.org/)
[![Status](https://img.shields.io/badge/build-experimental-orange)](https://github.com/joshuamlamerton/taskmesh/actions)

TaskMesh is a lightweight task routing layer for AI agents.
## Overview
-----------

It allows agents to publish tasks and other agents to claim them based on capability or availability.
TaskMesh is a lightweight, open-source task routing layer designed for AI agents. It enables agents to publish tasks and other agents to claim them based on their capabilities or availability.

## Quick Start
-------------

Clone the repository and run the demo.
Get started with TaskMesh by cloning the repository and running the demo.

### Installation

```bash
git clone https://github.com/joshuamlamerton/taskmesh
cd taskmesh
```

### Running the Demo

```bash
python examples/demo.py
```

## Architecture
This will launch the demo, showcasing the following features:

```mermaid
flowchart TB
* Task submission
* Agent task claiming
* Task assignment by the router

A[Task Producer Agent]
B[TaskMesh Router]
C[Worker Agent 1]
D[Worker Agent 2]
## Architecture
-------------

A --> B
B --> C
B --> D
```
TaskMesh consists of the following components:

## What it does
* **Task Producer Agent**: Publishes tasks to the TaskMesh router.
* **TaskMesh Router**: Routes tasks to available worker agents based on their capabilities or availability.
* **Worker Agent**: Claims tasks from the TaskMesh router and performs the assigned work.

The demo shows:
The following Mermaid diagram illustrates the architecture:

- a task being submitted
- agents claiming tasks
- the router assigning work
```mermaid
graph LR
A[Task Producer Agent] --> B[TaskMesh Router]
B --> C[Worker Agent 1]
B --> D[Worker Agent 2]
```

## Repository Structure
------------------------

```text
The TaskMesh repository is organized as follows:

```markdown
taskmesh
├── README.md
├── LICENSE
├── docs
│ └── architecture.md
├── core
│ └── task_router.py
├── examples
│ └── demo.py
```

README.md
LICENSE
## Roadmap
------------

docs
architecture.md
TaskMesh is currently in the experimental phase and is being developed in stages. The following roadmap outlines the planned features and milestones:

core
task_router.py
### Phase 1: Basic Task Queue

examples
demo.py
```
* Implement a basic task queue to store and retrieve tasks.
* Agents can submit and claim tasks from the queue.

## Roadmap
### Phase 2: Capability-Based Routing

* Introduce capability-based routing to match tasks with agents that possess the required skills.
* Agents can claim tasks based on their capabilities.

Phase 1
Basic task queue
### Phase 3: Priority and Retry Logic

Phase 2
Capability-based routing
* Implement priority-based task assignment to ensure critical tasks are completed first.
* Introduce retry logic to handle task failures and ensure task completion.

Phase 3
Priority and retry logic
### Phase 4: Multi-Agent Coordination Features

Phase 4
Multi-agent coordination features
* Develop features to enable multi-agent coordination, such as task delegation and agent collaboration.
* Enhance the TaskMesh router to manage complex task workflows and agent interactions.
74 changes: 74 additions & 0 deletions README.md.bak.20260313151934
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# TaskMesh

![License](https://img.shields.io/badge/license-Apache--2.0-blue)
![Python](https://img.shields.io/badge/python-3.9+-blue)
![Status](https://img.shields.io/badge/build-experimental-orange)

TaskMesh is a lightweight task routing layer for AI agents.

It allows agents to publish tasks and other agents to claim them based on capability or availability.

## Quick Start

Clone the repository and run the demo.

```bash
git clone https://github.com/joshuamlamerton/taskmesh
cd taskmesh
python examples/demo.py
```

## Architecture

```mermaid
flowchart TB

A[Task Producer Agent]
B[TaskMesh Router]
C[Worker Agent 1]
D[Worker Agent 2]

A --> B
B --> C
B --> D
```

## What it does

The demo shows:

- a task being submitted
- agents claiming tasks
- the router assigning work

## Repository Structure

```text
taskmesh

README.md
LICENSE

docs
architecture.md

core
task_router.py

examples
demo.py
```

## Roadmap

Phase 1
Basic task queue

Phase 2
Capability-based routing

Phase 3
Priority and retry logic

Phase 4
Multi-agent coordination features
30 changes: 30 additions & 0 deletions core/task_router.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,42 @@
```python
class TaskRouter:
"""
A task router class that manages a queue of tasks and assigns them to agents.
"""

def __init__(self):
"""
Initializes the task router with an empty task queue.
"""
# Initialize an empty list to store tasks
self.tasks = []

def submit_task(self, task):
"""
Adds a task to the task queue.

Args:
task (str): The task to be added to the queue.
"""
# Append the task to the end of the queue
self.tasks.append(task)

def claim_task(self, agent_name):
"""
Claims the next task in the queue for the given agent.

Args:
agent_name (str): The name of the agent claiming the task.

Returns:
dict or None: A dictionary containing the agent's name and the claimed task, or None if the queue is empty.
"""
# Check if the task queue is empty
if not self.tasks:
# If the queue is empty, return None
return None
# Remove and return the first task from the queue
task = self.tasks.pop(0)
# Return a dictionary containing the agent's name and the claimed task
return {"agent": agent_name, "task": task}
```
12 changes: 12 additions & 0 deletions core/task_router.py.bak.20260313151920
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
class TaskRouter:
def __init__(self):
self.tasks = []

def submit_task(self, task):
self.tasks.append(task)

def claim_task(self, agent_name):
if not self.tasks:
return None
task = self.tasks.pop(0)
return {"agent": agent_name, "task": task}
86 changes: 80 additions & 6 deletions examples/demo.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,84 @@
```python
from core.task_router import TaskRouter

router = TaskRouter()
def main():
"""
Demonstrates the usage of the TaskRouter class.
"""
# Initialize the task router
task_router = TaskRouter()

router.submit_task("analyze_market_data")
router.submit_task("generate_report")
# Submit tasks to the task router
tasks_to_submit = ["analyze_market_data", "generate_report"]
for task in tasks_to_submit:
task_router.submit_task(task)

print("Agent claim 1:", router.claim_task("analysis_agent"))
print("Agent claim 2:", router.claim_task("report_agent"))
print("Agent claim 3:", router.claim_task("idle_agent"))
# Attempt to claim tasks by agent name
agents = ["analysis_agent", "report_agent", "idle_agent"]
for agent in agents:
print(f"Agent claim {agents.index(agent) + 1}: {task_router.claim_task(agent)}")

if __name__ == "__main__":
main()
```

```python
# core/task_router.py
class TaskRouter:
"""
A class responsible for routing tasks to agents.

Attributes:
tasks (dict): A dictionary mapping task names to agent names.
"""

def __init__(self):
"""
Initializes the task router with an empty task dictionary.
"""
self.tasks = {}

def submit_task(self, task_name):
"""
Submits a task to the task router.

Args:
task_name (str): The name of the task to submit.

Returns:
None
"""
# For demonstration purposes, we'll just assign the task to the first available agent
# In a real implementation, this would likely involve more complex logic
self.tasks[task_name] = self.get_first_available_agent()

def claim_task(self, agent_name):
"""
Attempts to claim a task by agent name.

Args:
agent_name (str): The name of the agent attempting to claim the task.

Returns:
str: The name of the task claimed by the agent, or None if no task is available.
"""
# For demonstration purposes, we'll just return a task name if the agent is available
# In a real implementation, this would likely involve more complex logic
if agent_name in self.tasks.values():
for task, agent in self.tasks.items():
if agent == agent_name:
del self.tasks[task]
return task
return None

def get_first_available_agent(self):
"""
Returns the name of the first available agent.

Returns:
str: The name of the first available agent.
"""
# For demonstration purposes, we'll just return the first agent in the list
# In a real implementation, this would likely involve more complex logic
return "analysis_agent"
```
10 changes: 10 additions & 0 deletions examples/demo.py.bak.20260313151927
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from core.task_router import TaskRouter

router = TaskRouter()

router.submit_task("analyze_market_data")
router.submit_task("generate_report")

print("Agent claim 1:", router.claim_task("analysis_agent"))
print("Agent claim 2:", router.claim_task("report_agent"))
print("Agent claim 3:", router.claim_task("idle_agent"))
Loading