amacs 0.2.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.
- amacs-0.2.0/LICENSE +21 -0
- amacs-0.2.0/PKG-INFO +268 -0
- amacs-0.2.0/README.md +210 -0
- amacs-0.2.0/amacs/__init__.py +88 -0
- amacs-0.2.0/amacs/adaptive/__init__.py +32 -0
- amacs-0.2.0/amacs/adaptive/adaptation_engine.py +116 -0
- amacs-0.2.0/amacs/adaptive/evaluator.py +210 -0
- amacs-0.2.0/amacs/adaptive/monitor.py +153 -0
- amacs-0.2.0/amacs/adaptive/reconfigurator.py +271 -0
- amacs-0.2.0/amacs/agents/__init__.py +17 -0
- amacs-0.2.0/amacs/agents/analysis_agent.py +23 -0
- amacs-0.2.0/amacs/agents/base_agent.py +648 -0
- amacs-0.2.0/amacs/agents/search_agent.py +41 -0
- amacs-0.2.0/amacs/agents/validator_agent.py +23 -0
- amacs-0.2.0/amacs/agents/writer_agent.py +23 -0
- amacs-0.2.0/amacs/aggregation/__init__.py +146 -0
- amacs-0.2.0/amacs/aggregation/aggregator.py +5 -0
- amacs-0.2.0/amacs/benchmarks/__init__.py +7 -0
- amacs-0.2.0/amacs/benchmarks/benchmark_suite.py +57 -0
- amacs-0.2.0/amacs/cache.py +95 -0
- amacs-0.2.0/amacs/cli.py +72 -0
- amacs-0.2.0/amacs/communication/__init__.py +122 -0
- amacs-0.2.0/amacs/communication/bus.py +5 -0
- amacs-0.2.0/amacs/config.py +174 -0
- amacs-0.2.0/amacs/context_builder.py +128 -0
- amacs-0.2.0/amacs/coordination/__init__.py +13 -0
- amacs-0.2.0/amacs/coordination/base.py +57 -0
- amacs-0.2.0/amacs/coordination/debate.py +109 -0
- amacs-0.2.0/amacs/coordination/manager_worker.py +97 -0
- amacs-0.2.0/amacs/decorator.py +59 -0
- amacs-0.2.0/amacs/exceptions.py +197 -0
- amacs-0.2.0/amacs/executor.py +587 -0
- amacs-0.2.0/amacs/integrations/__init__.py +17 -0
- amacs-0.2.0/amacs/integrations/llm_providers.py +845 -0
- amacs-0.2.0/amacs/integrations/monitoring.py +82 -0
- amacs-0.2.0/amacs/integrations/vector_db.py +129 -0
- amacs-0.2.0/amacs/orchestrator/__init__.py +21 -0
- amacs-0.2.0/amacs/orchestrator/agent_selector.py +87 -0
- amacs-0.2.0/amacs/orchestrator/llm_decomposer.py +95 -0
- amacs-0.2.0/amacs/orchestrator/scheduler.py +195 -0
- amacs-0.2.0/amacs/orchestrator/task_analyzer.py +167 -0
- amacs-0.2.0/amacs/orchestrator/task_decomposer.py +151 -0
- amacs-0.2.0/amacs/pipeline.py +320 -0
- amacs-0.2.0/amacs/pricing.py +65 -0
- amacs-0.2.0/amacs/results.py +86 -0
- amacs-0.2.0/amacs/strategy.py +147 -0
- amacs-0.2.0/amacs/tools/__init__.py +40 -0
- amacs-0.2.0/amacs/tools/base_tool.py +49 -0
- amacs-0.2.0/amacs/tools/builtins.py +218 -0
- amacs-0.2.0/amacs/tracing.py +157 -0
- amacs-0.2.0/amacs.egg-info/PKG-INFO +268 -0
- amacs-0.2.0/amacs.egg-info/SOURCES.txt +88 -0
- amacs-0.2.0/amacs.egg-info/dependency_links.txt +1 -0
- amacs-0.2.0/amacs.egg-info/entry_points.txt +2 -0
- amacs-0.2.0/amacs.egg-info/requires.txt +41 -0
- amacs-0.2.0/amacs.egg-info/top_level.txt +2 -0
- amacs-0.2.0/benchmarks/__init__.py +7 -0
- amacs-0.2.0/benchmarks/benchmark_suite.py +10 -0
- amacs-0.2.0/benchmarks/report.py +79 -0
- amacs-0.2.0/benchmarks/run.py +141 -0
- amacs-0.2.0/benchmarks/systems/__init__.py +1 -0
- amacs-0.2.0/benchmarks/systems/baselines.py +63 -0
- amacs-0.2.0/pyproject.toml +88 -0
- amacs-0.2.0/setup.cfg +4 -0
- amacs-0.2.0/tests/test_adaptation_behavioral.py +361 -0
- amacs-0.2.0/tests/test_adaptive.py +140 -0
- amacs-0.2.0/tests/test_aggregation.py +74 -0
- amacs-0.2.0/tests/test_aggregator.py +112 -0
- amacs-0.2.0/tests/test_budgets.py +136 -0
- amacs-0.2.0/tests/test_bugs_phase1.py +157 -0
- amacs-0.2.0/tests/test_cheap_modules.py +164 -0
- amacs-0.2.0/tests/test_cli.py +43 -0
- amacs-0.2.0/tests/test_communication.py +73 -0
- amacs-0.2.0/tests/test_completion_regressions.py +76 -0
- amacs-0.2.0/tests/test_config.py +46 -0
- amacs-0.2.0/tests/test_context_builder.py +57 -0
- amacs-0.2.0/tests/test_coverage_boost.py +249 -0
- amacs-0.2.0/tests/test_decomposer_deps.py +94 -0
- amacs-0.2.0/tests/test_decorator.py +108 -0
- amacs-0.2.0/tests/test_fake_providers.py +74 -0
- amacs-0.2.0/tests/test_interwave_adaptation.py +67 -0
- amacs-0.2.0/tests/test_llm_providers.py +116 -0
- amacs-0.2.0/tests/test_multi_agent.py +58 -0
- amacs-0.2.0/tests/test_multi_agent_behavior.py +275 -0
- amacs-0.2.0/tests/test_orchestrator.py +191 -0
- amacs-0.2.0/tests/test_pipeline_parity.py +43 -0
- amacs-0.2.0/tests/test_retry_helper.py +121 -0
- amacs-0.2.0/tests/test_strategy.py +74 -0
- amacs-0.2.0/tests/test_strategy_budgets.py +69 -0
- amacs-0.2.0/tests/test_timeouts.py +119 -0
amacs-0.2.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 AMACS Contributors
|
|
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.
|
amacs-0.2.0/PKG-INFO
ADDED
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: amacs
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: Adaptive Multi-Agent Coordination System — add multi-agent AI coordination to any function with a single decorator.
|
|
5
|
+
Author-email: Aditya Padale <adityapadale25@gmail.com>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/Aditya-padale/amacs
|
|
8
|
+
Project-URL: Documentation, https://github.com/Aditya-padale/amacs/tree/main/docs
|
|
9
|
+
Project-URL: Repository, https://github.com/Aditya-padale/amacs
|
|
10
|
+
Project-URL: Issues, https://github.com/Aditya-padale/amacs/issues
|
|
11
|
+
Keywords: multi-agent,ai,coordination,decorator,llm,orchestration
|
|
12
|
+
Classifier: Development Status :: 3 - Alpha
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
20
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
21
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
22
|
+
Classifier: Typing :: Typed
|
|
23
|
+
Requires-Python: >=3.9
|
|
24
|
+
Description-Content-Type: text/markdown
|
|
25
|
+
License-File: LICENSE
|
|
26
|
+
Requires-Dist: tenacity>=8.0
|
|
27
|
+
Requires-Dist: pydantic>=2.0
|
|
28
|
+
Provides-Extra: openai
|
|
29
|
+
Requires-Dist: openai>=1.0; extra == "openai"
|
|
30
|
+
Provides-Extra: anthropic
|
|
31
|
+
Requires-Dist: anthropic>=0.20; extra == "anthropic"
|
|
32
|
+
Provides-Extra: ollama
|
|
33
|
+
Requires-Dist: ollama>=0.1; extra == "ollama"
|
|
34
|
+
Provides-Extra: gemini
|
|
35
|
+
Requires-Dist: google-genai>=1.0; extra == "gemini"
|
|
36
|
+
Provides-Extra: groq
|
|
37
|
+
Requires-Dist: groq>=0.9; extra == "groq"
|
|
38
|
+
Provides-Extra: pinecone
|
|
39
|
+
Requires-Dist: pinecone-client>=3.0; extra == "pinecone"
|
|
40
|
+
Provides-Extra: faiss
|
|
41
|
+
Requires-Dist: faiss-cpu>=1.7; extra == "faiss"
|
|
42
|
+
Provides-Extra: monitoring
|
|
43
|
+
Requires-Dist: prometheus-client>=0.17; extra == "monitoring"
|
|
44
|
+
Provides-Extra: all-llm
|
|
45
|
+
Requires-Dist: openai>=1.0; extra == "all-llm"
|
|
46
|
+
Requires-Dist: anthropic>=0.20; extra == "all-llm"
|
|
47
|
+
Requires-Dist: ollama>=0.1; extra == "all-llm"
|
|
48
|
+
Requires-Dist: google-genai>=1.0; extra == "all-llm"
|
|
49
|
+
Requires-Dist: groq>=0.9; extra == "all-llm"
|
|
50
|
+
Provides-Extra: dev
|
|
51
|
+
Requires-Dist: pytest>=7.0; extra == "dev"
|
|
52
|
+
Requires-Dist: pytest-asyncio>=0.21; extra == "dev"
|
|
53
|
+
Requires-Dist: pytest-cov>=4.0; extra == "dev"
|
|
54
|
+
Requires-Dist: hypothesis>=6.0; extra == "dev"
|
|
55
|
+
Requires-Dist: mypy>=1.0; extra == "dev"
|
|
56
|
+
Requires-Dist: ruff>=0.1; extra == "dev"
|
|
57
|
+
Dynamic: license-file
|
|
58
|
+
|
|
59
|
+
# AMACS
|
|
60
|
+
|
|
61
|
+
AMACS is a Python 3.9+ library for experimenting with adaptive multi-agent
|
|
62
|
+
orchestration behind the `@amacs(...)` decorator. It decomposes a task into
|
|
63
|
+
sub-tasks, schedules dependency-aware waves, calls a configured provider, and
|
|
64
|
+
aggregates the resulting text.
|
|
65
|
+
|
|
66
|
+
This repository is an alpha research and engineering project. The default
|
|
67
|
+
provider is an offline stub, and the included fixture benchmark measures
|
|
68
|
+
plumbing and fault recovery, not answer quality.
|
|
69
|
+
|
|
70
|
+
## Status
|
|
71
|
+
|
|
72
|
+
Implemented and tested locally:
|
|
73
|
+
|
|
74
|
+
- Synchronous and asynchronous `@amacs` wrappers backed by the shared `Pipeline`.
|
|
75
|
+
- Rule-based task analysis, template decomposition, DAG validation, and wave scheduling.
|
|
76
|
+
- Sync thread-pool and async wave execution with `max_agents` limits.
|
|
77
|
+
- OpenAI, Groq, Anthropic, Gemini, Ollama, and deterministic stub provider adapters, loaded lazily.
|
|
78
|
+
- Retry handling for retryable provider errors, per-agent timeout enforcement, token/cost budgets, and model pricing tables.
|
|
79
|
+
- Thread-safe communication bus, dependency-filtered context, tracing, optional response caching, and structured result details.
|
|
80
|
+
- Optional adaptive monitoring between waves and during a wave. It can record quality, failure, latency, and budget signals, retry with another agent, swap agents, skip optional work, or reduce the remaining team.
|
|
81
|
+
- Optional `debate`, `manager_worker`, and LLM planner modes. These are experimental interfaces, not validated quality improvements.
|
|
82
|
+
- Built-in tools with a mock search backend, a bounded search-agent tool loop, a local vector-store adapter, and an AST-restricted calculator.
|
|
83
|
+
|
|
84
|
+
Not established by this repository:
|
|
85
|
+
|
|
86
|
+
- Better answer quality than a single LLM call.
|
|
87
|
+
- A real web search service in the default configuration.
|
|
88
|
+
- Published PyPI distribution or stable production compatibility.
|
|
89
|
+
- A current comparison across providers, model IDs, domains, or real-world datasets.
|
|
90
|
+
|
|
91
|
+
## Installation From This Checkout
|
|
92
|
+
|
|
93
|
+
The project is not claiming a PyPI release. Install the checkout instead:
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
python -m pip install .
|
|
97
|
+
python -m pip install ".[dev]" # tests and verification tools
|
|
98
|
+
python -m pip install ".[openai]" # optional provider SDK
|
|
99
|
+
python -m pip install ".[groq]" # optional Groq provider SDK
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
Core runtime dependencies are `pydantic` and `tenacity`. Provider SDKs,
|
|
103
|
+
vector databases, and monitoring integrations are optional extras.
|
|
104
|
+
|
|
105
|
+
## Quick Start
|
|
106
|
+
|
|
107
|
+
```python
|
|
108
|
+
from amacs import amacs
|
|
109
|
+
|
|
110
|
+
@amacs(strategy="performance")
|
|
111
|
+
def research(topic: str) -> str:
|
|
112
|
+
return f"Research topic: {topic}"
|
|
113
|
+
|
|
114
|
+
print(research("renewable energy"))
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
The function body is used to produce the task input by default; AMACS does not
|
|
118
|
+
return the function's ordinary return value. Use `task="..."` for an explicit
|
|
119
|
+
prompt, `input_mode="return_value_as_prompt"` to make the return value the
|
|
120
|
+
prompt explicitly, or `return_details=True` to receive an `AMACSResult`.
|
|
121
|
+
|
|
122
|
+
```python
|
|
123
|
+
@amacs(task="Summarise the supplied topic", return_details=True, adaptive=True)
|
|
124
|
+
def summarise(topic: str) -> str:
|
|
125
|
+
return topic
|
|
126
|
+
|
|
127
|
+
result = summarise("grid storage")
|
|
128
|
+
print(result.final_output)
|
|
129
|
+
print(result.trace.to_json())
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
The public compatibility surface includes `max_agents`, `strategy`, and
|
|
133
|
+
`adaptive`, alongside configuration for provider, model, retry limit, timeout,
|
|
134
|
+
budgets, cache, planner, coordination mode, and structured output validation.
|
|
135
|
+
|
|
136
|
+
## Execution Model
|
|
137
|
+
|
|
138
|
+
```mermaid
|
|
139
|
+
flowchart TD
|
|
140
|
+
A[Decorated call] --> B[TaskAnalyzer]
|
|
141
|
+
B --> C[TaskDecomposer or LLM planner]
|
|
142
|
+
C --> D[AgentSelector]
|
|
143
|
+
D --> E[Scheduler: dependency waves]
|
|
144
|
+
E --> F[Agents and tools]
|
|
145
|
+
F --> G[CommunicationBus and Tracer]
|
|
146
|
+
G --> H[Aggregator and optional validation]
|
|
147
|
+
H --> I[AMACSResult or final_output]
|
|
148
|
+
F -. adaptive mode .-> J[Monitor -> Evaluator -> AdaptationEngine]
|
|
149
|
+
J --> K[Reconfigurator]
|
|
150
|
+
K --> E
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
The template planner is intentionally conservative: most built-in templates
|
|
154
|
+
form a search, analysis, writing, and validation chain. Independent tasks can
|
|
155
|
+
share a wave, but the default research template is mostly sequential. The
|
|
156
|
+
validator pass is a structured review; it only replaces the merged text when a
|
|
157
|
+
non-trivial revision passes the configured length ratio.
|
|
158
|
+
|
|
159
|
+
## Providers And Tools
|
|
160
|
+
|
|
161
|
+
Set `AMACS_LLM_PROVIDER` or pass `llm_provider=...`. Without configuration,
|
|
162
|
+
AMACS uses the deterministic `stub` provider so the default tests need no
|
|
163
|
+
network and no API key. The default `WebSearchTool` uses `MockSearchBackend` and
|
|
164
|
+
labels its output as mock data. Applications can supply a real `SearchBackend`.
|
|
165
|
+
|
|
166
|
+
Supported provider names are `stub`, `openai`, `groq`, `anthropic`, `gemini`, and
|
|
167
|
+
`ollama`. Provider model defaults are defined in the provider module and can be
|
|
168
|
+
overridden with `llm_model` or per-agent `models={...}`. Verify provider model
|
|
169
|
+
availability with the provider's current official documentation before making
|
|
170
|
+
live calls; this project does not assert that every default remains current.
|
|
171
|
+
|
|
172
|
+
For Groq, set `GROQ_API_KEY` and select the provider:
|
|
173
|
+
|
|
174
|
+
```bash
|
|
175
|
+
export GROQ_API_KEY="your-key"
|
|
176
|
+
export AMACS_LLM_PROVIDER=groq
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
Provider responses expose normalized content, usage, structured JSON, and tool
|
|
180
|
+
calls (`{id, name, arguments}`). Pass `output_schema` with a Pydantic model for
|
|
181
|
+
provider-native JSON guidance; tool execution is traced and bounded by
|
|
182
|
+
`max_tool_steps`. Provider SDK tests use mocks and `FakeProvider`, so API keys
|
|
183
|
+
are never required by normal tests.
|
|
184
|
+
|
|
185
|
+
Tracing records pipeline stages, waves, nested coordination, provider calls,
|
|
186
|
+
tools, cache hits, context truncation, retries, budgets, and adaptation actions.
|
|
187
|
+
OpenTelemetry export is optional and never required for local execution.
|
|
188
|
+
|
|
189
|
+
## Benchmarks
|
|
190
|
+
|
|
191
|
+
The checked-in `benchmarks/results/report.md` is a deterministic fixture run
|
|
192
|
+
with the stub provider. It is a recovery and overhead smoke test, not evidence
|
|
193
|
+
of model quality. Every report includes mean, standard deviation, and 95% CI
|
|
194
|
+
for latency, success, cost, and token usage, plus recovery rate.
|
|
195
|
+
|
|
196
|
+
| system | runs | success mean | success std | success CI95 | recovery rate | latency mean (s) | latency std | latency CI95 | cost mean | tokens mean |
|
|
197
|
+
|---|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|
|
|
198
|
+
| B0-B5 | see `benchmarks/results/report.md` | recorded fixture statistics | | | | | | | | |
|
|
199
|
+
|
|
200
|
+
The fixture's success predicate is string containment against expected fixture
|
|
201
|
+
text. It does not evaluate correctness, factuality, cost quality, or user
|
|
202
|
+
preference. Reproduce it with `make bench-fixture`. Full runs require a
|
|
203
|
+
locally available dataset and the selected provider SDK; they may require API
|
|
204
|
+
credentials and are never part of normal tests or CI:
|
|
205
|
+
|
|
206
|
+
```bash
|
|
207
|
+
python -m benchmarks.run --full --dataset reasoning --provider openai \
|
|
208
|
+
--systems B0,B1,B2,B3,B4,B5 --repetitions 3
|
|
209
|
+
python -m benchmarks.run --full --dataset coding --provider ollama \
|
|
210
|
+
--systems B2,B5 --repetitions 2
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
Use `--ablation adaptation`, `--ablation coordination`, `--ablation caching`,
|
|
214
|
+
or `--ablation strategy` to label reproducible ablation runs. Dataset provenance
|
|
215
|
+
and licensing requirements are documented in `benchmarks/datasets/README.md`.
|
|
216
|
+
|
|
217
|
+
## Package Structure
|
|
218
|
+
|
|
219
|
+
The implementation lives under `amacs/`. `amacs/communication/bus.py` and
|
|
220
|
+
`amacs/aggregation/aggregator.py` are compatibility exports; the implementations
|
|
221
|
+
are in `communication/__init__.py` and `aggregation/__init__.py` respectively.
|
|
222
|
+
|
|
223
|
+
```text
|
|
224
|
+
amacs/
|
|
225
|
+
decorator.py, pipeline.py, config.py, executor.py, results.py
|
|
226
|
+
agents/ provider-backed role agents and BaseAgent
|
|
227
|
+
adaptive/ monitor, evaluator, policy engine, reconfigurator
|
|
228
|
+
aggregation/ merge and validation implementation
|
|
229
|
+
communication/ shared bus implementation
|
|
230
|
+
coordination/ experimental debate and manager-worker modes
|
|
231
|
+
integrations/ provider, vector-store, and monitoring adapters
|
|
232
|
+
orchestrator/ analysis, decomposition, selection, and scheduling
|
|
233
|
+
tools/ calculator, search, vector, and registry tools
|
|
234
|
+
cache.py, tracing.py, pricing.py
|
|
235
|
+
benchmarks/ offline fixture harness and report
|
|
236
|
+
tests/ offline regression and behavioral tests
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
## Verification
|
|
240
|
+
|
|
241
|
+
```bash
|
|
242
|
+
make verify
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
The verification target runs Ruff, mypy, pytest with coverage, the fixture
|
|
246
|
+
benchmark, an offline wheel build, a fresh virtual-environment install, the
|
|
247
|
+
CLI smoke test, and the example. It does not make live API calls.
|
|
248
|
+
|
|
249
|
+
For the research context and known trade-offs, see
|
|
250
|
+
[`docs/architecture.md`](docs/architecture.md),
|
|
251
|
+
[`docs/adaptation.md`](docs/adaptation.md),
|
|
252
|
+
[`docs/evaluation.md`](docs/evaluation.md), and
|
|
253
|
+
[`docs/paper_notes.md`](docs/paper_notes.md).
|
|
254
|
+
|
|
255
|
+
## Limitations
|
|
256
|
+
|
|
257
|
+
The default task templates are linear enough that parallelism is workload
|
|
258
|
+
dependent. The mock search backend is not retrieval. Provider behavior,
|
|
259
|
+
pricing, latency, and model availability are external. Sync timeout handling
|
|
260
|
+
releases the caller after the timeout, but the underlying Python worker thread
|
|
261
|
+
may finish in the background. Adaptive actions change remaining execution and
|
|
262
|
+
can retry work, but they are not a learned policy and have no demonstrated
|
|
263
|
+
quality advantage. The repository has no verified real-task benchmark and no
|
|
264
|
+
claim of production readiness.
|
|
265
|
+
|
|
266
|
+
## License
|
|
267
|
+
|
|
268
|
+
MIT. See [`LICENSE`](LICENSE).
|
amacs-0.2.0/README.md
ADDED
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
# AMACS
|
|
2
|
+
|
|
3
|
+
AMACS is a Python 3.9+ library for experimenting with adaptive multi-agent
|
|
4
|
+
orchestration behind the `@amacs(...)` decorator. It decomposes a task into
|
|
5
|
+
sub-tasks, schedules dependency-aware waves, calls a configured provider, and
|
|
6
|
+
aggregates the resulting text.
|
|
7
|
+
|
|
8
|
+
This repository is an alpha research and engineering project. The default
|
|
9
|
+
provider is an offline stub, and the included fixture benchmark measures
|
|
10
|
+
plumbing and fault recovery, not answer quality.
|
|
11
|
+
|
|
12
|
+
## Status
|
|
13
|
+
|
|
14
|
+
Implemented and tested locally:
|
|
15
|
+
|
|
16
|
+
- Synchronous and asynchronous `@amacs` wrappers backed by the shared `Pipeline`.
|
|
17
|
+
- Rule-based task analysis, template decomposition, DAG validation, and wave scheduling.
|
|
18
|
+
- Sync thread-pool and async wave execution with `max_agents` limits.
|
|
19
|
+
- OpenAI, Groq, Anthropic, Gemini, Ollama, and deterministic stub provider adapters, loaded lazily.
|
|
20
|
+
- Retry handling for retryable provider errors, per-agent timeout enforcement, token/cost budgets, and model pricing tables.
|
|
21
|
+
- Thread-safe communication bus, dependency-filtered context, tracing, optional response caching, and structured result details.
|
|
22
|
+
- Optional adaptive monitoring between waves and during a wave. It can record quality, failure, latency, and budget signals, retry with another agent, swap agents, skip optional work, or reduce the remaining team.
|
|
23
|
+
- Optional `debate`, `manager_worker`, and LLM planner modes. These are experimental interfaces, not validated quality improvements.
|
|
24
|
+
- Built-in tools with a mock search backend, a bounded search-agent tool loop, a local vector-store adapter, and an AST-restricted calculator.
|
|
25
|
+
|
|
26
|
+
Not established by this repository:
|
|
27
|
+
|
|
28
|
+
- Better answer quality than a single LLM call.
|
|
29
|
+
- A real web search service in the default configuration.
|
|
30
|
+
- Published PyPI distribution or stable production compatibility.
|
|
31
|
+
- A current comparison across providers, model IDs, domains, or real-world datasets.
|
|
32
|
+
|
|
33
|
+
## Installation From This Checkout
|
|
34
|
+
|
|
35
|
+
The project is not claiming a PyPI release. Install the checkout instead:
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
python -m pip install .
|
|
39
|
+
python -m pip install ".[dev]" # tests and verification tools
|
|
40
|
+
python -m pip install ".[openai]" # optional provider SDK
|
|
41
|
+
python -m pip install ".[groq]" # optional Groq provider SDK
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Core runtime dependencies are `pydantic` and `tenacity`. Provider SDKs,
|
|
45
|
+
vector databases, and monitoring integrations are optional extras.
|
|
46
|
+
|
|
47
|
+
## Quick Start
|
|
48
|
+
|
|
49
|
+
```python
|
|
50
|
+
from amacs import amacs
|
|
51
|
+
|
|
52
|
+
@amacs(strategy="performance")
|
|
53
|
+
def research(topic: str) -> str:
|
|
54
|
+
return f"Research topic: {topic}"
|
|
55
|
+
|
|
56
|
+
print(research("renewable energy"))
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
The function body is used to produce the task input by default; AMACS does not
|
|
60
|
+
return the function's ordinary return value. Use `task="..."` for an explicit
|
|
61
|
+
prompt, `input_mode="return_value_as_prompt"` to make the return value the
|
|
62
|
+
prompt explicitly, or `return_details=True` to receive an `AMACSResult`.
|
|
63
|
+
|
|
64
|
+
```python
|
|
65
|
+
@amacs(task="Summarise the supplied topic", return_details=True, adaptive=True)
|
|
66
|
+
def summarise(topic: str) -> str:
|
|
67
|
+
return topic
|
|
68
|
+
|
|
69
|
+
result = summarise("grid storage")
|
|
70
|
+
print(result.final_output)
|
|
71
|
+
print(result.trace.to_json())
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
The public compatibility surface includes `max_agents`, `strategy`, and
|
|
75
|
+
`adaptive`, alongside configuration for provider, model, retry limit, timeout,
|
|
76
|
+
budgets, cache, planner, coordination mode, and structured output validation.
|
|
77
|
+
|
|
78
|
+
## Execution Model
|
|
79
|
+
|
|
80
|
+
```mermaid
|
|
81
|
+
flowchart TD
|
|
82
|
+
A[Decorated call] --> B[TaskAnalyzer]
|
|
83
|
+
B --> C[TaskDecomposer or LLM planner]
|
|
84
|
+
C --> D[AgentSelector]
|
|
85
|
+
D --> E[Scheduler: dependency waves]
|
|
86
|
+
E --> F[Agents and tools]
|
|
87
|
+
F --> G[CommunicationBus and Tracer]
|
|
88
|
+
G --> H[Aggregator and optional validation]
|
|
89
|
+
H --> I[AMACSResult or final_output]
|
|
90
|
+
F -. adaptive mode .-> J[Monitor -> Evaluator -> AdaptationEngine]
|
|
91
|
+
J --> K[Reconfigurator]
|
|
92
|
+
K --> E
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
The template planner is intentionally conservative: most built-in templates
|
|
96
|
+
form a search, analysis, writing, and validation chain. Independent tasks can
|
|
97
|
+
share a wave, but the default research template is mostly sequential. The
|
|
98
|
+
validator pass is a structured review; it only replaces the merged text when a
|
|
99
|
+
non-trivial revision passes the configured length ratio.
|
|
100
|
+
|
|
101
|
+
## Providers And Tools
|
|
102
|
+
|
|
103
|
+
Set `AMACS_LLM_PROVIDER` or pass `llm_provider=...`. Without configuration,
|
|
104
|
+
AMACS uses the deterministic `stub` provider so the default tests need no
|
|
105
|
+
network and no API key. The default `WebSearchTool` uses `MockSearchBackend` and
|
|
106
|
+
labels its output as mock data. Applications can supply a real `SearchBackend`.
|
|
107
|
+
|
|
108
|
+
Supported provider names are `stub`, `openai`, `groq`, `anthropic`, `gemini`, and
|
|
109
|
+
`ollama`. Provider model defaults are defined in the provider module and can be
|
|
110
|
+
overridden with `llm_model` or per-agent `models={...}`. Verify provider model
|
|
111
|
+
availability with the provider's current official documentation before making
|
|
112
|
+
live calls; this project does not assert that every default remains current.
|
|
113
|
+
|
|
114
|
+
For Groq, set `GROQ_API_KEY` and select the provider:
|
|
115
|
+
|
|
116
|
+
```bash
|
|
117
|
+
export GROQ_API_KEY="your-key"
|
|
118
|
+
export AMACS_LLM_PROVIDER=groq
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
Provider responses expose normalized content, usage, structured JSON, and tool
|
|
122
|
+
calls (`{id, name, arguments}`). Pass `output_schema` with a Pydantic model for
|
|
123
|
+
provider-native JSON guidance; tool execution is traced and bounded by
|
|
124
|
+
`max_tool_steps`. Provider SDK tests use mocks and `FakeProvider`, so API keys
|
|
125
|
+
are never required by normal tests.
|
|
126
|
+
|
|
127
|
+
Tracing records pipeline stages, waves, nested coordination, provider calls,
|
|
128
|
+
tools, cache hits, context truncation, retries, budgets, and adaptation actions.
|
|
129
|
+
OpenTelemetry export is optional and never required for local execution.
|
|
130
|
+
|
|
131
|
+
## Benchmarks
|
|
132
|
+
|
|
133
|
+
The checked-in `benchmarks/results/report.md` is a deterministic fixture run
|
|
134
|
+
with the stub provider. It is a recovery and overhead smoke test, not evidence
|
|
135
|
+
of model quality. Every report includes mean, standard deviation, and 95% CI
|
|
136
|
+
for latency, success, cost, and token usage, plus recovery rate.
|
|
137
|
+
|
|
138
|
+
| system | runs | success mean | success std | success CI95 | recovery rate | latency mean (s) | latency std | latency CI95 | cost mean | tokens mean |
|
|
139
|
+
|---|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|
|
|
140
|
+
| B0-B5 | see `benchmarks/results/report.md` | recorded fixture statistics | | | | | | | | |
|
|
141
|
+
|
|
142
|
+
The fixture's success predicate is string containment against expected fixture
|
|
143
|
+
text. It does not evaluate correctness, factuality, cost quality, or user
|
|
144
|
+
preference. Reproduce it with `make bench-fixture`. Full runs require a
|
|
145
|
+
locally available dataset and the selected provider SDK; they may require API
|
|
146
|
+
credentials and are never part of normal tests or CI:
|
|
147
|
+
|
|
148
|
+
```bash
|
|
149
|
+
python -m benchmarks.run --full --dataset reasoning --provider openai \
|
|
150
|
+
--systems B0,B1,B2,B3,B4,B5 --repetitions 3
|
|
151
|
+
python -m benchmarks.run --full --dataset coding --provider ollama \
|
|
152
|
+
--systems B2,B5 --repetitions 2
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
Use `--ablation adaptation`, `--ablation coordination`, `--ablation caching`,
|
|
156
|
+
or `--ablation strategy` to label reproducible ablation runs. Dataset provenance
|
|
157
|
+
and licensing requirements are documented in `benchmarks/datasets/README.md`.
|
|
158
|
+
|
|
159
|
+
## Package Structure
|
|
160
|
+
|
|
161
|
+
The implementation lives under `amacs/`. `amacs/communication/bus.py` and
|
|
162
|
+
`amacs/aggregation/aggregator.py` are compatibility exports; the implementations
|
|
163
|
+
are in `communication/__init__.py` and `aggregation/__init__.py` respectively.
|
|
164
|
+
|
|
165
|
+
```text
|
|
166
|
+
amacs/
|
|
167
|
+
decorator.py, pipeline.py, config.py, executor.py, results.py
|
|
168
|
+
agents/ provider-backed role agents and BaseAgent
|
|
169
|
+
adaptive/ monitor, evaluator, policy engine, reconfigurator
|
|
170
|
+
aggregation/ merge and validation implementation
|
|
171
|
+
communication/ shared bus implementation
|
|
172
|
+
coordination/ experimental debate and manager-worker modes
|
|
173
|
+
integrations/ provider, vector-store, and monitoring adapters
|
|
174
|
+
orchestrator/ analysis, decomposition, selection, and scheduling
|
|
175
|
+
tools/ calculator, search, vector, and registry tools
|
|
176
|
+
cache.py, tracing.py, pricing.py
|
|
177
|
+
benchmarks/ offline fixture harness and report
|
|
178
|
+
tests/ offline regression and behavioral tests
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
## Verification
|
|
182
|
+
|
|
183
|
+
```bash
|
|
184
|
+
make verify
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
The verification target runs Ruff, mypy, pytest with coverage, the fixture
|
|
188
|
+
benchmark, an offline wheel build, a fresh virtual-environment install, the
|
|
189
|
+
CLI smoke test, and the example. It does not make live API calls.
|
|
190
|
+
|
|
191
|
+
For the research context and known trade-offs, see
|
|
192
|
+
[`docs/architecture.md`](docs/architecture.md),
|
|
193
|
+
[`docs/adaptation.md`](docs/adaptation.md),
|
|
194
|
+
[`docs/evaluation.md`](docs/evaluation.md), and
|
|
195
|
+
[`docs/paper_notes.md`](docs/paper_notes.md).
|
|
196
|
+
|
|
197
|
+
## Limitations
|
|
198
|
+
|
|
199
|
+
The default task templates are linear enough that parallelism is workload
|
|
200
|
+
dependent. The mock search backend is not retrieval. Provider behavior,
|
|
201
|
+
pricing, latency, and model availability are external. Sync timeout handling
|
|
202
|
+
releases the caller after the timeout, but the underlying Python worker thread
|
|
203
|
+
may finish in the background. Adaptive actions change remaining execution and
|
|
204
|
+
can retry work, but they are not a learned policy and have no demonstrated
|
|
205
|
+
quality advantage. The repository has no verified real-task benchmark and no
|
|
206
|
+
claim of production readiness.
|
|
207
|
+
|
|
208
|
+
## License
|
|
209
|
+
|
|
210
|
+
MIT. See [`LICENSE`](LICENSE).
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"""AMACS — Adaptive Multi-Agent Coordination System.
|
|
2
|
+
|
|
3
|
+
Add multi-agent AI coordination to any function with a single decorator::
|
|
4
|
+
|
|
5
|
+
from amacs import amacs
|
|
6
|
+
|
|
7
|
+
@amacs(max_agents=8, strategy="performance")
|
|
8
|
+
def research_task(topic: str) -> str:
|
|
9
|
+
return f"Research on {topic}"
|
|
10
|
+
|
|
11
|
+
result = research_task("Renewable Energy")
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
from __future__ import annotations
|
|
15
|
+
|
|
16
|
+
__version__ = "0.2.0"
|
|
17
|
+
|
|
18
|
+
# ── Public API ────────────────────────────────────────────────────────────
|
|
19
|
+
|
|
20
|
+
from amacs.agents.base_agent import AgentResult, BaseAgent, SubTask
|
|
21
|
+
from amacs.communication import CommunicationBus, LogEntry
|
|
22
|
+
from amacs.config import AMACSConfig, Strategy
|
|
23
|
+
from amacs.decorator import amacs
|
|
24
|
+
from amacs.exceptions import (
|
|
25
|
+
AdaptationError,
|
|
26
|
+
AgentError,
|
|
27
|
+
AgentTimeoutError,
|
|
28
|
+
AggregationError,
|
|
29
|
+
AMACSError,
|
|
30
|
+
CommunicationError,
|
|
31
|
+
ConfigurationError,
|
|
32
|
+
LLMProviderError,
|
|
33
|
+
OrchestrationError,
|
|
34
|
+
RetryExhaustedError,
|
|
35
|
+
)
|
|
36
|
+
from amacs.integrations.llm_providers import (
|
|
37
|
+
LLMProvider,
|
|
38
|
+
LLMResponse,
|
|
39
|
+
Message,
|
|
40
|
+
get_provider,
|
|
41
|
+
register_provider,
|
|
42
|
+
)
|
|
43
|
+
from amacs.orchestrator.agent_selector import (
|
|
44
|
+
get_registered_agents,
|
|
45
|
+
register_agent,
|
|
46
|
+
)
|
|
47
|
+
from amacs.pipeline import Pipeline
|
|
48
|
+
from amacs.results import AMACSResult
|
|
49
|
+
|
|
50
|
+
__all__ = [
|
|
51
|
+
# Decorator & Pipeline
|
|
52
|
+
"amacs",
|
|
53
|
+
"Pipeline",
|
|
54
|
+
# Config
|
|
55
|
+
|
|
56
|
+
"AMACSConfig",
|
|
57
|
+
"Strategy",
|
|
58
|
+
# Results & Inspection
|
|
59
|
+
"AMACSResult",
|
|
60
|
+
"AgentResult",
|
|
61
|
+
"LogEntry",
|
|
62
|
+
"SubTask",
|
|
63
|
+
# Agents
|
|
64
|
+
"BaseAgent",
|
|
65
|
+
"get_registered_agents",
|
|
66
|
+
"register_agent",
|
|
67
|
+
# LLM
|
|
68
|
+
"get_provider",
|
|
69
|
+
"register_provider",
|
|
70
|
+
"LLMProvider",
|
|
71
|
+
"Message",
|
|
72
|
+
"LLMResponse",
|
|
73
|
+
# Communication
|
|
74
|
+
"CommunicationBus",
|
|
75
|
+
# Exceptions
|
|
76
|
+
"AMACSError",
|
|
77
|
+
"AgentError",
|
|
78
|
+
"AgentTimeoutError",
|
|
79
|
+
"AggregationError",
|
|
80
|
+
"CommunicationError",
|
|
81
|
+
"ConfigurationError",
|
|
82
|
+
"LLMProviderError",
|
|
83
|
+
"OrchestrationError",
|
|
84
|
+
"RetryExhaustedError",
|
|
85
|
+
"AdaptationError",
|
|
86
|
+
# Meta
|
|
87
|
+
"__version__",
|
|
88
|
+
]
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"""Adaptive control loop sub-package."""
|
|
2
|
+
|
|
3
|
+
from amacs.adaptive.adaptation_engine import (
|
|
4
|
+
ActionType,
|
|
5
|
+
AdaptationAction,
|
|
6
|
+
AdaptationEngine,
|
|
7
|
+
)
|
|
8
|
+
from amacs.adaptive.evaluator import (
|
|
9
|
+
AgentEvaluation,
|
|
10
|
+
EvaluationReport,
|
|
11
|
+
Evaluator,
|
|
12
|
+
HealthStatus,
|
|
13
|
+
ThresholdConfig,
|
|
14
|
+
)
|
|
15
|
+
from amacs.adaptive.monitor import AgentMetrics, Monitor, SystemSnapshot
|
|
16
|
+
from amacs.adaptive.reconfigurator import ReconfigurationResult, Reconfigurator
|
|
17
|
+
|
|
18
|
+
__all__ = [
|
|
19
|
+
"ActionType",
|
|
20
|
+
"AdaptationAction",
|
|
21
|
+
"AdaptationEngine",
|
|
22
|
+
"AgentEvaluation",
|
|
23
|
+
"AgentMetrics",
|
|
24
|
+
"EvaluationReport",
|
|
25
|
+
"Evaluator",
|
|
26
|
+
"HealthStatus",
|
|
27
|
+
"Monitor",
|
|
28
|
+
"ReconfigurationResult",
|
|
29
|
+
"Reconfigurator",
|
|
30
|
+
"SystemSnapshot",
|
|
31
|
+
"ThresholdConfig",
|
|
32
|
+
]
|