picoagents 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- picoagents-0.1.0/.gitignore +170 -0
- picoagents-0.1.0/LICENSE +21 -0
- picoagents-0.1.0/PKG-INFO +236 -0
- picoagents-0.1.0/README.md +195 -0
- picoagents-0.1.0/pyproject.toml +98 -0
- picoagents-0.1.0/src/picoagents/__init__.py +156 -0
- picoagents-0.1.0/src/picoagents/_cancellation_token.py +60 -0
- picoagents-0.1.0/src/picoagents/agents/__init__.py +18 -0
- picoagents-0.1.0/src/picoagents/agents/_agent.py +436 -0
- picoagents-0.1.0/src/picoagents/agents/_base.py +367 -0
- picoagents-0.1.0/src/picoagents/agents/multiagentbook.code-workspace +11 -0
- picoagents-0.1.0/src/picoagents/design.md +18 -0
- picoagents-0.1.0/src/picoagents/llm/__init__.py +24 -0
- picoagents-0.1.0/src/picoagents/llm/_base.py +160 -0
- picoagents-0.1.0/src/picoagents/llm/_openai.py +343 -0
- picoagents-0.1.0/src/picoagents/memory/__init__.py +20 -0
- picoagents-0.1.0/src/picoagents/memory/_base.py +259 -0
- picoagents-0.1.0/src/picoagents/messages.py +86 -0
- picoagents-0.1.0/src/picoagents/orchestration/__init__.py +39 -0
- picoagents-0.1.0/src/picoagents/orchestration/_ai.py +11 -0
- picoagents-0.1.0/src/picoagents/orchestration/_base.py +419 -0
- picoagents-0.1.0/src/picoagents/orchestration/_handoff.py +11 -0
- picoagents-0.1.0/src/picoagents/orchestration/_planner.py +11 -0
- picoagents-0.1.0/src/picoagents/orchestration/_round_robin.py +71 -0
- picoagents-0.1.0/src/picoagents/orchestration/termination/__init__.py +35 -0
- picoagents-0.1.0/src/picoagents/orchestration/termination/_base.py +76 -0
- picoagents-0.1.0/src/picoagents/orchestration/termination/_cancellation.py +27 -0
- picoagents-0.1.0/src/picoagents/orchestration/termination/_composite.py +74 -0
- picoagents-0.1.0/src/picoagents/orchestration/termination/_external.py +30 -0
- picoagents-0.1.0/src/picoagents/orchestration/termination/_function_call.py +27 -0
- picoagents-0.1.0/src/picoagents/orchestration/termination/_handoff.py +38 -0
- picoagents-0.1.0/src/picoagents/orchestration/termination/_max_message.py +34 -0
- picoagents-0.1.0/src/picoagents/orchestration/termination/_text_mention.py +31 -0
- picoagents-0.1.0/src/picoagents/orchestration/termination/_timeout.py +38 -0
- picoagents-0.1.0/src/picoagents/orchestration/termination/_token_usage.py +36 -0
- picoagents-0.1.0/src/picoagents/orchestration/termination.py +336 -0
- picoagents-0.1.0/src/picoagents/tools/__init__.py +16 -0
- picoagents-0.1.0/src/picoagents/tools/_base.py +274 -0
- picoagents-0.1.0/src/picoagents/types.py +394 -0
- picoagents-0.1.0/src/picoagents/workflow/__init__.py +7 -0
- picoagents-0.1.0/tests/__init__.py +3 -0
- picoagents-0.1.0/tests/test_agent_basic.py +285 -0
- picoagents-0.1.0/tests/test_cancellation_token.py +0 -0
- picoagents-0.1.0/tests/test_orchestrator.py +370 -0
- picoagents-0.1.0/tests/test_termination.py +471 -0
- picoagents-0.1.0/tests/test_tool_wrapping.py +229 -0
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
*.DS_Store
|
|
2
|
+
notebooks/data
|
|
3
|
+
notebooks/test
|
|
4
|
+
*.env
|
|
5
|
+
*.api.log
|
|
6
|
+
*.log
|
|
7
|
+
|
|
8
|
+
# Byte-compiled / optimized / DLL files
|
|
9
|
+
__pycache__/
|
|
10
|
+
*.py[cod]
|
|
11
|
+
*$py.class
|
|
12
|
+
|
|
13
|
+
# C extensions
|
|
14
|
+
*.so
|
|
15
|
+
|
|
16
|
+
# Distribution / packaging
|
|
17
|
+
.Python
|
|
18
|
+
build/
|
|
19
|
+
develop-eggs/
|
|
20
|
+
dist/
|
|
21
|
+
downloads/
|
|
22
|
+
eggs/
|
|
23
|
+
.eggs/
|
|
24
|
+
lib/
|
|
25
|
+
lib64/
|
|
26
|
+
parts/
|
|
27
|
+
sdist/
|
|
28
|
+
var/
|
|
29
|
+
wheels/
|
|
30
|
+
share/python-wheels/
|
|
31
|
+
*.egg-info/
|
|
32
|
+
.installed.cfg
|
|
33
|
+
*.egg
|
|
34
|
+
MANIFEST
|
|
35
|
+
|
|
36
|
+
# PyInstaller
|
|
37
|
+
# Usually these files are written by a python script from a template
|
|
38
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
39
|
+
*.manifest
|
|
40
|
+
*.spec
|
|
41
|
+
|
|
42
|
+
# Installer logs
|
|
43
|
+
pip-log.txt
|
|
44
|
+
pip-delete-this-directory.txt
|
|
45
|
+
|
|
46
|
+
# Unit test / coverage reports
|
|
47
|
+
htmlcov/
|
|
48
|
+
.tox/
|
|
49
|
+
.nox/
|
|
50
|
+
.coverage
|
|
51
|
+
.coverage.*
|
|
52
|
+
.cache
|
|
53
|
+
nosetests.xml
|
|
54
|
+
coverage.xml
|
|
55
|
+
*.cover
|
|
56
|
+
*.py,cover
|
|
57
|
+
.hypothesis/
|
|
58
|
+
.pytest_cache/
|
|
59
|
+
cover/
|
|
60
|
+
|
|
61
|
+
# Translations
|
|
62
|
+
*.mo
|
|
63
|
+
*.pot
|
|
64
|
+
|
|
65
|
+
# Django stuff:
|
|
66
|
+
*.log
|
|
67
|
+
local_settings.py
|
|
68
|
+
db.sqlite3
|
|
69
|
+
db.sqlite3-journal
|
|
70
|
+
|
|
71
|
+
# Flask stuff:
|
|
72
|
+
instance/
|
|
73
|
+
.webassets-cache
|
|
74
|
+
|
|
75
|
+
# Scrapy stuff:
|
|
76
|
+
.scrapy
|
|
77
|
+
|
|
78
|
+
# Sphinx documentation
|
|
79
|
+
docs/_build/
|
|
80
|
+
|
|
81
|
+
# PyBuilder
|
|
82
|
+
.pybuilder/
|
|
83
|
+
target/
|
|
84
|
+
|
|
85
|
+
# Jupyter Notebook
|
|
86
|
+
.ipynb_checkpoints
|
|
87
|
+
|
|
88
|
+
# IPython
|
|
89
|
+
profile_default/
|
|
90
|
+
ipython_config.py
|
|
91
|
+
|
|
92
|
+
# pyenv
|
|
93
|
+
# For a library or package, you might want to ignore these files since the code is
|
|
94
|
+
# intended to run in multiple environments; otherwise, check them in:
|
|
95
|
+
# .python-version
|
|
96
|
+
|
|
97
|
+
# pipenv
|
|
98
|
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
|
99
|
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
|
100
|
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
|
101
|
+
# install all needed dependencies.
|
|
102
|
+
#Pipfile.lock
|
|
103
|
+
|
|
104
|
+
# poetry
|
|
105
|
+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
|
106
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
107
|
+
# commonly ignored for libraries.
|
|
108
|
+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
|
109
|
+
#poetry.lock
|
|
110
|
+
|
|
111
|
+
# pdm
|
|
112
|
+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
|
113
|
+
#pdm.lock
|
|
114
|
+
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
|
|
115
|
+
# in version control.
|
|
116
|
+
# https://pdm.fming.dev/latest/usage/project/#working-with-version-control
|
|
117
|
+
.pdm.toml
|
|
118
|
+
.pdm-python
|
|
119
|
+
.pdm-build/
|
|
120
|
+
|
|
121
|
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
|
122
|
+
__pypackages__/
|
|
123
|
+
|
|
124
|
+
# Celery stuff
|
|
125
|
+
celerybeat-schedule
|
|
126
|
+
celerybeat.pid
|
|
127
|
+
|
|
128
|
+
# SageMath parsed files
|
|
129
|
+
*.sage.py
|
|
130
|
+
|
|
131
|
+
# Environments
|
|
132
|
+
.env
|
|
133
|
+
.venv
|
|
134
|
+
env/
|
|
135
|
+
venv/
|
|
136
|
+
ENV/
|
|
137
|
+
env.bak/
|
|
138
|
+
venv.bak/
|
|
139
|
+
|
|
140
|
+
# Spyder project settings
|
|
141
|
+
.spyderproject
|
|
142
|
+
.spyproject
|
|
143
|
+
|
|
144
|
+
# Rope project settings
|
|
145
|
+
.ropeproject
|
|
146
|
+
|
|
147
|
+
# mkdocs documentation
|
|
148
|
+
/site
|
|
149
|
+
|
|
150
|
+
# mypy
|
|
151
|
+
.mypy_cache/
|
|
152
|
+
.dmypy.json
|
|
153
|
+
dmypy.json
|
|
154
|
+
|
|
155
|
+
# Pyre type checker
|
|
156
|
+
.pyre/
|
|
157
|
+
|
|
158
|
+
# pytype static type analyzer
|
|
159
|
+
.pytype/
|
|
160
|
+
|
|
161
|
+
# Cython debug symbols
|
|
162
|
+
cython_debug/
|
|
163
|
+
|
|
164
|
+
# PyCharm
|
|
165
|
+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
|
166
|
+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
|
167
|
+
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
|
168
|
+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
|
169
|
+
#.idea/
|
|
170
|
+
/.quarto/
|
picoagents-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Victor Dibia
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: picoagents
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A minimal multi-agent framework for educational purposes
|
|
5
|
+
Project-URL: Homepage, https://github.com/victordibia/picoagents
|
|
6
|
+
Project-URL: Documentation, https://github.com/victordibia/picoagents#readme
|
|
7
|
+
Project-URL: Repository, https://github.com/victordibia/picoagents
|
|
8
|
+
Author-email: Victor Dibia <victordibia@gmail.com>
|
|
9
|
+
License-Expression: MIT
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Keywords: agents,ai,educational,llm,multi-agent
|
|
12
|
+
Classifier: Development Status :: 3 - Alpha
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: Intended Audience :: Education
|
|
15
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
21
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
22
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
23
|
+
Requires-Python: >=3.9
|
|
24
|
+
Requires-Dist: openai>=1.0.0
|
|
25
|
+
Requires-Dist: pydantic>=2.0.0
|
|
26
|
+
Requires-Dist: typing-extensions>=4.0.0
|
|
27
|
+
Provides-Extra: dev
|
|
28
|
+
Requires-Dist: black; extra == 'dev'
|
|
29
|
+
Requires-Dist: flake8; extra == 'dev'
|
|
30
|
+
Requires-Dist: isort; extra == 'dev'
|
|
31
|
+
Requires-Dist: mypy; extra == 'dev'
|
|
32
|
+
Requires-Dist: pyright; extra == 'dev'
|
|
33
|
+
Requires-Dist: pytest-asyncio>=0.21.0; extra == 'dev'
|
|
34
|
+
Requires-Dist: pytest-cov; extra == 'dev'
|
|
35
|
+
Requires-Dist: pytest>=7.0.0; extra == 'dev'
|
|
36
|
+
Provides-Extra: examples
|
|
37
|
+
Requires-Dist: matplotlib; extra == 'examples'
|
|
38
|
+
Requires-Dist: requests; extra == 'examples'
|
|
39
|
+
Requires-Dist: yfinance; extra == 'examples'
|
|
40
|
+
Description-Content-Type: text/markdown
|
|
41
|
+
|
|
42
|
+
# PicoAgents [Beta]
|
|
43
|
+
|
|
44
|
+
A minimal multi-agent framework for educational purposes, accompanying the book "Designing Multi-Agent Systems: Principles, Patterns, and Implementation for AI Agents" by Victor Dibia.
|
|
45
|
+
|
|
46
|
+
> Note: While the principles in this library are "production-ready" and mirror many of the decisions made in frameworks like AutoGen, Google ADK etc, careful consideration should be given before using it in production environments.
|
|
47
|
+
|
|
48
|
+
## Overview
|
|
49
|
+
|
|
50
|
+
PicoAgents demonstrates core multi-agent concepts by building agents and coordination patterns from scratch. It's designed to be:
|
|
51
|
+
|
|
52
|
+
- **Educational**: Clear, well-documented implementations of core concepts
|
|
53
|
+
- **Minimal**: Focused on essential patterns without unnecessary complexity
|
|
54
|
+
- **Extensible**: Easy to modify and experiment with different approaches
|
|
55
|
+
- **Type-safe**: Full typing support with pyright/mypy
|
|
56
|
+
|
|
57
|
+
## Installation
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
# Install from PyPI (when published)
|
|
61
|
+
pip install picoagents
|
|
62
|
+
|
|
63
|
+
# Or install from source
|
|
64
|
+
git clone <repository-url>
|
|
65
|
+
cd picoagents
|
|
66
|
+
pip install -e .
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## Quick Start
|
|
70
|
+
|
|
71
|
+
### Creating a Basic Agent
|
|
72
|
+
|
|
73
|
+
```python
|
|
74
|
+
from picoagents import Agent, get_weather
|
|
75
|
+
|
|
76
|
+
# Create an agent with tools
|
|
77
|
+
agent = Agent(
|
|
78
|
+
name="weather_assistant",
|
|
79
|
+
instructions="You are a helpful weather assistant.",
|
|
80
|
+
model="gpt-4",
|
|
81
|
+
tools=[get_weather]
|
|
82
|
+
)
|
|
83
|
+
|
|
84
|
+
# Use the agent
|
|
85
|
+
response = agent.run("What's the weather like in San Francisco?")
|
|
86
|
+
print(response)
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### Sequential Workflow Pattern
|
|
90
|
+
|
|
91
|
+
```python
|
|
92
|
+
from picoagents import Agent, SequentialWorkflow, AgentNode
|
|
93
|
+
|
|
94
|
+
# Create agents
|
|
95
|
+
researcher = Agent("researcher", "You research topics thoroughly.")
|
|
96
|
+
writer = Agent("writer", "You write clear, engaging content.")
|
|
97
|
+
editor = Agent("editor", "You edit and improve text.")
|
|
98
|
+
|
|
99
|
+
# Create workflow
|
|
100
|
+
workflow = SequentialWorkflow("content_pipeline")
|
|
101
|
+
workflow.add_node(AgentNode("research", researcher))
|
|
102
|
+
workflow.add_node(AgentNode("write", writer))
|
|
103
|
+
workflow.add_node(AgentNode("edit", editor))
|
|
104
|
+
|
|
105
|
+
# Run workflow
|
|
106
|
+
result = workflow.run("Write an article about renewable energy")
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
### Round-Robin Orchestration
|
|
110
|
+
|
|
111
|
+
```python
|
|
112
|
+
from picoagents import Agent, RoundRobinOrchestrator
|
|
113
|
+
|
|
114
|
+
# Create specialized agents
|
|
115
|
+
coder = Agent("coder", "You write clean, efficient code.")
|
|
116
|
+
tester = Agent("tester", "You test code and find bugs.")
|
|
117
|
+
reviewer = Agent("reviewer", "You review code quality.")
|
|
118
|
+
|
|
119
|
+
# Create orchestrator
|
|
120
|
+
orchestrator = RoundRobinOrchestrator("development_team")
|
|
121
|
+
orchestrator.add_agent(coder)
|
|
122
|
+
orchestrator.add_agent(tester)
|
|
123
|
+
orchestrator.add_agent(reviewer)
|
|
124
|
+
|
|
125
|
+
# Solve task collaboratively
|
|
126
|
+
result = orchestrator.orchestrate("Create a Python function to calculate fibonacci numbers")
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
## Core Concepts
|
|
130
|
+
|
|
131
|
+
### Agents (Chapter 4)
|
|
132
|
+
|
|
133
|
+
The foundation of the framework is the `Agent` class that implements:
|
|
134
|
+
|
|
135
|
+
- **Reasoning**: Integration with language models (OpenAI GPT, etc.)
|
|
136
|
+
- **Acting**: Tool calling and execution
|
|
137
|
+
- **Memory**: Information storage and retrieval
|
|
138
|
+
- **Communication**: Message history and context management
|
|
139
|
+
|
|
140
|
+
### Workflow Patterns (Chapter 2 - Explicit Control)
|
|
141
|
+
|
|
142
|
+
Predefined execution paths with deterministic behavior:
|
|
143
|
+
|
|
144
|
+
- **Sequential**: Linear execution (A → B → C)
|
|
145
|
+
- **Conditional**: Branching logic with decision points
|
|
146
|
+
- **Parallel**: Concurrent execution with fan-out/fan-in
|
|
147
|
+
|
|
148
|
+
### Orchestration Patterns (Chapter 2 - Autonomous Control)
|
|
149
|
+
|
|
150
|
+
Runtime-determined coordination through agent reasoning:
|
|
151
|
+
|
|
152
|
+
- **Round-Robin**: Simple turn-taking between agents
|
|
153
|
+
- **LLM-Based**: AI-driven agent selection and coordination
|
|
154
|
+
- **Plan-Based**: Explicit planning with dynamic execution
|
|
155
|
+
|
|
156
|
+
## Architecture
|
|
157
|
+
|
|
158
|
+
```
|
|
159
|
+
src/picoagents/
|
|
160
|
+
├── agents.py # Core Agent implementation
|
|
161
|
+
├── multiagent.py # High-level system coordination
|
|
162
|
+
├── workflow/ # Explicit control patterns
|
|
163
|
+
│ ├── base.py # Base classes and abstractions
|
|
164
|
+
│ ├── sequential.py # Sequential workflow pattern
|
|
165
|
+
│ ├── conditional.py # Conditional/branching workflows
|
|
166
|
+
│ └── parallel.py # Parallel execution patterns
|
|
167
|
+
└── orchestration/ # Autonomous control patterns
|
|
168
|
+
├── base.py # Base orchestration classes
|
|
169
|
+
├── roundrobin.py # Round-robin coordination
|
|
170
|
+
├── llm.py # LLM-based coordination
|
|
171
|
+
└── planner.py # Plan-based orchestration
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
## Examples
|
|
175
|
+
|
|
176
|
+
The `examples/` directory contains implementations from each chapter:
|
|
177
|
+
|
|
178
|
+
- `chapter04_basic_agent.py` - Building your first agent
|
|
179
|
+
- `chapter05_workflow_patterns.py` - Multi-agent workflows
|
|
180
|
+
- `chapter06_orchestration.py` - Autonomous coordination
|
|
181
|
+
- `advanced_examples.py` - Complex multi-agent systems
|
|
182
|
+
|
|
183
|
+
## Development
|
|
184
|
+
|
|
185
|
+
```bash
|
|
186
|
+
# Install development dependencies
|
|
187
|
+
pip install -e ".[dev]"
|
|
188
|
+
|
|
189
|
+
# Run type checking
|
|
190
|
+
pyright
|
|
191
|
+
|
|
192
|
+
# Run tests
|
|
193
|
+
pytest
|
|
194
|
+
|
|
195
|
+
# Format code
|
|
196
|
+
black src/
|
|
197
|
+
isort src/
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
## Requirements
|
|
201
|
+
|
|
202
|
+
- Python 3.9+
|
|
203
|
+
- OpenAI API key (set `OPENAI_API_KEY` environment variable)
|
|
204
|
+
- Optional: Other LLM providers (configure in agent initialization)
|
|
205
|
+
|
|
206
|
+
## Contributing
|
|
207
|
+
|
|
208
|
+
This is an educational framework designed to accompany the book. Contributions should:
|
|
209
|
+
|
|
210
|
+
1. Maintain clarity and simplicity
|
|
211
|
+
2. Include comprehensive documentation
|
|
212
|
+
3. Follow the established patterns
|
|
213
|
+
4. Include tests and type hints
|
|
214
|
+
|
|
215
|
+
## License
|
|
216
|
+
|
|
217
|
+
MIT License - see LICENSE file for details.
|
|
218
|
+
|
|
219
|
+
## Related Resources
|
|
220
|
+
|
|
221
|
+
- Book: "Designing Multi-Agent Systems: Principles, Patterns, and Implementation"
|
|
222
|
+
- Documentation: [Coming soon]
|
|
223
|
+
- Examples: See `examples/` directory
|
|
224
|
+
|
|
225
|
+
## Citation
|
|
226
|
+
|
|
227
|
+
If you use this framework in academic work, please cite:
|
|
228
|
+
|
|
229
|
+
```bibtex
|
|
230
|
+
@book{dibia2025multiagent,
|
|
231
|
+
title={Designing Multi-Agent Systems: Principles, Patterns, and Implementation},
|
|
232
|
+
author={Dibia, Victor},
|
|
233
|
+
year={2025},
|
|
234
|
+
publisher={...}
|
|
235
|
+
}
|
|
236
|
+
```
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
# PicoAgents [Beta]
|
|
2
|
+
|
|
3
|
+
A minimal multi-agent framework for educational purposes, accompanying the book "Designing Multi-Agent Systems: Principles, Patterns, and Implementation for AI Agents" by Victor Dibia.
|
|
4
|
+
|
|
5
|
+
> Note: While the principles in this library are "production-ready" and mirror many of the decisions made in frameworks like AutoGen, Google ADK etc, careful consideration should be given before using it in production environments.
|
|
6
|
+
|
|
7
|
+
## Overview
|
|
8
|
+
|
|
9
|
+
PicoAgents demonstrates core multi-agent concepts by building agents and coordination patterns from scratch. It's designed to be:
|
|
10
|
+
|
|
11
|
+
- **Educational**: Clear, well-documented implementations of core concepts
|
|
12
|
+
- **Minimal**: Focused on essential patterns without unnecessary complexity
|
|
13
|
+
- **Extensible**: Easy to modify and experiment with different approaches
|
|
14
|
+
- **Type-safe**: Full typing support with pyright/mypy
|
|
15
|
+
|
|
16
|
+
## Installation
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
# Install from PyPI (when published)
|
|
20
|
+
pip install picoagents
|
|
21
|
+
|
|
22
|
+
# Or install from source
|
|
23
|
+
git clone <repository-url>
|
|
24
|
+
cd picoagents
|
|
25
|
+
pip install -e .
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Quick Start
|
|
29
|
+
|
|
30
|
+
### Creating a Basic Agent
|
|
31
|
+
|
|
32
|
+
```python
|
|
33
|
+
from picoagents import Agent, get_weather
|
|
34
|
+
|
|
35
|
+
# Create an agent with tools
|
|
36
|
+
agent = Agent(
|
|
37
|
+
name="weather_assistant",
|
|
38
|
+
instructions="You are a helpful weather assistant.",
|
|
39
|
+
model="gpt-4",
|
|
40
|
+
tools=[get_weather]
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
# Use the agent
|
|
44
|
+
response = agent.run("What's the weather like in San Francisco?")
|
|
45
|
+
print(response)
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### Sequential Workflow Pattern
|
|
49
|
+
|
|
50
|
+
```python
|
|
51
|
+
from picoagents import Agent, SequentialWorkflow, AgentNode
|
|
52
|
+
|
|
53
|
+
# Create agents
|
|
54
|
+
researcher = Agent("researcher", "You research topics thoroughly.")
|
|
55
|
+
writer = Agent("writer", "You write clear, engaging content.")
|
|
56
|
+
editor = Agent("editor", "You edit and improve text.")
|
|
57
|
+
|
|
58
|
+
# Create workflow
|
|
59
|
+
workflow = SequentialWorkflow("content_pipeline")
|
|
60
|
+
workflow.add_node(AgentNode("research", researcher))
|
|
61
|
+
workflow.add_node(AgentNode("write", writer))
|
|
62
|
+
workflow.add_node(AgentNode("edit", editor))
|
|
63
|
+
|
|
64
|
+
# Run workflow
|
|
65
|
+
result = workflow.run("Write an article about renewable energy")
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### Round-Robin Orchestration
|
|
69
|
+
|
|
70
|
+
```python
|
|
71
|
+
from picoagents import Agent, RoundRobinOrchestrator
|
|
72
|
+
|
|
73
|
+
# Create specialized agents
|
|
74
|
+
coder = Agent("coder", "You write clean, efficient code.")
|
|
75
|
+
tester = Agent("tester", "You test code and find bugs.")
|
|
76
|
+
reviewer = Agent("reviewer", "You review code quality.")
|
|
77
|
+
|
|
78
|
+
# Create orchestrator
|
|
79
|
+
orchestrator = RoundRobinOrchestrator("development_team")
|
|
80
|
+
orchestrator.add_agent(coder)
|
|
81
|
+
orchestrator.add_agent(tester)
|
|
82
|
+
orchestrator.add_agent(reviewer)
|
|
83
|
+
|
|
84
|
+
# Solve task collaboratively
|
|
85
|
+
result = orchestrator.orchestrate("Create a Python function to calculate fibonacci numbers")
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
## Core Concepts
|
|
89
|
+
|
|
90
|
+
### Agents (Chapter 4)
|
|
91
|
+
|
|
92
|
+
The foundation of the framework is the `Agent` class that implements:
|
|
93
|
+
|
|
94
|
+
- **Reasoning**: Integration with language models (OpenAI GPT, etc.)
|
|
95
|
+
- **Acting**: Tool calling and execution
|
|
96
|
+
- **Memory**: Information storage and retrieval
|
|
97
|
+
- **Communication**: Message history and context management
|
|
98
|
+
|
|
99
|
+
### Workflow Patterns (Chapter 2 - Explicit Control)
|
|
100
|
+
|
|
101
|
+
Predefined execution paths with deterministic behavior:
|
|
102
|
+
|
|
103
|
+
- **Sequential**: Linear execution (A → B → C)
|
|
104
|
+
- **Conditional**: Branching logic with decision points
|
|
105
|
+
- **Parallel**: Concurrent execution with fan-out/fan-in
|
|
106
|
+
|
|
107
|
+
### Orchestration Patterns (Chapter 2 - Autonomous Control)
|
|
108
|
+
|
|
109
|
+
Runtime-determined coordination through agent reasoning:
|
|
110
|
+
|
|
111
|
+
- **Round-Robin**: Simple turn-taking between agents
|
|
112
|
+
- **LLM-Based**: AI-driven agent selection and coordination
|
|
113
|
+
- **Plan-Based**: Explicit planning with dynamic execution
|
|
114
|
+
|
|
115
|
+
## Architecture
|
|
116
|
+
|
|
117
|
+
```
|
|
118
|
+
src/picoagents/
|
|
119
|
+
├── agents.py # Core Agent implementation
|
|
120
|
+
├── multiagent.py # High-level system coordination
|
|
121
|
+
├── workflow/ # Explicit control patterns
|
|
122
|
+
│ ├── base.py # Base classes and abstractions
|
|
123
|
+
│ ├── sequential.py # Sequential workflow pattern
|
|
124
|
+
│ ├── conditional.py # Conditional/branching workflows
|
|
125
|
+
│ └── parallel.py # Parallel execution patterns
|
|
126
|
+
└── orchestration/ # Autonomous control patterns
|
|
127
|
+
├── base.py # Base orchestration classes
|
|
128
|
+
├── roundrobin.py # Round-robin coordination
|
|
129
|
+
├── llm.py # LLM-based coordination
|
|
130
|
+
└── planner.py # Plan-based orchestration
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
## Examples
|
|
134
|
+
|
|
135
|
+
The `examples/` directory contains implementations from each chapter:
|
|
136
|
+
|
|
137
|
+
- `chapter04_basic_agent.py` - Building your first agent
|
|
138
|
+
- `chapter05_workflow_patterns.py` - Multi-agent workflows
|
|
139
|
+
- `chapter06_orchestration.py` - Autonomous coordination
|
|
140
|
+
- `advanced_examples.py` - Complex multi-agent systems
|
|
141
|
+
|
|
142
|
+
## Development
|
|
143
|
+
|
|
144
|
+
```bash
|
|
145
|
+
# Install development dependencies
|
|
146
|
+
pip install -e ".[dev]"
|
|
147
|
+
|
|
148
|
+
# Run type checking
|
|
149
|
+
pyright
|
|
150
|
+
|
|
151
|
+
# Run tests
|
|
152
|
+
pytest
|
|
153
|
+
|
|
154
|
+
# Format code
|
|
155
|
+
black src/
|
|
156
|
+
isort src/
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
## Requirements
|
|
160
|
+
|
|
161
|
+
- Python 3.9+
|
|
162
|
+
- OpenAI API key (set `OPENAI_API_KEY` environment variable)
|
|
163
|
+
- Optional: Other LLM providers (configure in agent initialization)
|
|
164
|
+
|
|
165
|
+
## Contributing
|
|
166
|
+
|
|
167
|
+
This is an educational framework designed to accompany the book. Contributions should:
|
|
168
|
+
|
|
169
|
+
1. Maintain clarity and simplicity
|
|
170
|
+
2. Include comprehensive documentation
|
|
171
|
+
3. Follow the established patterns
|
|
172
|
+
4. Include tests and type hints
|
|
173
|
+
|
|
174
|
+
## License
|
|
175
|
+
|
|
176
|
+
MIT License - see LICENSE file for details.
|
|
177
|
+
|
|
178
|
+
## Related Resources
|
|
179
|
+
|
|
180
|
+
- Book: "Designing Multi-Agent Systems: Principles, Patterns, and Implementation"
|
|
181
|
+
- Documentation: [Coming soon]
|
|
182
|
+
- Examples: See `examples/` directory
|
|
183
|
+
|
|
184
|
+
## Citation
|
|
185
|
+
|
|
186
|
+
If you use this framework in academic work, please cite:
|
|
187
|
+
|
|
188
|
+
```bibtex
|
|
189
|
+
@book{dibia2025multiagent,
|
|
190
|
+
title={Designing Multi-Agent Systems: Principles, Patterns, and Implementation},
|
|
191
|
+
author={Dibia, Victor},
|
|
192
|
+
year={2025},
|
|
193
|
+
publisher={...}
|
|
194
|
+
}
|
|
195
|
+
```
|