dev-task-queue
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseAgent Task Queue
Agent任务队列
Persistent, cross-session task queue for AI agents aligned with the Claude Code Tasks schema. Tasks survive beyond sessions, carry full context including conversation transcripts, and support dependency tracking with blocks/blockedBy. Backed by a git repo with move-based locking for conflict-free multi-agent access.
符合Claude Code Tasks schema的AI Agent跨会话持久化任务队列。任务可跨会话留存,包含对话记录在内的完整上下文,并支持通过blocks/blockedBy进行依赖追踪。基于Git仓库实现,采用基于移动的锁机制,确保多Agent无冲突访问。
Prerequisites
前置条件
Clone the task queue repository:
bash
git clone git@github.com:OlechowskiMichal/agent-task-queue.git ~/.agent-task-queueAll commands below assume the repo is at .
~/.agent-task-queue克隆任务队列仓库:
bash
git clone git@github.com:OlechowskiMichal/agent-task-queue.git ~/.agent-task-queue以下所有命令均假设仓库路径为。
~/.agent-task-queueQuick Reference
快速参考
| Operation | Command | Description |
|---|---|---|
| Add | | Create a new task |
| List | | List/filter tasks |
| Claim | | Claim a pending task |
| Complete | | Mark task done |
| Release | | Unclaim a task |
| Reassign | | Reassign to different agent |
| Index | | Regenerate root index |
| Prune | | Archive old tasks |
| 操作 | 命令 | 说明 |
|---|---|---|
| 添加 | | 创建新任务 |
| 列出 | | 列出/筛选任务 |
| 认领 | | 认领待处理任务 |
| 完成 | | 标记任务完成 |
| 释放 | | 取消任务认领 |
| 重新分配 | | 重新分配给其他Agent |
| 生成索引 | | 重新生成根索引 |
| 清理 | | 归档旧任务 |
Adding a Task
添加任务
Save a task for a future agent session:
bash
python3 ~/.agent-task-queue/scripts/add_task.py \
--assignee go-expert \
--subject "Fix error handling in API middleware" \
--description "The error handler swallows context. Wrap errors with fmt.Errorf." \
--priority high \
--project my-api \
--tags "error-handling,api" \
--active-form "Fixing error handling" \
--ttl-hours 48 \
--blocked-by "3,7" \
--context-repo "git@github.com:OlechowskiMichal/my-api.git" \
--context-files "pkg/middleware/error.go,pkg/middleware/error_test.go" \
--context-notes "See issue #42 for the original bug report"The script reads to assign the next monotonic integer ID, writes the task JSON to , regenerates the root index, and pushes to the repo.
.highwatermarkpending/{id}.json为未来的Agent会话保存任务:
bash
python3 ~/.agent-task-queue/scripts/add_task.py \
--assignee go-expert \
--subject "Fix error handling in API middleware" \
--description "The error handler swallows context. Wrap errors with fmt.Errorf." \
--priority high \
--project my-api \
--tags "error-handling,api" \
--active-form "Fixing error handling" \
--ttl-hours 48 \
--blocked-by "3,7" \
--context-repo "git@github.com:OlechowskiMichal/my-api.git" \
--context-files "pkg/middleware/error.go,pkg/middleware/error_test.go" \
--context-notes "See issue #42 for the original bug report"该脚本读取文件来分配下一个递增整数ID,将任务JSON写入,重新生成根索引并推送到仓库。
.highwatermarkpending/{id}.jsonListing Tasks
列出任务
bash
undefinedbash
undefinedAll pending tasks for an agent
某Agent的所有待处理任务
python3 ~/.agent-task-queue/scripts/list_tasks.py --agent go-expert --status pending
python3 ~/.agent-task-queue/scripts/list_tasks.py --agent go-expert --status pending
Stale tasks (claimed but exceeded TTL)
过期任务(已认领但超出TTL)
python3 ~/.agent-task-queue/scripts/list_tasks.py --stale
python3 ~/.agent-task-queue/scripts/list_tasks.py --stale
Blocked tasks (unmet dependencies)
被阻塞的任务(依赖未满足)
python3 ~/.agent-task-queue/scripts/list_tasks.py --blocked
python3 ~/.agent-task-queue/scripts/list_tasks.py --blocked
Tasks for a specific project
特定项目的任务
python3 ~/.agent-task-queue/scripts/list_tasks.py --project my-api
python3 ~/.agent-task-queue/scripts/list_tasks.py --project my-api
Tasks created after a date
指定日期后创建的任务
python3 ~/.agent-task-queue/scripts/list_tasks.py --since 2026-03-01
undefinedpython3 ~/.agent-task-queue/scripts/list_tasks.py --since 2026-03-01
undefinedClaiming a Task
认领任务
Start working on a pending task:
bash
python3 ~/.agent-task-queue/scripts/claim_task.py 1 --session-id $(uuidgen)The script:
- Verifies all dependencies are completed
blockedBy - Moves the task from to
pending/active/ - Sets and
ownermetadata.claimed_at - Updates to
statusin_progress - Pushes with conflict detection — if another agent claimed it first, the push fails
开始处理待处理任务:
bash
python3 ~/.agent-task-queue/scripts/claim_task.py 1 --session-id $(uuidgen)该脚本执行以下操作:
- 验证所有依赖项均已完成
blockedBy - 将任务从移动到
pending/active/ - 设置和
owner字段metadata.claimed_at - 将更新为
statusin_progress - 推送并检测冲突 —— 如果其他Agent已先认领该任务,推送会失败
Completing a Task
完成任务
bash
python3 ~/.agent-task-queue/scripts/complete_task.py 1 \
--session-id "$SESSION_ID" \
--jsonl-path "~/.claude/projects/.../conversation.jsonl" \
--notes "Fixed by wrapping errors with context in middleware chain"The task moves to with the conversation transcript reference appended.
completed/YYYY-MM/{id}.jsonbash
python3 ~/.agent-task-queue/scripts/complete_task.py 1 \
--session-id "$SESSION_ID" \
--jsonl-path "~/.claude/projects/.../conversation.jsonl" \
--notes "Fixed by wrapping errors with context in middleware chain"任务会被移动到,并附加对话记录引用。
completed/YYYY-MM/{id}.jsonReleasing a Task
释放任务
If you cannot finish a claimed task:
bash
python3 ~/.agent-task-queue/scripts/release_task.py 1Moves back to with and reset to so the next agent knows it was attempted.
pending/metadata.previously_claimed=truestatuspending如果无法完成已认领的任务:
bash
python3 ~/.agent-task-queue/scripts/release_task.py 1任务会被移回,同时设置,重置为,以便后续Agent知晓该任务曾被尝试处理。
pending/metadata.previously_claimed=truestatuspendingReassigning a Task
重新分配任务
Transfer a task to a different agent type:
bash
python3 ~/.agent-task-queue/scripts/reassign_task.py 1 --to re-expertThis is a metadata-only update — it sets to the new agent. No file move occurs. The task stays in its current directory ( or ).
metadata.assigneepending/active/将任务转移给其他类型的Agent:
bash
python3 ~/.agent-task-queue/scripts/reassign_task.py 1 --to re-expert这只是元数据更新 —— 将设置为新的Agent,不会移动文件。任务会保留在当前目录(或)。
metadata.assigneepending/active/Dependency Management
依赖管理
Tasks support bidirectional dependency tracking via and fields, aligned with the Claude Code Tasks schema.
blocksblockedBy- blockedBy: Array of task IDs that must be completed before this task can be claimed. enforces this — it refuses to claim a task with unresolved blockedBy entries.
claim_task.py - blocks: Array of task IDs that are waiting on this task. When a task is completed, the system can check whether downstream tasks are now unblocked.
Both sides are kept in sync: adding task 5 to the of task 8 also adds task 8 to the of task 5.
blockedByblocksCycle detection runs at add time and at claim time. If adding a dependency would create a circular chain (e.g., A blocks B blocks A), the operation is rejected with an error.
bash
undefined任务支持通过和字段实现双向依赖追踪,与Claude Code Tasks schema保持一致。
blocksblockedBy- blockedBy:必须先完成的任务ID数组,只有这些任务完成后才能认领当前任务。会强制执行此规则 —— 拒绝认领存在未解决blockedBy项的任务。
claim_task.py - blocks:等待当前任务完成的任务ID数组。当任务完成后,系统可检查下游任务是否已解除阻塞。
两者会保持同步:将任务5添加到任务8的中,同时会将任务8添加到任务5的中。
blockedByblocks循环检测会在添加任务和认领任务时运行。如果添加依赖会形成循环链(例如A阻塞B,B阻塞A),操作会被拒绝并返回错误。
bash
undefinedAdd a task that depends on tasks 3 and 7
添加一个依赖任务3和7的任务
python3 ~/.agent-task-queue/scripts/add_task.py
--subject "Deploy after migrations"
--blocked-by "3,7"
--subject "Deploy after migrations"
--blocked-by "3,7"
python3 ~/.agent-task-queue/scripts/add_task.py
--subject "Deploy after migrations"
--blocked-by "3,7"
--subject "Deploy after migrations"
--blocked-by "3,7"
List all currently blocked tasks
列出所有当前被阻塞的任务
python3 ~/.agent-task-queue/scripts/list_tasks.py --blocked
undefinedpython3 ~/.agent-task-queue/scripts/list_tasks.py --blocked
undefinedRace Condition Handling
竞争条件处理
All scripts use push-reject, pull-rebase, retry (once). If a claim push is rejected after rebase, it means another agent already claimed the task. The script exits with an error message.
所有脚本均采用“推送-拒绝、拉取-变基、重试(一次)”的机制。如果认领推送在变基后被拒绝,说明其他Agent已先认领该任务,脚本会输出错误信息并退出。
Conversation Linking
对话关联
Link Claude Code conversation transcripts to tasks when completing:
- Pass with the path to the
--jsonl-pathtranscript file.jsonl - The path is stored in the task's array
metadata.conversations - Multiple sessions can contribute to the same task
完成任务时可将Claude Code对话记录与任务关联:
- 通过参数传入
--jsonl-path对话记录文件路径.jsonl - 路径会被存储在任务的数组中
metadata.conversations - 多个会话可贡献到同一个任务
Staleness Detection
过期检测
Tasks have a field (default: 24). A claimed task is stale when . Find stale tasks with flag. Release stale tasks manually with .
metadata.ttl_hoursmetadata.claimed_at + ttl_hours < now--stalerelease_task.py任务包含字段(默认值:24)。当时,已认领的任务会被标记为过期。可通过参数查找过期任务,使用手动释放过期任务。
metadata.ttl_hoursmetadata.claimed_at + ttl_hours < 当前时间--stalerelease_task.pyPruning Completed Tasks
清理已完成任务
Remove old completed tasks:
bash
undefined移除旧的已完成任务:
bash
undefinedDry run — show what would be deleted
试运行 —— 显示会被删除的内容
python3 ~/.agent-task-queue/scripts/prune_completed.py --older-than 90d
python3 ~/.agent-task-queue/scripts/prune_completed.py --older-than 90d
Actually delete
实际执行删除
python3 ~/.agent-task-queue/scripts/prune_completed.py --older-than 90d --execute
undefinedpython3 ~/.agent-task-queue/scripts/prune_completed.py --older-than 90d --execute
undefinedTask Schema
任务Schema
See references/task-schema.md for the full JSON schema with field descriptions.
完整的JSON Schema及字段说明请查看references/task-schema.md。
Directory Layout
目录结构
agent-task-queue/
├── .highwatermark # Monotonic ID counter (single integer)
├── pending/ # Flat — no agent subdirs
│ └── {id}.json
├── active/
│ └── {id}.json
├── completed/
│ └── YYYY-MM/
│ └── {id}.json
├── index.md # Single root index
├── scripts/
│ ├── _lib.py
│ ├── add_task.py
│ ├── claim_task.py
│ ├── complete_task.py
│ ├── list_tasks.py
│ ├── release_task.py
│ ├── reassign_task.py
│ ├── render_index.py
│ └── prune_completed.py
├── AGENTS.md
├── CLAUDE.md
├── TODO.md
└── README.mdagent-task-queue/
├── .highwatermark # 递增ID计数器(单个整数)
├── pending/ # 待处理任务目录(无Agent子目录)
│ └── {id}.json
├── active/
│ └── {id}.json
├── completed/
│ └── YYYY-MM/
│ └── {id}.json
├── index.md # 根索引文件
├── scripts/
│ ├── _lib.py
│ ├── add_task.py
│ ├── claim_task.py
│ ├── complete_task.py
│ ├── list_tasks.py
│ ├── release_task.py
│ ├── reassign_task.py
│ ├── render_index.py
│ └── prune_completed.py
├── AGENTS.md
├── CLAUDE.md
├── TODO.md
└── README.md