Skip to content

Agent teams: shared crew task list, worker peer messaging, and loop guardrails (#277) - #407

Merged
currentbits merged 10 commits into
mainfrom
coder/worker-peer-messaging-and-a-shared-task--ca6e83
Aug 17, 2026
Merged

currentbits merged 10 commits into
mainfrom
coder/worker-peer-messaging-and-a-shared-task--ca6e83

Conversation

@currentbits

Copy link
Copy Markdown
Owner

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 handoffFrom chain plus every orchWorker under it (services.crewRootOf, cycle- and depth-guarded). That root id keys one list in store.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 (omit taskId to take the next unblocked task), task_complete, task_release.

Dependency auto-unblocking is derived, never stored. blocked is computed from needs on every read, so completing a task opens its dependents with no second write that could go stale. completeCrewTask returns exactly the tasks that just became claimable, and that list is what wakes the crew root. An unknown id in needs is rejected at task_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 stated projectId, 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 }) is flushOrchNotices generalized 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.md on your branch, put a branch:path ref in the task note or peer message, and the peer reads it with git 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.crewTaskNoteFor rides 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_send starts a run on the peer and leaves the lead's transcript empty, and task_complete wakes 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-integration reconnect subtest, which fails on main too.

Architecture notes are in docs/ARCHITECTURE.md under "Agent teams".

🤖 Generated with Claude Code

  • PR created by the Claude Code agent

Willem and others added 9 commits August 17, 2026 21:32
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
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]>
@chatgpt-codex-connector

Copy link
Copy Markdown

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
currentbits merged commit bc37775 into main Aug 17, 2026
1 check failed
@currentbits
currentbits deleted the coder/worker-peer-messaging-and-a-shared-task--ca6e83 branch October 3, 2026 16:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Worker peer messaging and a shared task list (agent teams)

1 participant