Skip to content

Workflow enhacements#454

Merged
khaliqgant merged 18 commits into
mainfrom
feature/workflow-superiority-spec
Feb 20, 2026
Merged

Workflow enhacements#454
khaliqgant merged 18 commits into
mainfrom
feature/workflow-superiority-spec

Conversation

@khaliqgant
Copy link
Copy Markdown
Member

@khaliqgant khaliqgant commented Feb 20, 2026

Summary

This PR introduces significant enhancements to the relay broker-sdk workflow system, making it more robust for multi-agent orchestration.

Key Changes

  • PTY-based output capture: Workflow runner now collects agent terminal output directly instead of relying on file-based summaries, enabling real-time step output chaining via {{steps.X.output}}
  • Dedicated workflow channels: Auto-generates wf-{name}-{id} channels for workflow isolation instead of using shared general channel
  • Agent self-termination: Changed from remove_agent MCP call to /exit PTY output to avoid workspace misalignment issues
  • Credential handling: RELAY_API_KEY is now optional - runner auto-provisions via Relaycast and validates API keys before trusting cached credentials
  • MCP server migration: Switched from @agent-relay/mcp to @relaycast/mcp with credential file-based authentication
  • Rust broker enhancements: Added run_init handler for agent.release_requested WebSocket events and listen --all flag
  • Resource management: Fixed PTY resource leaks with proper cleanup in finally blocks and PTY map re-keying when broker assigns different agent names

New Features

  • Workflow skill documentation: Comprehensive guide for building multi-agent workflows with the WorkflowBuilder API
  • Step output persistence: Outputs saved to disk and Relaycast channel messages
  • Example workflow: 1,486-line workflow-superiority.ts demonstrating a 9-agent, 23-step DAG campaign

Files Changed

File Changes
.claude/skills/writing-agent-relay-workflows/SKILL.md New skill documentation for workflow building
packages/broker-sdk/src/workflows/runner.ts Major revamp with PTY capture, dedicated channels, cleanup
packages/broker-sdk/src/examples/workflow-superiority.ts New comprehensive multi-agent workflow example
src/main.rs WebSocket event handlers and --all flag
.mcp.json MCP server migration to @relaycast/mcp
packages/broker-sdk/src/relaycast.ts API key validation

Test plan

  • Verify workflow runner correctly captures PTY output from agents
  • Confirm dedicated channels are created with wf-{name}-{id} format
  • Test agent self-termination via /exit PTY output
  • Validate Relaycast credential caching and validation
  • Run existing broker-sdk tests to ensure no regressions
  • Test listen --all flag subscribes to all workspace channels

🤖 Generated with Claude Code

Agent Relay and others added 8 commits February 19, 2026 10:54
… campaign

Adds a TypeScript workflow that orchestrates 9 agents (Claude lead +
code-reviewer, 7 Codex workers) across 5 implementation tiers to make
the relay broker-sdk workflow system decisively superior to Agno and
Swarms AI.

Agents:
- lead (claude): orchestrates, approves trajectories, reviews each phase
- code-reviewer (claude): independent review after every phase
- spec-analyst, schema-implementer, engine-implementer, meta-implementer,
  storage-implementer, deploy-implementer, test-validator (all codex)

23-step DAG with 11 review gates (6 lead + 5 independent code reviews):
- Phase 0: codebase analysis + spec approval
- Phase 1: TypeScript type system extension (condition/loop/router/hitl/sub-workflow)
- Phase 2: execution engine (CEL conditions, session state, input validation)
- Phase 3+4: meta-orchestration + storage backends (parallel)
- Phase 5: HTTP serve, OTel tracing, CLI improvements
- Phase 6: integration validation + final capability audit

Key design decisions:
- RELAY_API_KEY optional (runner auto-provisions via Relaycast)
- All agent tasks use withExit() to call relay_remove_agent MCP tool on
  completion, resolving waitForExit() via the released event

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
… self-termination

- Add PTY-based output capture in runner.ts to collect agent terminal output
  instead of relying on file-based summaries
- Auto-generate dedicated workflow channels (wf-{name}-{id}) instead of using
  shared 'general' channel
- Change agent self-termination from remove_agent MCP call to /exit PTY output
  to avoid workspace misalignment issues
- Add run_init handler for agent.release_requested WebSocket events in main.rs
- Add listen --all flag to subscribe to all workspace channels
- Remove RELAY_API_KEY from .mcp.json and snippets.rs (MCP server now reads
  from .agent-relay/relaycast.json credential file)
- Parallelize review steps and remove withExit() in workflow-superiority.ts
- Add step output persistence to disk and Relaycast channel messages
- Validate Relaycast API keys before trusting cached credentials

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Import stripAnsi from pty.ts instead of maintaining incomplete duplicate regex
- Wrap spawnAndWait in try/finally to prevent log stream fd leaks on errors
- Re-key PTY maps if broker assigns a different agent name than requested
- Clean up PTY resources in execute()/resume() finally blocks
- Fix test asserting RELAY_API_KEY in .mcp.json (now intentionally omitted)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Registers the new workflow building skill in the prpm package manifest.
The skill covers WorkflowBuilder API, DAG step dependencies, step output
chaining, verification gates, and swarm patterns.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Comment on lines +144 to +147
headers: {
authorization: `Bearer ${apiKey}`,
'content-type': 'application/json',
},

Check warning

Code scanning / CodeQL

File data in outbound network request Medium

Outbound network request depends on
file data
.
devin-ai-integration[bot]

This comment was marked as resolved.

khaliqgant and others added 2 commits February 20, 2026 09:50
Non-interactive agents run as simple subprocesses (no PTY, no relay
messaging) for faster fan-out/map-reduce patterns. Each CLI has a
one-shot flag (claude -p, codex exec, gemini -p, etc). Agents with
interactive: false are excluded from coordinator topology edges and
lead agents are informed which workers can't receive messages.

- Add interactive?: boolean to AgentDefinition and AgentOptions
- Add opencode and droid to AgentCli union
- Add buildNonInteractiveCommand() with CLI flag mapping
- Add execNonInteractive() subprocess execution path
- Branch in spawnAndWait() based on interactive flag
- Exclude non-interactive agents from coordinator topology edges
- Append non-interactive awareness to lead agent tasks
- Add workers.json interactive metadata field
- Update workflow skill documentation
- Add unit tests for command builder and topology changes

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…sistence

Addresses three issues from Devin's code review:

1. Race condition on workers.json (registerWorker/unregisterWorker):
   - Added in-memory Map to track active workers
   - Added promise-based mutex to serialize file access
   - Prevents lost entries when parallel steps run concurrently

2. Log file name mismatch after broker re-keying:
   - Close old log stream and rename file when broker assigns different name
   - Open new log stream with correct name
   - Update listener to use new stream

3. Channel not persisted for resume():
   - Persist auto-generated channel back to run config in DB
   - Ensures resume() reuses the original channel instead of generating new one

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
devin-ai-integration[bot]

This comment was marked as resolved.

khaliqgant and others added 2 commits February 20, 2026 10:04
…ement

- Update schema.json with interactive field and opencode/droid CLIs
- Add non-interactive agents section to workflows README
- Set interactive: false on worker agents in all 6 builtin templates
- Fix DAG topology to filter non-interactive agents from stepEdges
- Add DAG non-interactive test to coordinator tests
- Add strong deliverable enforcement instructions for non-interactive tasks

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ss text

- Add abort signal wiring to execNonInteractive so runner.abort() kills child
- Fix buildNonInteractiveAwareness to show actual {{steps.X.output}} refs
- Fix pickHub to prefer interactive agents as hub (avoid non-interactive hubs)
- Add missing {{steps.X.output}} chaining in builtin templates:
  - documentation: draft←gather-context, edit←draft
  - refactor: refactor-code←design, validate←refactor-code
  - security-audit: verify←remediate
  - code-review: consolidate←all review passes

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

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

Devin Review found 1 new potential issue.

View 13 additional findings in Devin Review.

Open in Devin Review

Comment on lines +70 to +72
Architecture review: {{steps.architecture-pass.output}}
Correctness review: {{steps.correctness-pass.output}}
Security review: {{steps.security-pass.output}}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔴 YAML indentation error causes review outputs to be parsed as step-level keys instead of task content

In the code-review.yaml builtin template, the newly added lines referencing step outputs (Architecture review:, Correctness review:, Security review:) are indented at the same level as the task: key (10 spaces), not inside the YAML block scalar (12 spaces). This means YAML will parse them as new mapping keys at the step object level rather than as part of the task string.

Root Cause and Impact

The task: | block scalar at packages/broker-sdk/src/workflows/builtin-templates/code-review.yaml:66 requires its content to be indented more than the key itself. The original content line Produce merged findings... is correctly at 12 spaces, but the three new lines are at 10 spaces — the same level as task:, agent:, dependsOn:, etc.

YAML parsing will treat the added lines as separate keys in the step mapping:

# What YAML actually sees:
- name: consolidate
  task: |              # block scalar content is ONLY "Produce merged..."
    Produce merged findings, severity levels, and final recommendation.
  Architecture review: "{{steps.architecture-pass.output}}"  # ← new key!
  Correctness review: "{{steps.correctness-pass.output}}"    # ← new key!
  Security review: "{{steps.security-pass.output}}"          # ← new key!

Impact: The consolidation step's task will NOT include the review outputs from prior steps. Since the WorkflowStep schema has additionalProperties: false, this would also fail JSON Schema validation. Even without strict validation, the agent performing the consolidation step receives no review context, making the entire code-review workflow's final step useless.

Suggested change
Architecture review: {{steps.architecture-pass.output}}
Correctness review: {{steps.correctness-pass.output}}
Security review: {{steps.security-pass.output}}
Architecture review: {{steps.architecture-pass.output}}
Correctness review: {{steps.correctness-pass.output}}
Security review: {{steps.security-pass.output}}
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

devin-ai-integration[bot]

This comment was marked as resolved.

khaliqgant and others added 4 commits February 20, 2026 11:14
Co-authored-by: devin-ai-integration[bot] <158243242+devin-ai-integration[bot]@users.noreply.github.com>
…orkforce/relay into feature/workflow-superiority-spec
@khaliqgant khaliqgant merged commit 777e652 into main Feb 20, 2026
39 of 40 checks passed
@khaliqgant khaliqgant deleted the feature/workflow-superiority-spec branch February 20, 2026 10:38
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