← Back to Templates
poll-queue.sh · Shell + MD

Multi-Agent Cache Rules + 0-Token Local Poll Script

Put the rules in your coordination doc and run the shell script via cron/launchd every 5–10 minutes so agents only wake when work actually arrives.

# === Part 1: Token & Cache Coordination Rules ===
- Pin the coordinator to one primary model and fixed toolset (preserve 1-hour Prompt Cache).
- Schedule wakeups <= 55 minutes; hand off around ~300K context to avoid frequent cold-start tax.
- One fresh session per task; lightweight read-only subagents report in <= 10 lines.
- Split limit: never split trivial cleanup, max 1 generation; non-semantic wording edits self-approve.

# === Part 2: 0-Token Local Poll Script Skeleton (poll-queue.sh) ===
#!/usr/bin/env bash
set -euo pipefail

ROLE_LABEL="${1:-ready-for-software}"
STATE_FILE="/tmp/queue-seen-${ROLE_LABEL}.txt"
touch "$STATE_FILE"

# 1. Query ready tickets via lightweight CLI (zero LLM tokens)
ISSUES=$(your-tracker-cli list --label "$ROLE_LABEL" --status "To Do" --format id)

[ -z "$ISSUES" ] && exit 0

for KEY in $ISSUES; do
  if ! grep -qx "$KEY" "$STATE_FILE"; then
    echo "$KEY" >> "$STATE_FILE"
    echo "[wake] New ready ticket: $KEY -> dispatching agent..."
    # 2. Wake the matching role agent only when a new ticket arrives
    # your-agent-dispatch --role "$ROLE_LABEL" --ticket "$KEY"
  fi
done