Agent Skillsmonotykamary/pi-fabric › fabric-swarm

fabric-swarm

GitHub

创建自组织持久化 Agent 团队,支持通过 durable topics 和 CAS 机制处理长周期协作任务。适用于构建具备依赖管理、状态同步及消息路由能力的分布式多智能体系统。

skillsets/python/fabric-swarm/SKILL.md monotykamary/pi-fabric

Trigger Scenarios

需要构建多 Agent 协作流程 实现基于持久化 Actor 的分布式任务编排

Install

npx skills add monotykamary/pi-fabric --skill fabric-swarm -g -y
More Options

Non-standard path

npx skills add https://github.com/monotykamary/pi-fabric/tree/main/skillsets/python/fabric-swarm -g -y

Use without installing

npx skills use monotykamary/pi-fabric@fabric-swarm

指定 Agent (Claude Code)

npx skills add monotykamary/pi-fabric --skill fabric-swarm -a claude-code -g -y

安装 repo 全部 skill

npx skills add monotykamary/pi-fabric --all -g -y

预览 repo 内 skill

npx skills add monotykamary/pi-fabric --list

SKILL.md

Frontmatter
{
    "name": "fabric-swarm",
    "description": "Creates a self-organizing team of persistent Pi Fabric actors with durable topics, mailboxes, and compare-and-swap tasks. Use for messenger-like collaboration and long-lived delegated work.",
    "disable-model-invocation": true
}

Fabric Swarm — Python

Build from persistent actors and durable mesh primitives, not an external swarm extension. Pass payloads.run, JSON payloads.tasks (id, title, detail, optional dependencies), and JSON payloads.roles (name, instructions). Choose a fresh run key; seed with ifVersion=0.

Actor instructions must require: verify dependencies are complete; claim only ready tasks with the observed version; stop after a failed claim; publish progress; update blocked/completed state using each successful operation's returned version; CAS-unblock dependents only when all dependencies complete; direct questions via mesh.publish(topic=..., to=...); respect path ownership; emit directives only for blockers/final results.

import json
run = π.run
topic = "team." + run
tasks = json.loads(π.tasks)
roles = json.loads(π.roles)
seeded = []
actors = []
dispatched = []
try:
    for task in tasks:
        value = dict(task)
        value.update({"dependencies": task.get("dependencies", []), "status": "blocked" if task.get("dependencies") else "ready", "owner": None, "progress": [], "result": None})
        await mesh.put(key="runs/" + run + "/tasks/" + task["id"], value=value, ifVersion=0)
        seeded.append(task["id"])
    for role in roles:
        actor = await agents.create(name=role["name"], runner="pi", instructions=role["instructions"], topics=[topic], responseMode="directive", delivery="mailbox", coalesce=False)
        actors.append({"id": actor["id"], "name": actor["name"]})
    for actor in actors:
        await agents.tell(id=actor["id"], message="Join " + topic + ". Inspect ready tasks under runs/" + run + "/tasks/ and atomically claim one matching your role.")
        dispatched.append(actor["id"])
    await mesh.publish(topic=topic, kind="run.started", data={"run": run, "actors": actors})
    return {"status": "success", "run": run, "topic": topic, "actors": actors, "taskPrefix": "runs/" + run + "/tasks/"}
except Exception as error:
    return {"status": "partial" if seeded or actors else "failed", "run": run, "topic": topic, "seeded": seeded, "actors": actors, "dispatched": dispatched, "error": str(error)}

Seeding, actor creation, and dispatch are sequential so failures retain exact completed identities. On partial setup, inspect state/mailboxes before retrying; never automatically replay successful creation or messages. Keep coordination pull-based at decision points, not continuous polling. Persistent actors receive tell/ask; agents.steer redirects running one-shot workers. Do not return transcripts or task bodies unnecessarily.

Version History

  • 88c505b Current 2026-09-08 19:27

Same Skill Collection

skills/fabric-advisor/SKILL.md
skills/fabric-ambient/SKILL.md
skills/fabric-council/SKILL.md
skills/fabric-exec/SKILL.md
skills/fabric-fusion/SKILL.md
skills/fabric-guide/SKILL.md
skills/fabric-rlm/SKILL.md
skills/fabric-schema/SKILL.md
skills/fabric-spec/SKILL.md
skills/fabric-supervisor/SKILL.md
skills/fabric-swarm/SKILL.md
skills/fabric-workflow/SKILL.md
skillsets/python/fabric-advisor/SKILL.md
skillsets/python/fabric-ambient/SKILL.md
skillsets/python/fabric-council/SKILL.md
skillsets/python/fabric-exec/SKILL.md
skillsets/python/fabric-fusion/SKILL.md
skillsets/python/fabric-guide/SKILL.md
skillsets/python/fabric-rlm/SKILL.md
skillsets/python/fabric-schema/SKILL.md
skillsets/python/fabric-spec/SKILL.md
skillsets/python/fabric-supervisor/SKILL.md
skillsets/python/fabric-workflow/SKILL.md
skillsets/typescript/fabric-advisor/SKILL.md
skillsets/typescript/fabric-ambient/SKILL.md
skillsets/typescript/fabric-council/SKILL.md
skillsets/typescript/fabric-exec/SKILL.md
skillsets/typescript/fabric-fusion/SKILL.md
skillsets/typescript/fabric-guide/SKILL.md
skillsets/typescript/fabric-rlm/SKILL.md
skillsets/typescript/fabric-schema/SKILL.md
skillsets/typescript/fabric-spec/SKILL.md
skillsets/typescript/fabric-supervisor/SKILL.md
skillsets/typescript/fabric-swarm/SKILL.md
skillsets/typescript/fabric-workflow/SKILL.md

Metadata

Files
0
Version
88c505b
Hash
f7caabc9
Indexed
2026-09-08 19:27

inicio - Wiki
Copyright © 2011-2026 iteam. Current version is 2.155.2. UTC+08:00, 2026-09-09 01:16
浙ICP备14020137号-1 $mapa de visitantes$