fix: pin models in first-party v2 flows

Merged
KH
2mo ago
+11082-349

Summary

First-party executable and copyable v2 Flows now carry explicit current CLI/model pairs instead of inheriting an adapter default that may not be authorized for the selected credential:

  • Claude: claude-sonnet-5
  • Codex: gpt-5.6-sol
  • Cursor: gpt-5.6-sol-high
  • Grok: grok-4.7

This updates Software Factory, PR review, Babysitter/reviewer, task graph, stuck-run triage, communication/drive flows, provider-selectable examples, and the close-PR dogfood flow. The generated drive-cloud-v2.yaml now copies and verifies the exact model from drive.yaml and refuses a missing model.

The runtime contract is unchanged: authored step > named agent > adapter default precedence remains fail closed. Exact (cli, model) readiness runs at the existing host-owned f.agent preflight boundary with the isolated credential environment and binds the executable identity before worker admission; authored f.run steps intentionally cannot access that overlay. This PR does not change the Claude adapter default.

Incident

This is Flows lane B for failed Cloud v2 run https://agentrelay.com/cloud/dashboard/workflow/b5d6ab22-caee-58c5-a1c7-4c02d4aa9e26/runner. The run reached agent-3 with an omitted model, inherited claude-opus-5, and the connected credential rejected that exact probe.

The incident generator fix landed separately in AgentWorkforce/agentrelay.com#121. This PR repairs the independently shipped Flows sources and prepares the authoritative source commit needed by the later release and Cloud catalog pin update.

Invariant

shipped-source-models.test.ts inventories current first-party TypeScript and declarative v2 source under examples, workflows, and SDK dogfood:

  • every inline agent requires both cli and model;
  • every literal pair must be in the current supported map;
  • current YAML steps require an effective CLI and explicit model;
  • named-agent and dynamic-pair exceptions are explicit, call-exact, count-exact waivers backed by focused tests;
  • generated dist, node_modules, and symlinks are excluded so ignored build products cannot alter the source inventory.

Changing the reviewed Software Factory bytes also updates the hosted capability-isolation digest and its regression fixture.

Corrective review closure

  • The scanner now resolves only immutable, symbol-scoped string constants; mutable aliases remain unresolved and require an exact waiver.
  • Every named-agent declaration must resolve both a literal CLI and model, and every omitted inline pair must map call-exactly to complete named declarations.
  • Dynamic waivers are bound to the exact source file, call identity, and count; regression fixtures prove mutable aliases and incomplete declarations fail.
  • Babysitter, legacy reviewer, and close-PR custom wrappers now require an explicit model; the four supported built-in CLIs retain their current exact pins.
  • Current aliases without verified frozen prices now pair nominal dollar budgets with enforceable token ceilings.
  • The composition test stubs its declared server preflight, so linux-x64-artifact no longer depends on api.github.com availability.
  • Corrective head: a87bfffebe7610953792f90af67105b59129c2bf.

Verification

  • PATH=<node-24.21.0>:<bun-1.4.0> RELAYFLOWD_BIN=<built-relayflowd> npm test in packages/sdk: 218 files passed, 1 skipped; 3513 tests passed, 3 skipped.
  • Focused inventory plus process-group flake rerun: 2 files, 11/11 passed.
  • npm run typecheck:regressions && npm test in packages/surface: generated helpers current; 10 files, 53/53 passed.
  • Babysitter: 53 passed, 7 intentional TODOs, then typecheck and build passed.
  • Research: 27/27 passed and typecheck passed.
  • python3 ops/gen-drive-cloud-v2.py --check: generated workflow current and equivalent.
  • git diff --check: passed.

RED/GREEN evidence: the first full SDK run caught the stale hosted Software Factory digest and the inventory following an ignored dangling symlink. After updating the digest and making traversal source-only, those regressions pass. Environment-only reds from an unset RELAYFLOWD_BIN, Bun 1.4.2, and Node 26 were eliminated by rerunning with the repository-compatible built daemon, Bun 1.4.0, and Node 24.21.0.

Production boundary proof

Fresh post-generator-fix run af723592-ea24-50c0-b7bb-8adaeb0c40a8 completed all 19 authored steps. Agents 3/6/8/10 ran with codex + gpt-5.6-sol; logs contain neither agent_cli_unresolved nor claude-opus-5. Its terminal control-plane status is failed only because the authored workflow deliberately parked needs_human after complete-19, not because of model resolution. The immutable original failed run was not retried or modified.

Rollout / rollback

After review and merge, a human must publish a Flows release before Cloud updates the recommended catalog immutable ref/digest/fixtures. Roll back by reverting this commit before release, or pinning Cloud to the prior artifact after release. No publish, Cloud mutation, merge, or deployment is performed by this PR.


[!NOTE]
Medium Risk
Changes agent/LLM admission, budget enforcement, and process teardown across the SDK and kernel boundary; incorrect binding could mis-route credentials or leave orphan processes, but behavior is fail-closed on validation.

Overview
First-party flows, examples, and generated Cloud drive steps now declare explicit cli + model pairs (e.g. claude-sonnet-5) instead of inheriting adapter defaults, and nominal dollar budgets are paired with enforceable token ceilings at 100k tokens per dollar when prices are unverified.

Runtime and preflight bind the probed absolute executable to each LLM/agent step and attach host-proved cli_identity so symlinked or generic cli.js targets still use the correct adapter and model resolution; serialized specs cannot smuggle cli_identity. Probes and workers run through pinned basename aliases (realpath + temporary symlinks), and child/MCP shutdown waits for process-group exit before settling.

Babysitter / close-PR add reviewerModel (required for custom CLIs), validate declaration strings up front, and resolve relative wrapper paths before f.agent preflight. Flow-extension manifests and composition honor token budget ceilings alongside dollars/wallclock.

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


Summary by cubic

Fixes first-party executable and copyable v2 flows to pin explicit (cli, model) pairs instead of inheriting adapter defaults, ending a failed Cloud run inheriting claude-opus-5 and being rejected by its credential.

  • Pins claude-sonnet-5, claude-opus-5, gpt-5.6-sol, gpt-5.6-sol-high, and grok-4.7 across shipped flows, examples, and v1/v2 drive workflows, with token ceilings at 100,000 tokens per budget dollar.
  • Preflight probes the exact pair with isolated credentials, binds the executable identity before worker admission, and dispatches through aliases pinned to the authored basename; host-proved cli_identity is accepted only on provider steps, and --probe-cli is removed from the public CLI.
  • Custom Babysitter, legacy reviewer, and close-PR CLI overrides require a valid model and validate before any repository, GitHub, or agent side effects; legacy preflight runs from the sealed runtime.
  • Budget grammar rejects overprecise dollar values and overflowing wallclock strings; composed flow extensions take the minimum token, dollar, and wallclock ceilings.
  • A static invariant audits shipped TypeScript and YAML agent/LLM calls, flow headers, budgets, and callable, binding, iteration, and reflective invocation provenance, including loop-bound callables and wrapped alias writes; mutable or ambiguous declarations fail closed with exact waivers.
  • Webhook and budget snapshotting capture Number, Object, and Array intrinsics so poisoned globals cannot divert parsing; forced stops confirm the process group is gone before reporting, and adopted child runs use the suspended status contract.

Rollout

Publish a Flows release after merge before updating Cloud's catalog reference.

Review closure at 5377263ce73fecd85ab495e3009ab3c37c8a0758

  • The shipped-source invariant now scans both f.agent(...) and f.llm(...); a mutation fixture proves an LLM-only missing model and missing token ceiling fail the gate.
  • The close-PR dogfood flow validates a custom CLI/model pair immediately after input parsing, before any worktree or GitHub side effect; its regression proves no cd or gh command runs on invalid input.
  • Focused regression gate: 2 files, 37/37 tests passed.
  • Full SDK gate with Node 24.21.0, Bun 1.4.0, and the built RELAYFLOWD_BIN: 218 files passed / 1 skipped; 3514 tests passed / 3 skipped.
  • git diff --check passed; origin/main and the PR base remain 66eb9a932239af0a4d2e318b64607010b1f6c474.

Review closure at 70238e52628d66ee1ec42d508a1bf0c57c91aec2

  • The shipped-source invariant inventories f.agent(...), f.llm(...), and tagged-template f.llm syntax. Tagged calls fail as unpinned; prospect-demo now uses the options form with claude / claude-sonnet-5 and an output string schema.
  • All user-supplied CLI/model entrypoints changed by this PR were audited. close-pr and current/legacy Babysitter validate normalized declaration syntax before filesystem, GitHub, or network effects; invalid custom values fail closed.
  • Focused final-state gate: 2 files, 38/38 tests passed.
  • Prospect-demo strict standalone typecheck with --skipLibCheck: passed.
  • Babysitter final state: 54 passed / 7 intentional TODOs; typecheck passed.
  • Full SDK final-state gate with Node 24.21.0, Bun 1.4.0, and the built RELAYFLOWD_BIN: 218 files passed / 1 skipped; 3515 tests passed / 3 skipped.
  • python3 ops/gen-drive-cloud-v2.py --check and git diff --check: passed.
  • origin/main and the PR base remain 66eb9a932239af0a4d2e318b64607010b1f6c474.

Review closure at aad3ae1a24127b92e9c8e8487e37dd371285abae

  • prospect-demo now asks for JSON matching its object output schema ({ message: string }) and posts result.message, so the pinned options-form f.llm call does not fail schema verification on a normal response.
  • Focused shipped-source/close-pr gate: 2 files, 38/38 tests passed.
  • Prospect-demo standalone strict typecheck with --skipLibCheck: passed.
  • Final serialized full SDK gate with Node 24.21.0, Bun 1.4.0, and the built RELAYFLOWD_BIN: 218 files passed / 1 skipped; 3515 tests passed / 3 skipped.
  • The normal parallel full gate reached 3514 passing tests and one unrelated transient worker-cli hidden .bun-build EACCES race; its isolated file passed 18/18 before the clean serialized full gate.
  • python3 ops/gen-drive-cloud-v2.py --check, git diff --check, and the live base guard passed; origin/main remains 66eb9a932239af0a4d2e318b64607010b1f6c474.

Review closure at dfd927f6e4a592a4197630667a93c8fee4b0b150

  • Legacy Babysitter now applies generated reviewer defaults only when CLI/model inputs are absent; explicitly blank or whitespace values fail syntax validation before repository, GitHub, network, or agent effects.
  • A body-level regression invokes the exported legacy flow with blank CLI and blank model cases and proves zero commands and zero agent dispatches.
  • Babysitter suite: 55 passed / 7 intentional TODOs; typecheck passed. Legacy reviewer suite: 50/50 passed.
  • Focused shipped-source/close-pr SDK gate: 2 files, 38/38 passed.
  • Full SDK gate with pinned Node 24.21.0, Bun 1.4.0, and the built RELAYFLOWD_BIN: 218 files passed / 1 skipped; 3515 tests passed / 3 skipped.
  • python3 ops/gen-drive-cloud-v2.py --check, git diff --check, and the live base guard passed; origin/main remains 66eb9a932239af0a4d2e318b64607010b1f6c474.

Review closure at 8d295012428e4ed8328ff5dd0a2d65048b539b48

  • Declarative shipped-source inventory now validates both type: agent and type: llm steps through the same supported-pair gate; mutation fixtures prove missing and unsupported YAML LLM models fail.
  • TypeScript budget inventory now parses literal dollars and tokens, rejecting missing/nonliteral/negative values, zero-dollar budgets, and ceilings above 100,000 tokens per dollar. Mutation coverage rejects 20,000,000 / $2 and accepts the 200,000 / $2 boundary.
  • Focused invariant gate: 3/3 passed.
  • Final constrained full SDK corpus with Node 24.21.0, Bun 1.4.0, and the built RELAYFLOWD_BIN: 218 files passed / 1 skipped; 3515 tests passed / 3 skipped.
  • Earlier parallel full runs exposed unrelated process-group/hosted-snapshot flakes; the affected files passed isolated (9/9 and 27/27) before the clean constrained full run.
  • python3 ops/gen-drive-cloud-v2.py --check, git diff --check, and the exact live base/head guard passed; base remains 66eb9a932239af0a4d2e318b64607010b1f6c474.

Review closure at e9531407b151cedebb692ca5b25a93184dce6d96

  • The shipped declarative inventory now covers the actively launched v1 workflows/drive-cloud.yaml alongside current v2 sources, resolves roster-backed steps, and rejects incomplete roster pairs. Regeneration added exact models to all three v1 Cloud roster declarations.
  • Budget enforcement now resolves shorthand properties and identifier-backed object/numeric literals only through symbol-scoped const declarations; a factored 20,000,000-token / $2 budget regression is rejected.
  • Focused invariant gate: 1 file, 3/3 passed. Production and test TypeScript typechecks passed.
  • Full pinned Node 24.21.0 + Bun 1.4.0 + built RELAYFLOWD_BIN SDK gate: 218 files passed / 1 skipped; 3515 tests passed / 3 skipped; duration 135.19s.
  • python3 ops/gen-drive-cloud-v2.py --check reports the v2 artifact current and equivalent; git diff --check passed; base/main remains 66eb9a932239af0a4d2e318b64607010b1f6c474.

Review closure โ€” e16a9ca444c0e6e5c5fbae7c680990d38486ce67

  • Rejected mutable const budget aliases: identifier-backed budget objects are accepted only when their symbol is immutable and used solely as a direct budget header binding.
  • Property mutation/access, aliasing, calls, spreads, duplicate ceiling fields, mutable declarations, and nonliteral values now fail closed.
  • Mutation regression proves an initially valid 200,000-token / $2 object becomes invalid after budget.tokens is reassigned to 20,000,000.
  • Focused invariant: 3/3 passed.
  • Typecheck and test typecheck passed.
  • Generator equivalence check passed.
  • Full pinned Node 24.21.0 + Bun 1.4.0 + RELAYFLOWD_BIN SDK gate: 218 files passed / 1 skipped; 3515 tests passed / 3 skipped; 136.42s.

Review closure โ€” 9bd1348490aa7af62c0df725e98caf1de44ed57e

  • Exported Babysitter and close-pr model resolvers now apply generated defaults only when an override is absent; explicitly blank or whitespace overrides fail validation.
  • Earlier exact-head fixes remain included: element-access and parenthesized agent/LLM inventory, active v1 launch discovery, immutable single-binding budget resolution, and close-pr model-scoped readiness probing before repository or GitHub effects.
  • Babysitter focused suite: 8 passed / 1 intentional TODO.
  • SDK focused gate: 2 files, 39/39 passed.
  • Full pinned Node 24.21.0 + Bun 1.4.0 + built RELAYFLOWD_BIN SDK gate: 218 files passed / 1 skipped; 3516 tests passed / 3 skipped; 139.58s.
  • Lens CLI parity, lens prompt parity, generator equivalence, and git diff --check passed.
  • Base remains 66eb9a932239af0a4d2e318b64607010b1f6c474.

Review closure โ€” 9bd1348490aa7af62c0df725e98caf1de44ed57e

  • Exported Babysitter and close-pr model resolvers now apply generated defaults only when an override is absent; explicitly blank or whitespace overrides fail validation.
  • Earlier exact-head fixes remain included: element-access and parenthesized agent/LLM inventory, active v1 launch discovery, immutable single-binding budget resolution, and close-pr model-scoped readiness probing before repository or GitHub effects.
  • Babysitter focused suite: 8 passed / 1 intentional TODO.
  • SDK focused gate: 2 files, 39/39 passed.
  • Full pinned Node 24.21.0 + Bun 1.4.0 + built RELAYFLOWD_BIN SDK gate: 218 files passed / 1 skipped; 3516 tests passed / 3 skipped; 139.58s.
  • Lens CLI parity, lens prompt parity, generator equivalence, and git diff --check passed.
  • Base remains 66eb9a932239af0a4d2e318b64607010b1f6c474.

Review closure โ€” 6583c84442fc938ec094093fb3e7c5096c63a865

  • TypeScript budget and named-agent declarations are now accepted only from the actual inline flow header; header aliases fail closed.
  • Named declarations are scoped to worker calls enclosed by the same flow, so unused policy objects cannot satisfy omitted pairs.
  • Destructured and renamed agent/LLM method aliases are inventoried alongside property, element-access, parenthesized, call, and tagged-template forms.
  • Mutation fixtures cover the exact header-alias budget mutation, unused agents policy, and destructured agent/LLM bypasses.
  • Focused invariant + close-pr gate: 39/39 passed; production and test typechecks passed.
  • Constrained full SDK corpus: 218 files passed / 1 skipped; 3516 tests passed / 3 skipped; 184.12s.
  • Parallel-only worker-cli and stop-process-group flakes passed isolated at 18/18 and 9/9.
  • Lens CLI parity, lens prompt parity, generator equivalence, and git diff --check passed.
  • Base remains 66eb9a932239af0a4d2e318b64607010b1f6c474.