Skip to main content

Multi-provider agent swarm orchestration: Kimi CLI + Kimi Coding API + DeepSeek + Qwen + Claude. asyncio.gather + git worktree isolation, pre-authored packets, AG#1 source-trace meta-review. v0.3.3 adds --no-thinking opt-out for DeepSeek v4-* thinking-mode (harmful on long-input grep tasks per the V_HOTFIX_1 A4 ramp test). See CHANGELOG for the full version history.

Project description

xaxiu-swarm

Multi-provider parallel agent dispatch with asyncio.gather + git worktree isolation. Pre-authored packets only, no auto-decomposition. Three primitives: dispatch / swarm / worktree_swarm. Four backends: Kimi CLI (subscription, zero marginal), DeepSeek (paid HTTP), Qwen (paid HTTP), Claude (premium, optional). Plus ag1_meta_review for cross-engine adjudication with source-trace baked in.

Python 3.10+ License: MIT Status: Beta

Why

Parallel agent dispatch is conceptually simple — asyncio.gather over N subprocess/API calls — but the production-grade version has surprisingly many sharp edges that get rediscovered every time. xaxiu-swarm packages the lessons:

  • UTF-8 environment hygiene so Kimi doesn't crash on Unicode chars in source files (Windows CP1252 charmap)
  • Per-worker isolated Kimi HOME so concurrent processes don't fight over the shared log file
  • Context-file inlining so API backends (DeepSeek/Qwen/Claude) can actually see source instead of pattern-extrapolating from packet text alone
  • Auto-write of API-backend responses to deliverable paths extracted from packet text
  • swarm.json state with atomic per-worker updates + heartbeat liveness
  • Worktree isolation primitive for parallel codemod workloads
  • AG#1 cross-engine meta-review helper that auto-injects a source-trace verification clause (so AG#1 doesn't rubber-stamp pattern-extrapolated findings)

This isn't a replacement for LangGraph or CrewAI — those handle DAG dependencies, mid-run checkpointing, complex agent collaboration. xaxiu-swarm is the parallel-dispatch primitive for embarrassingly-parallel-with-isolation workloads. ~1500 LoC, no auto-decomp, no DAG, boring and predictable.

Install

pip install xaxiu-swarm
# or with optional Claude support:
pip install "xaxiu-swarm[claude]"
# or for development:
pip install "xaxiu-swarm[dev]"

Quick start

CLI

# Single dispatch
xaxiu-swarm dispatch packet.md --backend kimi

# 3-way swarm, single backend
xaxiu-swarm swarm engineer.md di.md pract.md --backend kimi --max-concurrent 3

# Mixed-backend swarm (cross-engine diversity → reduces conformity bias)
xaxiu-swarm swarm engineer.md di.md pract.md --backends kimi,deepseek,qwen

# Worktree-isolated parallel codemod
xaxiu-swarm wt-swarm fix_a.md fix_b.md fix_c.md \
    --repo-root /path/to/repo --backend kimi --cleanup on-success

# AG#1 cross-engine meta-review (G32 source-trace clause auto-injected)
xaxiu-swarm ag1 \
    --subject "Wave 42 hotfix" \
    --report engineer.md --report di.md --report pract.md \
    --source v_file.html \
    --backend deepseek \
    --deliverable ag1_meta.md

Python API

import asyncio
from xaxiu_swarm import dispatch, swarm, worktree_swarm, ag1_meta_review

# Sync single dispatch
result = dispatch("packet.md", backend="kimi", timeout=1800)
print(result.status, result.response[:200])

# N-way parallel
results = asyncio.run(swarm(
    packets=["engineer.md", "di.md", "pract.md"],
    backend="kimi",
    max_concurrent=3,
))

# Mixed-backend swarm
results = asyncio.run(swarm(
    packets=["audit.md", "audit.md", "audit.md"],
    backend=["kimi", "deepseek", "qwen"],
))

# Worktree-isolated codemod
results = asyncio.run(worktree_swarm(
    packets=["refactor_x.md", "refactor_y.md"],
    repo_root="/path/to/repo",
    backend="kimi",
    cleanup="on-success",
))

# AG#1 with source-trace
ag1_result = asyncio.run(ag1_meta_review(
    subject="Wave 42 hotfix",
    cohort_reports=[Path("engineer.md"), Path("di.md")],
    source_files=[Path("v_file.html")],
    backend="deepseek",
    deliverable_path="ag1_meta.md",
))

Backends

Name Cost Concurrency cap (practical) Auth env var
kimi Subscription (zero marginal) 5–10 local (uses Kimi CLI; needs kimi login)
deepseek Pay-per-token 50+ via API DEEPSEEK_API_KEY; honors DEEPSEEK_MODEL env (default deepseek-chat)
qwen Pay-per-token 50+ via API QWEN_API_KEY or OPENROUTER_API_KEY; honors QWEN_MODEL env
claude Premium (paid) Anthropic rate limits ANTHROPIC_API_KEY; optional install

Custom backends: subclass xaxiu_swarm.Backend and pass an instance directly to dispatch/swarm.

Hybrid tier strategy

Empirically validated: chat-tier cohort workers + premium-tier AG#1 is cheaper AND higher-signal than all-premium. Chat's enumerative style produces noise; pro AG#1 sifts it. The disagreement IS the signal. See docs/VALIDATION_v4pro_vs_chat_quality.md for the head-to-head comparison.

# Hybrid: chat for cohort, pro for AG#1 (recommended for hotfixes / standard waves)
DEEPSEEK_MODEL=deepseek-chat xaxiu-swarm swarm pkt1.md pkt2.md pkt3.md --backends kimi,deepseek,deepseek
xaxiu-swarm ag1 --subject "..." --report ... --backend deepseek  # uses DEEPSEEK_MODEL=v4-pro from env

Output artifacts

Per run, written under <state_dir>/<run_id>/:

  • swarm.json — live worker statuses (read while running for HUD)
  • audit/<worker_id>_*.jsonl — per-worker audit log (prompt + response + timing + tokens)
  • audit/swarm_summary_*.jsonl — final summary
  • worktrees/<worker_id>/ — only for worktree_swarm; cleaned per cleanup policy

When NOT to use

  • Need DAG dependencies (chained tools, conditional branches) → use LangGraph
  • Need long-running with mid-stream checkpointing/recovery → use Temporal or LangGraph
  • Need event-driven / reactive agents → use a queue framework
  • Need multi-turn interactive refinement → use the agent's interactive mode (Kimi/Claude/etc.) directly, not --print

Documentation

See docs/ for validation reports covering:

  • v0.2 G16+G17 validation (V_CONV4d cohort A/B with eliminated DeepSeek hallucinations)
  • C1 worktree codemod test (4 parallel workers; cherry-pick merge-back)
  • D high-N stress test (8 Kimi concurrent workers under 60s wall)
  • E cross-project portability (clean install in isolated venv)
  • v0.2.3 4-test workload validation
  • v0.2.4 G31 <PROVIDER>_MODEL env var fix + 3-parallel test
  • v4-pro vs deepseek-chat quality A/B (multi-agent conformity bias)
  • xaxiu-swarm vs kimi_dispatch.py legacy comparison

Status

v0.3.0 — Beta. 35/35 unit tests pass; battle-tested across 9 production waves on a single project. API surface stable; expect minor additions in v0.3.x. Path to v1.0: 3+ months of cross-project use, more backends as needs surface, possibly LangGraph adapter for DAG-shape work.

Contributing

PRs welcome. Repo is small enough to read end-to-end; please match the existing patterns:

  • Backends never raise; always return DispatchResult(status="failed", ...) on error
  • All Path resolution honors cwd kwarg when set (G26 pattern)
  • Public APIs documented in module docstring; CLI flags in cli.py add helper text

License

MIT — see LICENSE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

xaxiu_swarm-0.3.3.tar.gz (41.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

xaxiu_swarm-0.3.3-py3-none-any.whl (44.5 kB view details)

Uploaded Python 3

File details

Details for the file xaxiu_swarm-0.3.3.tar.gz.

File metadata

  • Download URL: xaxiu_swarm-0.3.3.tar.gz
  • Upload date:
  • Size: 41.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.13

File hashes

Hashes for xaxiu_swarm-0.3.3.tar.gz
Algorithm Hash digest
SHA256 bf047f808055d8d69b112f233addd0fde4daf523449bf33f25b355f16674a186
MD5 9257b68376923ac7d2b221c0394077f4
BLAKE2b-256 c738dbcf54a7340da9d2f00e8a6ae9cba6d700e87f42127ed08f07e74c305673

See more details on using hashes here.

File details

Details for the file xaxiu_swarm-0.3.3-py3-none-any.whl.

File metadata

  • Download URL: xaxiu_swarm-0.3.3-py3-none-any.whl
  • Upload date:
  • Size: 44.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.13

File hashes

Hashes for xaxiu_swarm-0.3.3-py3-none-any.whl
Algorithm Hash digest
SHA256 9944e055a76ab8ebfe294dfba4bdbbf32fcd2114b0c099f235fb8545e03cb31c
MD5 53206bcc84a1328edb823407143df559
BLAKE2b-256 66c47b67f4f2e674aa41d0cc009b8948f2394d7035d93235ed3312bd47d2b813

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page