Channels Queues And Workflows channels-queues-and-workflows
Design and run Paperclip channel queues, inboxes, and multi-agent workflows with leases, assign, handoff, CAS labels, DAG deps, and human gates.
- Our test
- —
- not tested yet
- GitHub stars
- 120k
- paperclipai/paperclip
- Added by
- 0
- members
- Updated
- Dec 6
- commit 52a1dfb
- Content
- 2 files
- no scripts · 17 KB
- License
- MIT
- free to use
What our test found
Not tested yet. Our model tries every skill on a realistic request and scores the result, the most popular skills first. Until then, the safety checks on the right still apply.
name: channels-queues-and-workflows description: Design and run Paperclip channel queues, inboxes, and multi-agent workflows with leases, assign, handoff, CAS labels, DAG deps, and human gates.
Channels, Queues, and Workflows
Use Paperclip's channel, queue, lease, handoff, label, and dependency primitives to coordinate multi-agent work without heavy setup or custom glue.
Core Mental Model
Four primitives cover every queue and workflow pattern:
- Channel = lightweight folder / room of Issues.
- Created lazily on first write (
pc post,pc tasks create). Supports nested slash paths (seo/briefs,factory/build); trailing/queries the whole subtree (seo/). - Separate from Projects: a Project binds execution infrastructure (Git repos, sandboxes, secrets); a Channel is just a stream/queue. They compose cleanly (
--projectis optional per task or channel default). - Administer channel queue policy, archive state, private membership, or managed-pool auto-drain anytime with
pc channels update <path>(aliasconfig) andpc channels members list|add|remove <path>. - Post vs. Task = the same `Issue` object.
pc post <channel> "<text>"creates an unassignedstatus=backlogissue (scope=channel). Defaultclaim --readyignores it.pc tasks create <channel> "<text>"creates an unassignedstatus=todoissue (scope=channel). Workers can claim it immediately.pc tasks create <existing-id>(orpc tasks assign <id> @agent) promotes abacklogpost totodoin place, keeping its ID (PAP-142) and full thread history.- Queue = pullable slice of ready issues (Pull vs. Push).
- No separate Queue resource is required. Any channel with ready issues is a queue.
- Pull (`pc tasks claim --ready <channel>`): Pops the next matching task atomically (
FOR UPDATE SKIP LOCKED), setsstatus=in_progress, and grants a 5-minute TTL lease + fencedclaimToken. - Safe default:
status=todo+unassigned. - Opt-in filters: Pass
--status backlog(e.g., triage bot draining raw inbox posts) or--status in_review(review pool — automatically excludes tasks waiting on pending human interaction cards). Pass--mine(--assignee me) to claim tasks pushed to you, or--assignee anyfor unassigned + yours (never steals another agent's assigned task). - Push (`pc tasks assign <id> @agent`): Assigns an existing post/task to a registered Paperclip agent (auto-promoting
backlog→todounless--keep-status) and wakes it via Paperclip's managed Runner. Use--unassignto return a task to the unassigned pool, or--forceto fence an active worker lease. - Managed Pool Auto-Drain: Bind a managed agent directly to a channel (
pc channels update factory/build --managed-pool @coder --max-concurrency 4) so Paperclip's control plane automatically assigns and wakes up toNconcurrent tasks without an external bash loop. - Key-Value Labels (`kv_labels`) = routing and lock-free state.
- Slice any queue with
--label key=value(--label role=reviewer,--label stage=draft). - Guard state transitions with atomic Compare-And-Swap (
--if/--if-unset):pc label PAP-50 stage=draft --if stage=newreturns409 label_conflictif another agent already transitioned it.
Queue & Inbox Patterns
1. Direct Work Queue (Drop & Drain)
Use when every dropped item is immediately actionable by a pool of fungible workers.
# Producers drop work in (human, cron, webhook, or lead agent)
pc tasks create triage/bugs "Fix 500 on /api/checkout" --priority high --label role=fixer
# Pool of workers drains in parallel (auto-renews lease, releases on Ctrl-C)
pc tasks run --ready triage/bugs --label role=fixer --wait 10m --as worker-1 \
-- claude -p 'Read $PAPERCLIP_TASK_ID with pc read, fix it, verify, and reply.'2. Two-Step Inbox (Passive Drop → Triage → Promote or Assign)
Use when raw signals are noisy (alerts, external requests, ideas) and should not burn worker tokens until triaged.
# 1. Drop raw signal as passive backlog post (zero worker wakeups)
pc post errors/web "500 spike on /api/checkout (14 occurrences in 5m)"
# 2. Optional: a lightweight triage bot pops raw backlog posts with --status backlog
pc tasks claim --ready errors/web --status backlog --as triage-bot
# 3. Promote to a worker pool OR push-assign directly to a managed agent:
pc tasks create PAP-142 --priority high --label role=fixer
# ...or push to a named Paperclip agent (auto-promotes backlog -> todo and wakes @backend-eng):
pc tasks assign PAP-142 @backend-eng --comment "Confirmed nil stripeCustomerId"Multi-Agent Workflow Patterns
Choose one of three patterns (or combine them) based on the shape of the work:
Pattern A: Single-Thread Relay (Atomic handoff Across Stages or Channels)
Use when: One unit of work (a support ticket, PR, or article) moves sequentially through specialists and every specialist needs the entire conversation history in one thread.
Use `pc tasks handoff` (alias `move`) to atomically move channels, update labels (with optional --if CAS), change status/assignee, and release the active lease in one transaction:
# Writer finishes draft and atomically hands off PAP-50 to #seo/review with CAS guard
pc tasks handoff PAP-50 --channel seo/review \
--label stage=review --if stage=draft \
--comment "Draft ready for fact-check" --as writer-1You can also keep the issue in a single channel and omit --channel, or push-assign the next stage directly (--assignee @qa-reviewer).
Pattern B: Assembly Line (Chained Channels with 1-to-Many Fan-Out)
Use when: Stages produce distinct artifacts, have 1-to-many fan-out (1 audit → 5 fix tasks, 1 topic → 3 briefs), or need separate queue policies/permissions per stage.
- Give each stage its own channel:
#seo/topics→#seo/briefs→#seo/drafts→#seo/publish. - A worker pops from Stage $N$, produces its artifact, creates one or more
todotasks in Stage $N+1$ (linking back to the source ID), and marks its Stage $N$ taskdone. pc channels --prefix seo/surfaces queue depth and bottlenecks at every stage.
Pattern C: DAG Fan-Out / Fan-In (plan.json + Mid-Flight --needs)
Use when: The dependency graph is known up front (feature launches, multi-repo refactors) OR a worker discovers a new prerequisite mid-flight.
- Up-front DAG:
pc tasks create <channel> --file plan.json --idempotency-key <key>. Tasks with"needs": ["keyA", "keyB"]sit inWaitinguntil every dependency reachesdone, then flipReadyautomatically. - Mid-flight prerequisite: If a worker claims
PAP-142and discovers it needsPAP-150done first, park it without losing auto-wakeup: ``bash pc tasks block PAP-142 --needs PAP-150 "Waiting on schema migration" --as worker-1 # Releases lease and parks PAP-142 in todo (Waiting). Auto-becomes Ready when PAP-150 completes!`` - Inspect or edit dependencies anytime with
pc tasks deps list|add|remove <id>.
Lifecycle & Workflow Glue
- Non-Blocking Human Gates (`pc ask` / `pc confirm`): Posts a typed interactive card, moves the task to
in_review, and releases the worker's lease. When the human answers or clicks Approve (--human), Paperclip automatically flips the task back totodo(Ready) for the pool. - Cancel & Reopen: Cancel duplicate/obsolete tasks with
pc tasks cancel <id> "Duplicate of PAP-110"(use--forceto fence another worker's lease), and reopendone/cancelled/blockedtasks withpc tasks reopen <id>. - Typed Stage Contracts (`--schema` & `--result-schema`): Attach
--schema finding@1on posts/replies for validated JSON alongside Markdown prose, or--result-schema content-brief@1on tasks sopc tasks complete <id> --data '{...}'enforces the JSON contract beforedone.
Decision Cheat Sheet
| Goal | Primitive / Command | Example | | :--- | :--- | :--- | | Group a stream or create a distinct stage queue | Channel | #seo/drafts, #factory/build | | Log/discuss before deciding whether to run agents | Passive Post (`pc post`) | #errors/web → promote or --status backlog | | Pull next ready task from a pool (or your own assigned) | `pc tasks claim` | pc tasks claim --ready build/ --mine | | Push an existing post/task to a managed Paperclip agent | `pc tasks assign` | pc tasks assign PAP-142 @backend-eng | | Atomically move channel + update labels + drop lease | `pc tasks handoff` (`move`) | pc tasks handoff PAP-50 --channel seo/review --label stage=review | | Park a task waiting on a newly discovered blocker | `pc tasks block --needs` | pc tasks block PAP-142 --needs PAP-150 | | Cancel or reopen a task | `pc tasks cancel` / `reopen` | pc tasks cancel PAP-9 "Duplicate" | | Auto-drain a channel with a managed Paperclip agent | `pc channels update` | pc channels update build --managed-pool @coder --max-concurrency 4 | | Manage --private channel access | `pc channels members` | pc channels members add sec/private @sec-bot | | Pause for human decision without blocking a worker | `pc ask` / `pc confirm` | Drops lease → human resolves → auto-requeues | | Bind a Git repo, sandbox, and secrets | Project (`--project`) | #factory/build + --project web-app |
Additional Resources
- For complete end-to-end recipes (Software Factory, Customer Service Review, SEO/AEO Content Engine, and Feature Launch Campaign), see .