Skip to content

feat: add self-contained broker-backed issue swarm flow - #664

Merged
willwashburn merged 7 commits into
feat/agent-broker-sessionsfrom
feat/issue-swarm-flow
Oct 28, 2026
Merged

willwashburn merged 7 commits into
feat/agent-broker-sessionsfrom
feat/issue-swarm-flow

Conversation

@willwashburn

@willwashburn willwashburn commented Oct 13, 2026 •

Copy link
Copy Markdown
Member

The self-contained issue-swarm flow turns labeled GitHub issues into worktrees and persistent broker implementers, opens PRs, and runs three adversarial review lenses. Exact-head GO verdicts gate readiness; findings and monitored CI/conflict/review-thread repairs return to the owning implementer through bounded messages. Sessions release before worktree cleanup; dirty worktrees remain for human recovery. The flow never merges.

Stacked on #663. Base: feat/agent-broker-sessions. Only examples/issue-swarm/ changes in this PR. The source deploys as-is and stays readable in the online editor.

The README documents inputs, prerequisites, manual deployment, review-round limits, monitor deadlines, and cleanup. All tests use fakes; no live broker, PTY, agent harness, or GitHub mutation was exercised.

The monitor waits for pending checks and unknown mergeability, sends actionable findings only, and refreshes after repairs. Recorded dirty-worktree refusal reports human attention; actual step failures propagate after cleanup. Empty issue bodies normalize to empty text.

Validation at head 6cd6aafb, stacked on broker 030245f6 (repository root unless noted):

$ npm --prefix packages/surface run build
npm notice run @relayflows/surface@2.0.50 build
npm notice run tsc

Exit 0.

$ npm --prefix examples/issue-swarm run typecheck
npm notice run typecheck
npm notice run tsc -p tsconfig.json

Exit 0.

Test command (working directory examples/issue-swarm):

node --experimental-strip-types --test --test-reporter=spec tests/*.test.ts

Captured output (exit 0):

✔ count bounds parallel issues; three broker reviewers per PR; releases before removing worktrees (2.487834ms)
✔ NO-GO findings go to the same implementer, followed by fresh review (1.120791ms)
✔ monitor sends CI and review-thread repairs, then captures fresh state (38.123833ms)
✔ pending checks and unknown mergeability wait without repair pushes (0.372041ms)
✔ a completed clean snapshot takes precedence over deadline expiry (0.303333ms)
✔ monitor fixes that push a new head trigger all three reviewers again (0.5875ms)
✔ a timed out message ends with human attention and releases its implementer (0.383791ms)
✔ a new head cannot inherit GO after the last review pass (0.315791ms)
✔ review exhaustion and unknown mergeability cannot become success at deadline (0.621125ms)
✔ zero monitor budget captures status but sends no monitor repair (4.646459ms)
✔ a failed lane waits for peers and still releases each returned session (0.553041ms)
✔ worktree creation failure still cleans up the successful sibling lane (48.049667ms)
✔ malformed reviewer result releases implementers and cannot produce GO (0.209958ms)
✔ release failures preserve that worktree and do not skip other cleanup (35.178792ms)
✔ dirty worktree is preserved and cleanup error reported (0.246291ms)
✔ empty issue list allocates no agents or worktrees (0.087917ms)
✔ title-only issues normalize null body without losing their identity (0.16525ms)
✔ invalid input fails before effects; label shell metacharacters stay quoted (41.366792ms)
✔ explicit foreign repo and a mismatched origin fail before allocating worktrees (0.1995ms)
✔ malformed, stale and contradictory verdicts fail closed (0.194209ms)
✔ captures current-head checks, newest status and final metadata read (1.054291ms)
✔ pages REST checks and GraphQL unresolved threads (0.500583ms)
✔ a later approval clears a changes-requested review but a comment does not (0.2135ms)
✔ rejects changing heads and incomplete GraphQL responses (0.343792ms)
✔ pending, stale checks, unknown mergeability, blocked state and stale review fail closed (0.124542ms)
✔ GraphQL repeated cursors and REST pagination exhaustion fail closed (1.1365ms)
✔ saved source runs with fakes after copying without sibling modules (164.516167ms)
ℹ tests 27
ℹ suites 0
ℹ pass 27
ℹ fail 0
ℹ cancelled 0
ℹ skipped 0
ℹ todo 0
ℹ duration_ms 505.0415

The branch lookup uses the documented gh pr list --head <branch> syntax. <owner>:<branch> is unsupported by GitHub CLI. Read-only confirmation:

$ gh pr list --repo AgentWorkforce/flows --head feat/issue-swarm-flow --json number,headRefName
[{"headRefName":"feat/issue-swarm-flow","number":664}]

🤖 Generated with Claude Code


Note

Low Risk
New example-only code under examples/issue-swarm/ with no core package changes; runtime risk is limited to operators who deploy the flow and grant broker agents push/PR-comment access.

Overview
Adds a new examples/issue-swarm example: a self-contained @relayflows/surface flow that turns labeled open GitHub issues into parallel implementation lanes (git worktrees, broker implementers with pr-comments), opens PRs, and runs three adversarial-review lenses per round.

Review GO/NO-GO JSON must match the current head; NO-GO findings route back to the same implementer via f.message when review rounds remain. A bounded monitor polls PR state (paginated checks, mergeability, unresolved threads) and triggers repairs without merging. Outcomes use success vs needs_human; implementers are **f.release**d before non-forced worktree cleanup.

The package includes README, issue-swarm.flow.ts (input validation, capturePr/blockers, orchestration), and 27 fake-context tests (flow, GitHub helpers, deployable single-file source).

Reviewed by Cursor Bugbot for commit 6cd6aaf. Bugbot is set up for automated code reviews on this repo. Configure here.


Agent Relay sessions

  • codex session 01a135d2 · opened via gh pr create · last active 2026-10-13

@coderabbitai

coderabbitai Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 0c5a8da3-0bb1-4588-90f1-5426e29b2de0
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-13T15:36:59.269951Z 0fd496b PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0fd496b707

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

const reviews = await settleAll(lenses.map(async lens => {
const result = await f.agent(`review-${issue}-${round}-${lens}`, {
transport: 'broker', cli, cwd, skills: ['adversarial-review'], keepAlive: false,
permissions: { accessPreset: 'readonly' }, timeout: options.timeout ?? '30m',

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Remove the unsupported broker permissions option

For every non-empty swarm, the first review fails before the reviewer starts because the broker path explicitly rejects any defined options.permissions in packages/sdk/src/authored-broker.ts. This call therefore throws agent_cli_unresolved, leaving the newly opened PR for human attention and preventing any lane from obtaining a GO verdict. Remove this option for broker reviewers or add broker support for it.

Useful? React with 👍 / 👎.

@capy-ai capy-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Capy found 2 potential issues (1 high, 1 medium).

View 1 other finding in Capy.

Open in Capy

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

if (!lane.agentName) throw new Error('Broker did not return implementer agentName');
const prs = JSON.parse(await f.run(`gh pr list --repo ${shellWord(repo)} --state open --head ${shellWord(lane.branch)} --json number`));
if (!Array.isArray(prs) || prs.length !== 1 || !Number.isSafeInteger(prs[0]?.number) || prs[0].number < 1) throw new Error(`Expected one open PR for ${lane.branch}`);
lane.pr = prs[0].number;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR lookup drops owner and slash

High Severity

Every lane branch is issue-swarm…/issue-N, but the open-PR lookup passes that ref to gh pr list --head without the owner: prefix GitHub's list API requires. A slash ref does not match owner:ref, so the lookup returns no PR and the lane fails after the implementer has already opened one.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 0fd496b. Configure here.

@capy-ai capy-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Capy found no issues.

View 1 other finding in Capy.

Open in Capy

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Session-Id: 01a135d2-3108-7c01-88be-f3119fa7e51f

Session-Id: 01a135d2-3108-7c01-88be-f3119fa7e51f

Session-Id: 01a135d2-3108-7c01-88be-f3119fa7e51f

Session-Id: 01a135d2-3108-7c01-88be-f3119fa7e51f
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Session-Id: 01a135d2-3108-7c01-88be-f3119fa7e51f

Session-Id: 01a135d2-3108-7c01-88be-f3119fa7e51f
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Session-Id: 01a135d2-3108-7c01-88be-f3119fa7e51f
@willwashburn
willwashburn force-pushed the feat/issue-swarm-flow branch from 1652e01 to 6cd6aaf Compare October 13, 2026 15:51

@capy-ai capy-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Capy found no issues.

View 2 other findings in Capy.

Open in Capy

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

There are 2 total unresolved issues (including 1 from previous review).

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 6cd6aaf. Configure here.

}

const now = async (f: Ctx): Promise<number> => {
const raw = (await f.run('node -p Date.now()', { timeout: '5s' })).trim();

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Journaled clock command is shell-invalid

High Severity

now runs node -p Date.now() through f.run, which executes under /bin/sh -c. Unquoted () is a shell syntax error, so the command never prints a timestamp. After implementers and reviewers finish, deadline setup throws a journal step failure instead of entering the monitor or completing with last-observed status. Tests compare the literal string and never execute it in a shell.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 6cd6aaf. Configure here.

@willwashburn
willwashburn added this pull request to stack #686 October 28, 2026 05:29
cursoragent and others added 2 commits October 28, 2026 14:10
Co-authored-by: Will Washburn <willwashburn@users.noreply.github.com>
The file dependency still named 2.0.50 after main's release commits landed
through the broker branch.

Co-authored-by: Will Washburn <willwashburn@users.noreply.github.com>
@greptile-apps

greptile-apps Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 3/5

[Medium impact] The flow can create and update pull requests in the operator's selected repository.

The PR should not merge until monitoring can start and parallel issue lanes can resume safely.

Fix All in CodexFindings

  1. P1 Monitoring never starts ▶
  2. P1 Parallel lanes can break resume ▶
Fix with agent prompt
### Issue 1
examples/issue-swarm/issue-swarm.flow.ts:undefined-257
`now()` runs `node -p Date.now()` without quoting the expression. `/bin/sh` rejects the parentheses before Node starts, so every run with matching issues fails when it starts monitoring-even when all PRs are ready. Use `node -p 'Date.now()'` and add a test that executes the generated command.

```suggestion
  const raw = (await f.run("node -p 'Date.now()'", { timeout: '5s' })).trim();
```

### Issue 2
examples/issue-swarm/issue-swarm.flow.ts:312-314
Each parallel issue lane makes several journaled calls after separate awaits, but the SDK assigns step IDs from one shared counter. If issue 2 finishes first during the original run and issue 1 finishes first during resume, their next calls receive different IDs. The SDK then rejects the resumed run with an admission conflict or `serial_replay_order_mismatch`. Agent names do not provide stable step IDs.

Give each lane its own durable child flow, or otherwise keep journaled call order stable across resume.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Summary

Adds a self-contained issue-swarm example that turns labeled issues into broker-backed implementation lanes.

  • Labeled issues get broker-backed pull requests with three review lenses.
  • The monitor checks current PR state and requests targeted repairs.
  • Implementers are released before worktrees are removed, leaving dirty work intact.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Labeled issues] --> B[Worktree and persistent implementer]
  B --> C[Open PR]
  C --> D[Three review lenses]
  D --> E{Current-head GO?}
  E -->|No, passes remain| F[Message owning implementer]
  F --> D
  E -->|Yes| G[Monitor checks and review threads]
  G -->|Repair needed| F
  G -->|Ready or deadline reached| H[Release implementers]
  E -->|Passes exhausted| H
  H --> I[Remove clean worktrees]
  I --> J[Report readiness or human attention]
Loading

Reviews (2) · Last reviewed commit: "Merge branch 'feat/agent-broker-sessions..." · Reviewed by Greptile

}

const now = async (f: Ctx): Promise<number> => {
const raw = (await f.run('node -p Date.now()', { timeout: '5s' })).trim();

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Monitoring never starts

now() runs node -p Date.now() without quoting the expression. /bin/sh rejects the parentheses before Node starts, so every run with matching issues fails when it starts monitoring—even when all PRs are ready. Use node -p 'Date.now()' and add a test that executes the generated command.

Suggested change
const raw = (await f.run('node -p Date.now()', { timeout: '5s' })).trim();
const raw = (await f.run("node -p 'Date.now()'", { timeout: '5s' })).trim();
Prompt To Fix With AI
This is a comment left during a code review.
Path: examples/issue-swarm/issue-swarm.flow.ts
Line: 257

Comment:
**Monitoring never starts**

`now()` runs `node -p Date.now()` without quoting the expression. `/bin/sh` rejects the parentheses before Node starts, so every run with matching issues fails when it starts monitoring—even when all PRs are ready. Use `node -p 'Date.now()'` and add a test that executes the generated command.

```suggestion
  const raw = (await f.run("node -p 'Date.now()'", { timeout: '5s' })).trim();
```

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Fix in Codex Fix in Claude Code

Comment on lines +312 to +314
await settleAll(lanes.map(async lane => {
await f.run(`git worktree add -b ${shellWord(lane.branch)} ${shellWord(lane.cwd)} ${shellWord(base)}`, { timeout: '2m' });
const result = await f.agent(`implement-${lane.issue.number}`, {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Parallel lanes can break resume

Each parallel issue lane makes several journaled calls after separate awaits, but the SDK assigns step IDs from one shared counter. If issue 2 finishes first during the original run and issue 1 finishes first during resume, their next calls receive different IDs. The SDK then rejects the resumed run with an admission conflict or serial_replay_order_mismatch. Agent names do not provide stable step IDs.

Give each lane its own durable child flow, or otherwise keep journaled call order stable across resume.

Prompt To Fix With AI
This is a comment left during a code review.
Path: examples/issue-swarm/issue-swarm.flow.ts
Line: 312-314

Comment:
**Parallel lanes can break resume**

Each parallel issue lane makes several journaled calls after separate awaits, but the SDK assigns step IDs from one shared counter. If issue 2 finishes first during the original run and issue 1 finishes first during resume, their next calls receive different IDs. The SDK then rejects the resumed run with an admission conflict or `serial_replay_order_mismatch`. Agent names do not provide stable step IDs.

Give each lane its own durable child flow, or otherwise keep journaled call order stable across resume.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Fix in Codex Fix in Claude Code

Co-authored-by: Will Washburn <willwashburn@users.noreply.github.com>
Co-authored-by: Will Washburn <willwashburn@users.noreply.github.com>
@willwashburn
willwashburn merged commit 878e089 into main Oct 28, 2026
4 checks passed
@willwashburn
willwashburn deleted the feat/issue-swarm-flow branch October 28, 2026 14:59
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.

2 participants