Repository navigation
Agent teams: shared crew task list, worker peer messaging, and loop guardrails (#277) - #407
Merged
currentbits merged 10 commits intoAug 17, 2026
Conversation
Tasks belong to the crew ROOT thread (walk handoffFrom while orchWorker), so every worker of one orchestration self-claims from the same list. Blocked-ness is derived from `needs`, never stored — completing a task unblocks its dependents with no second write to go stale. Loop guardrails: a task is refused after CREW_TASK_ATTEMPT_CAP claims, and crewTaskNoteFor forces a "what failed / am I repeating myself" reflection into the dispatch prompt whenever a held task was attempted before. Contract commit for the orchServer / runner / UI workers. Co-Authored-By: Claude Opus 5 <[email protected]>
Expose the shared crew task list and worker-to-worker messaging on coder-threads so agents can self-claim work and hand off artifacts without routing through the lead.
Read-only threads.crewTasks IPC so the human can see who holds what. The Agents tab lists each task with status (including blocked), owner title, done note, and retry count. Empty crews render nothing.
Generalize orchNotices into deliverNotice so peer/unblock lines share the worker-finished wake-up path. Cap consecutive machine-delivered turns at CREW_AUTO_TURN_CAP, wire crewTaskNoteFor into dispatch, and release claimed crew tasks on a failed turn.
…into coder/worker-peer-messaging-and-a-shared-task--ca6e83
Co-Authored-By: Claude Opus 5 <[email protected]>
The browser fixture's active thread carries a workflow, so the list was invisible there. Same card, same rows.
…into coder/worker-peer-messaging-and-a-shared-task--ca6e83
The MCP tools and the notice delivery were each written against a fake of the other. This drives the real handlers against a real runner: peer_send starts a run on the peer without touching the lead, task_complete wakes the crew root naming what it unblocked, and a released claim carries the failure to the next claimer. Co-Authored-By: Claude Opus 5 <[email protected]>
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
…saging-and-a-shared-task--ca6e83 # Conflicts: # electron/runner.js
currentbits
deleted the
coder/worker-peer-messaging-and-a-shared-task--ca6e83
branch
October 3, 2026 16:07
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #277.
Today every worker in an orchestration talks only to the lead: the lead hands out work, and any artifact one worker produces for another goes back up and down through the orchestrator's chat history. This adds the three pieces that let a crew coordinate directly, plus the guardrails that keep an autonomous crew from spinning.
Shared task list
A crew is the thread at the top of the
handoffFromchain plus everyorchWorkerunder it (services.crewRootOf, cycle- and depth-guarded). That root id keys one list instore.tasksByCrew, so every worker of one orchestration self-claims from the same board instead of waiting to be assigned.Agents drive it through the coder-threads MCP server:
task_add,task_list,task_claim(omittaskIdto take the next unblocked task),task_complete,task_release.Dependency auto-unblocking is derived, never stored.
blockedis computed fromneedson every read, so completing a task opens its dependents with no second write that could go stale.completeCrewTaskreturns exactly the tasks that just became claimable, and that list is what wakes the crew root. An unknown id inneedsis rejected attask_add— a typo must not block a task forever.Peer messaging
peer_send({ toThreadId, message })starts a run on the peer thread directly, so the backend worker hands the frontend worker the API contract without a round trip through the lead. Both threads are checked against the caller's statedprojectId, the same guard the existing thread tools use.Delivery reuses the orchestrator wake-up queue rather than adding a second mechanism:
runner.deliverNotice({ threadId, line })isflushOrchNoticesgeneralized to any line, with the same rule (idle thread runs immediately, a busy one flushes at its own terminal). Worker-finished lines keep the[orchestration]prefix; caller-prefixed lines ([peer from …],[crew] finished t1 …) keep their own.Hand-offs as artifacts
No artifact registry, deliberately. Worktrees of one repo share a git object store, so the durable hand-off is: commit
contract.mdon your branch, put abranch:pathref in the task note or peer message, and the peer reads it withgit show <branch>:<path>. That convention is stated in the MCP instructions, which ride every agent dispatch — so hand-offs are documents in git, not chat history.Loop guardrails
All three are refusals, not advice:
CREW_TASK_ATTEMPT_CAP(3) — a fourth claim of the same task is refused and the crew has to escalate.attempts[]records who tried and what outcome each gave back.services.crewTaskNoteForrides every dispatch of a thread holding a task and, when that task was attempted before or the thread's own last run failed, forces a "what failed / am I repeating myself" answer before the retry rather than after the third one.CREW_AUTO_TURN_CAP(25) caps consecutive machine-delivered turns on one thread, refused through the same undeliverable path as the orchestration budget gate (event +failed+lastError). Any user-sent turn resets the counter.A failed run also releases that thread's claims with the error as the outcome, so a crashed worker never strands a task.
UI
threads:crewTasks(read-only — agents own the list) renders the crew's tasks in the Agents panel: id, title, a status/blocked pill, the owning thread, the note on a done task, and the attempt count once a task is on its second try.Testing
electron/test/crew-tasks.test.js— the data layer: shared visibility across the crew, derived blocking, claim/complete/release, the attempt cap, the reflection note.electron/test/orch-crew-tools.test.js— the MCP tool surface and its project guards.electron/test/crew-notices.test.js— delivery to an idle thread, queueing behind a running one, the auto-turn cap and its reset.electron/test/crew-seam.test.js— the real tool handlers against a real runner. The tools and the delivery were written in parallel against a fake of each other, so this is the only test that covers the join:peer_sendstarts a run on the peer and leaves the lead's transcript empty, andtask_completewakes the root naming what it unblocked.test/crewTasks.test.tsx— the panel.Suites: core 38/38, renderer 883/883, electron 1094 pass / 1 fail — that one being the pre-existing
web-integrationreconnect subtest, which fails onmaintoo.Architecture notes are in
docs/ARCHITECTURE.mdunder "Agent teams".🤖 Generated with Claude Code