SwarmLLM is a research prototype for running a coordinator-guided swarm of LLM agents against optimization problems. The goal is to let many worker agents explore solution ideas in parallel, log what they tried, and let a coordinator LLM steer the next round based on what worked, what failed, and what still looks unexplored.
Today the repo is focused on a job scheduling benchmark: agents generate Python scheduling heuristics, the sandbox executes them, and the orchestrator scores them across multiple problem instances with different sizes and deadline tightness.
The inference layer now targets a unified OpenAI-compatible runtime surface, with backend profiles for ollama, vllm-metal, and vllm. The orchestration layer uses PydanticAI with typed coordinator and worker outputs while preserving the existing shared-log swarm loop.
The design in docs/DESIGN.md centers on three ideas:
- A swarm of worker agents exploring different algorithmic directions in parallel.
- A coordinator LLM assigning new directions after reading shared results.
- A shared, human-readable log so runs are debuggable and easy to inspect.
The preferred workflow uses uv, but you can fall back to pip or conda if a uv environment is unavailable.
Preferred uv setup:
uv syncFallback pip setup inside an activated Python environment:
python -m pip install -U pip
python -m pip install -e .
python -m pip install pytestFallback conda setup:
conda create -n swarmllm python=3.11
conda activate swarmllm
python -m pip install -U pip
python -m pip install -e .
python -m pip install pytestRun the test suite:
uv run pytest
# or, inside an activated pip or conda environment:
pytestRun the swarm from the project entry point:
uv run swarmllm --help
uv run swarmllm --backend-profile configs/backends/ollama.local.example.toml --agents 10 --iterations 3
uv run swarmllm --backend-profile configs/backends/ollama.local.example.toml --agents 10 --iterations 3 --dashboard auto
# or, inside an activated pip or conda environment:
swarmllm --help
swarmllm --backend-profile configs/backends/ollama.local.example.toml --agents 10 --iterations 3You can also run the script module directly:
uv run python -m scripts.run --backend-profile configs/backends/vllm.single-node.example.toml --agents 10 --iterations 3
# or, inside an activated pip or conda environment:
python -m scripts.run --backend-profile configs/backends/vllm.single-node.example.toml --agents 10 --iterations 3Swarm runs now support a built-in terminal monitor:
uv run swarmllm --backend-profile configs/backends/ollama.local.example.toml --dashboard auto--dashboard autouses the Rich TUI when stdout is a TTY and falls back to plain logs otherwise.--dashboard plainforces plain terminal output while still writing telemetry files.--dashboard tuiasks for the Rich TUI explicitly and falls back to plain mode if a TTY is unavailable.
Each run folder now includes:
events.jsonlfor append-only lifecycle telemetrylive_state.jsonfor the latest dashboard snapshotrun.logfor mirrored console output- the existing
results_log.md,summary.txt,token_usage.json,prompts/,instances/, andconfig.json
TUI controls:
o,a,p,dswitch between overview, agents, processes, and detail viewstabcycles viewsj/kmove the current selectiong/Gjump to the first or last item in the active list[/]switch the detail pane between agent and process context
ollamais the default local-iteration and Windows-friendly path.vllm-metalis the Apple Silicon path for higher local throughput on macOS.vllmis the Linux/server/cluster/cloud path for higher parallel agent throughput.
App dependencies live in this repo. Model servers are external runtimes:
- Ollama: run an OpenAI-compatible Ollama server locally.
- vLLM Metal: install and run the Apple Silicon
vllmCLI from the documented~/.venv-vllm-metalenvironment. - vLLM: run a standard
vllm servedeployment locally or remotely.
Example backend profiles live in configs/backends/, and example vllm serve YAML files live in configs/vllm/.
scripts/run.pyis the main CLI entry point.swarmllm/core/contains the orchestrator, worker agent loop, and coordinator logic.swarmllm/problems/contains optimization problem definitions and evaluation helpers.swarmllm/sandbox/runs agent-generated code under restrictions.swarmllm/llm/contains the LLM client wrapper.configs/backends/contains backend profile examples for Ollama, vLLM Metal, and vLLM.configs/vllm/containsvllm serveYAML templates.swarmllm/tracking/stores shared-log, prompt-log, and token-tracking helpers.tests/holds deterministic unit tests for local development and regression protection.
swarmLLM/
├── AGENTS.md
├── README.md
├── docs/
│ └── DESIGN.md
│ └── LLM_INFRA_SPEC.md
├── configs/
│ ├── backends/
│ └── vllm/
├── scripts/
│ ├── run.py
│ └── setup_run.py
├── swarmllm/
│ ├── config.py
│ ├── core/
│ ├── llm/
│ ├── problems/
│ ├── sandbox/
│ └── tracking/
├── tests/
└── pyproject.toml
- Prefer
uv add <package>for runtime dependencies anduv add --dev <package>for developer tooling. - If
uvis unavailable, install the project into an activatedpiporcondaenvironment withpython -m pip install -e ., install local dev tools such aspytestwithpython -m pip install ..., and run commands directly inside that environment. - Prefer
uv run ...for scripts, CLIs, and tests whenuvis available; otherwise use the same commands without theuv runprefix inside the activepiporcondaenvironment. - Treat
pyproject.tomlanduv.lockas the canonical dependency definitions;pipandcondaare compatibility workflows, not separate sources of truth. - Add or update tests whenever behavior changes, especially in
swarmllm/problems,swarmllm/sandbox,swarmllm/tracking, and parser-heavy logic inswarmllm/core. - Keep the deterministic core testable without requiring a live Ollama server.
- Keep backend selection in TOML profiles instead of scattering endpoint details through code.
- Treat
vllmandvllm-metalas external serving runtimes rather than mandatory Python package dependencies for repo users.