feat: launch Relayflow agents from personas - #28
Conversation
|
Warning Review limit reached
Next review available in: 32 minutes You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThe workflow now accepts persona-based agents. Schemas and builders enforce exclusive ChangesPersona agent support
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant WorkflowRunner
participant PersonaRuntime
participant ProcessSpawner
participant Broker
WorkflowRunner->>PersonaRuntime: resolve and activate persona
PersonaRuntime-->>WorkflowRunner: return resolved CLI and runtime settings
WorkflowRunner->>ProcessSpawner: spawn interactive agent
ProcessSpawner->>Broker: emit worker_ready
Broker-->>WorkflowRunner: confirm registration
WorkflowRunner->>ProcessSpawner: send task
ProcessSpawner-->>WorkflowRunner: report completion
WorkflowRunner->>PersonaRuntime: dispose persona resources
Possibly related issues
Possibly related PRs
Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
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. Comment |
|
Bugbot is not enabled for your account, so this pull request was not reviewed. Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 18d2bc5b87
ℹ️ 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".
There was a problem hiding this comment.
Actionable comments posted: 4
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
packages/core/src/schema.json (1)
454-469: 🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win
AgentClienum still omits"api".The enum now includes
"grok"but still does not include"api".schema.ts'sAgentCliTypeScript union includes'api', andrunner.ts/process-backend-executor.tsexplicitly branch oncli === 'api'. A workflow YAML agent withcli: api, validated against this schema, fails validation even though the runtime supports it.Add
"api"to the enum for consistency withschema.ts.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/core/src/schema.json` around lines 454 - 469, Update the AgentCli enum in schema.json to include "api", matching the supported values in schema.ts and the runtime branches handling cli === 'api'.
🧹 Nitpick comments (1)
packages/core/src/runner.ts (1)
9936-9980: 🗄️ Data Integrity & Integration | 🔵 Trivial | ⚡ Quick win
captureAgentReportre-resolves the persona instead of reusing the CLI already resolved at spawn time.
agentDef.persona ? (resolveWorkflowPersona(agentDef.persona, cwd).cli as AgentCli) : undefinedre-invokesresolveWorkflowPersonaon every report capture (including per retry attempt), even though the same persona was already resolved once inspawnAndWait. Two issues:
- It is wasted computation on a path that already knows the resolved CLI.
- It uses
cwd=lastEffectiveCwd, derived fromresolveAgentCwd(unmounted path), whilespawnAndWaitresolved the same persona usingresolveExecutionCwd(mounted path when the agent also has a relayfile permission mount). If a persona agent also carriespermissions, these two cwd values can diverge, risking a different persona resolution outcome than the one actually spawned.Consider threading the resolved
cli(and persona id) fromspawnAndWait'sSpawnResultback toexecuteAgentStep, socaptureAgentReportreuses it instead of re-resolving.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/core/src/runner.ts` around lines 9936 - 9980, Update the spawn-to-report flow so captureAgentReport reuses the CLI resolved during spawnAndWait rather than calling resolveWorkflowPersona with cwd again. Thread the resolved CLI (and persona identifier if required) through SpawnResult into executeAgentStep, then pass it to captureAgentReport and use it for collectCliSession, preserving the exact execution-time persona resolution.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/core/package.json`:
- Around line 60-61: Update the dependency entries for
`@agentworkforce/persona-kit` and `@agentworkforce/persona-registry` in
packages/core/package.json so they resolve to versions actually available on
npm, or release the required 4.1.38+ versions before publishing
`@relayflows/core`.
In `@packages/core/src/builder.ts`:
- Around line 90-92: Update the persona variant of AgentOptions to match
WorkflowRunner.validateConfig: add preset?: never and narrow interactive to true
or undefined, while preserving the existing exclusions for cli, role, and model.
In `@packages/core/src/persona-runtime.ts`:
- Around line 13-46: Validate plan.cli inside resolveWorkflowPersona against the
supported AgentCli values before constructing the return object. Reuse the
existing AgentCli validation or supported-CLI set, reject unsupported
identifiers with the established error behavior, and only expose the validated
CLI value so downstream registry lookups cannot bypass validation.
In `@packages/core/src/runner.ts`:
- Around line 7066-7069: Ensure repair-agent resolution never selects
persona-only agents without a CLI: update resolveWorkflowRepairAgent and its
errorHandling.repairAgent, step.agent, and scoreRepairAgent candidate paths to
exclude them, and reject explicitly configured persona repair agents with a
clear configuration error; alternatively, resolve and activate the persona
consistently with spawnAndWait before invoking execNonInteractive. Preserve
normal repair-agent selection and make skipped persona repairs explicit rather
than swallowing the non-interactive execution failure.
---
Outside diff comments:
In `@packages/core/src/schema.json`:
- Around line 454-469: Update the AgentCli enum in schema.json to include "api",
matching the supported values in schema.ts and the runtime branches handling cli
=== 'api'.
---
Nitpick comments:
In `@packages/core/src/runner.ts`:
- Around line 9936-9980: Update the spawn-to-report flow so captureAgentReport
reuses the CLI resolved during spawnAndWait rather than calling
resolveWorkflowPersona with cwd again. Thread the resolved CLI (and persona
identifier if required) through SpawnResult into executeAgentStep, then pass it
to captureAgentReport and use it for collectCliSession, preserving the exact
execution-time persona resolution.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 03c19a00-93e1-4fc6-b219-f327e70518a8
⛔ Files ignored due to path filters (1)
package-lock.jsonis excluded by!**/package-lock.json
📒 Files selected for processing (12)
README.mdpackages/core/package.jsonpackages/core/src/__tests__/builder-agent-round-trip.test.tspackages/core/src/__tests__/persona-runtime.test.tspackages/core/src/__tests__/workflow-runner.test.tspackages/core/src/builder.tspackages/core/src/persona-runtime.tspackages/core/src/process-backend-executor.tspackages/core/src/process-spawner.tspackages/core/src/runner.tspackages/core/src/schema.jsonpackages/core/src/schema.ts
There was a problem hiding this comment.
All reported issues were addressed across 13 files
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (4)
packages/core/src/schema.json (1)
384-386: 🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick winReject blank persona references in the JSON Schema.
The schema accepts
persona: ""and whitespace-only values. Runtime validation rejects these values. Add a non-whitespace pattern so schema validation matches runtime behavior.Proposed fix
"persona": { "type": "string", + "pattern": "\\S", "description": "AgentWorkforce persona id or JSON path; mutually exclusive with cli" }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/core/src/schema.json` around lines 384 - 386, Update the persona property in the JSON Schema so its string constraint rejects empty and whitespace-only values by adding a non-whitespace pattern, while preserving valid persona IDs and JSON paths and the existing mutual-exclusion description.packages/core/src/runner.ts (3)
7444-7485: 🩺 Stability & Availability | 🟡 Minor | ⚡ Quick winStop before spawning when persona activation exhausts the step deadline.
stepDeadlinestarts beforeactivateWorkflowPersona(). If activation consumes the timeout, this code still callsspawnPty(). The readiness check then fails with zero remaining time after the harness has started.Proposed fix
activePersona = personaResolution ? await activateWorkflowPersona(personaResolution, agentCwd) : undefined; +if (stepDeadline !== undefined && Date.now() >= stepDeadline) { + throw new Error(`Step "${step.name}" timed out during persona activation`); +} const interactiveSpawnPolicy = resolveSpawnPolicy({🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/core/src/runner.ts` around lines 7444 - 7485, Check the step deadline immediately after the conditional activateWorkflowPersona call and before constructing or invoking relay.spawnPty through WorkflowAgentHandle. If the deadline has been exhausted, stop the step using the existing timeout/abort handling path and do not start the harness; otherwise preserve the current spawn flow.
7719-7761: 🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy liftCapture the persona session before runtime disposal.
This
finallyblock disposesactivePersonabefore returningruntimeCwd.captureAgentReport()runs afterspawnAndWait()returns at Lines 5503-5511. It can therefore receive a removed isolated mount, fail to collect the session, and silently lose persona reports and token usage.Keep the runtime alive until reporting completes, or collect the report before
activePersona.dispose().🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/core/src/runner.ts` around lines 7719 - 7761, Move persona report/session collection ahead of activePersona.dispose() in the runner flow, or defer disposal until captureAgentReport() has completed after spawnAndWait() returns. Ensure the runtimeCwd remains valid while reporting collects persona session data, token usage, and related evidence, then dispose the persona runtime afterward.
5341-5357: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick winPerform persona startup on custom executors.
Custom
createProcessBackendExecutorimplementations can be used throughexecutor.executeAgentStep()before the process-backed synthetic executor is applied. The process-backed path rejects non-CLI personas, but an explicit executor that callsProcessBackend.exec()bypassesspawnAndWait()and can launch persona agents without resolving the persona reference, activating the isolated mount, validating readiness, and disposing the persona runtime. Apply the persona lifecycle inexecuteAgentStep()for persona agents before sending the command to the backend.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/core/src/runner.ts` around lines 5341 - 5357, The executor path in executeAgentStep must apply the persona lifecycle before invoking executor.executeAgentStep for persona agents: resolve the persona reference, activate its isolated mount, validate readiness, and dispose the persona runtime afterward. Ensure this occurs for custom executors that call ProcessBackend.exec(), while preserving the existing non-persona and process-backed flows.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/core/src/templates.ts`:
- Around line 400-404: Update the agent-definition validation near hasCli and
hasPersona to reject any provided cli or persona value that is not a non-empty
string, including numbers such as cli: 42. Preserve the existing requirement
that exactly one valid launch field is present, so malformed fields fail before
the template is accepted.
---
Outside diff comments:
In `@packages/core/src/runner.ts`:
- Around line 7444-7485: Check the step deadline immediately after the
conditional activateWorkflowPersona call and before constructing or invoking
relay.spawnPty through WorkflowAgentHandle. If the deadline has been exhausted,
stop the step using the existing timeout/abort handling path and do not start
the harness; otherwise preserve the current spawn flow.
- Around line 7719-7761: Move persona report/session collection ahead of
activePersona.dispose() in the runner flow, or defer disposal until
captureAgentReport() has completed after spawnAndWait() returns. Ensure the
runtimeCwd remains valid while reporting collects persona session data, token
usage, and related evidence, then dispose the persona runtime afterward.
- Around line 5341-5357: The executor path in executeAgentStep must apply the
persona lifecycle before invoking executor.executeAgentStep for persona agents:
resolve the persona reference, activate its isolated mount, validate readiness,
and dispose the persona runtime afterward. Ensure this occurs for custom
executors that call ProcessBackend.exec(), while preserving the existing
non-persona and process-backed flows.
In `@packages/core/src/schema.json`:
- Around line 384-386: Update the persona property in the JSON Schema so its
string constraint rejects empty and whitespace-only values by adding a
non-whitespace pattern, while preserving valid persona IDs and JSON paths and
the existing mutual-exclusion description.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: b81dd3ba-3124-4240-a2d0-e5d29cdbb5d7
📒 Files selected for processing (9)
README.mdpackages/core/src/__tests__/builder-agent-round-trip.test.tspackages/core/src/__tests__/workflow-runner.test.tspackages/core/src/builder.tspackages/core/src/persona-runtime.tspackages/core/src/runner.tspackages/core/src/schema.jsonpackages/core/src/schema.tspackages/core/src/templates.ts
🚧 Files skipped from review as they are similar to previous changes (3)
- README.md
- packages/core/src/builder.ts
- packages/core/src/persona-runtime.ts
There was a problem hiding this comment.
All reported issues were addressed across 9 files (changes from recent commits).
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
Summary
personain place ofcli+role, in YAML and the TypeScript builder@agentworkforce/persona-registry, then prepare skills, MCP servers, sidecars, harness settings, model, and isolated autosync mount through persona-kit in processworker_readyplus authoritative agent inventory before continuing, releasing the worker and disposing its prepared runtime on any failureThis is the Relayflows part of AgentWorkforce/workforce#306. It does not shell out to
agentworkforce.Verification
run-scripttests failed because this checkout has notsxbinary and theirnpx tsxfallback exited 127Stack / blockers
Depends on AgentWorkforce/workforce#307 and the subsequent Workforce 4.1.38+ publication.
@agentworkforce/persona-registryand the persona-kit autosync contract are not published yet, so a clean install/lock refresh is intentionally blocked until that upstream release; the local validation used the checked-out Workforce packages.Summary by cubic
Launch Relayflow agents directly from AgentWorkforce personas to simplify config and run with the persona’s harness, model, and settings. Adds strict schema and template validation, and waits for runtime readiness and broker registration before executing steps.
New Features
personato agent config and builder (agent('name', { persona: 'id' })) as an alternative tocli. Resolve and activate personas via@agentworkforce/persona-registryand@agentworkforce/persona-kit, installing skills and launching in an isolated autosync mount; layer workflow tasks over standing instructions.worker_ready, verify registration via inventory, then proceed; dispose the persona runtime and release the worker on failure.cliorpersona; persona agents are interactive-only and cannot setrole,preset, orconstraints.model; template loader rejects malformedcli/personavalues; persona agents are blocked from non-interactive paths (process backend, diagnostics).Migration
persona: <id>instead ofcli/role; do not combine withcli,role, orpreset; do not setconstraints.model; personas must be interactive (do not useinteractive: false).@agentworkforce/persona-kit,@agentworkforce/persona-registry).Written for commit 955e0d3. Summary will update on new commits.