Skip to content

improvement(workflow-code): agent efficiency — typed child results, commands use the source directory's workspace, primer and cookbook fixes - #10388

Merged
waleedlatif1 merged 13 commits into
stagingfrom
improvement/workflow-code-r12-agent-efficiency
Nov 25, 2026
Merged

waleedlatif1 merged 13 commits into
stagingfrom
improvement/workflow-code-r12-agent-efficiency

Conversation

@waleedlatif1

Copy link
Copy Markdown
Collaborator

Summary

Removes the recurring agent frictions measured in A/B benchmark runs of the workflows-as-code loop.

Typed child results

  • A parent's <call.result.data.<field>> is typed from the child's Response when the child always responds, so it no longer warns W_JSON_REF_UNTYPED, which cost every cross-workflow benchmark run an extra check-and-apply round.
  • The value is stored quoted for text and bare otherwise, with the same rule everywhere: the CLI workspace check, the server's workspace apply and dry run, single-workflow apply and get, and the printer, so get → check → apply round-trips.
  • Rule: the type comes from the child's draft. A field counts only when every Response block sends it with the same kind.
  • Standalone workflow directory: the check there can't read the child and keeps today's warning. A freshly printed source still checks clean.

Commands use the source directory's workspace

  • Run inside a source directory, sim tables … and other commands act on that directory's workspace. Today they fall back to the profile's and 404.
  • Precedence: -w, then SIM_WORKSPACE, then the source directory (base, its workspace directory, or a starter), then the profile.
  • There is one definition of the workspace a directory names, applied where a command picks its request workspace. resolveProfile stays flag/env/config.
  • A SIM_WORKSPACE naming another workspace is refused by source commands (SOURCE_OTHER_WORKSPACE), as -w already was.

Primer and cookbook

  • Renames: any number of display names or consts per apply, and apply rewrites function files' $ref.<key> too. Renaming both the const and the display name works for one block per apply. The old "one variable per apply" line was wrong both ways.
  • A compile-checked cookbook example of branches that rejoin before one Response. A function picks the value that ran with ??; a block that didn't run reads as null in code and '' in text.

Also

  • packages/sim-cli/scripts/print-source-primers.ts prints both primers as JSON for the mothership worker's preloaded workflow-source skill.
  • The promote-record and lock-layout docs now match the code.
  • Efficiency:
    • one lock parse and canonicalize per apply;
    • child graphs loaded once per batched read, with child ids taken from the stored blocks;
    • the workspace check compiles most workflows once, and a calling one at most twice.

Type of Change

  • Improvement
  • Bug fix

Testing

  • Full local gate: bun run generate, bun run lint, bun run type-check, bun run check:audits, check-block-registry.ts origin/staging, root bun run test.
  • Each behaviour change has a test that failed on the old code (old file restored, then fix put back):
    • workflow-code child typing and print round trip;
    • CLI workspace check, including stored-edges under child typing;
    • workspace precedence through the real CLI entry;
    • starter workspace;
    • the SIM_WORKSPACE refusal;
    • the server integration test against real Postgres: workspace apply as submitted or stored, single-workflow get matching the workspace get, single-workflow apply.
  • New and changed tests pass the test-audit authoring gate.
  • Benchmark that motivated it: 6 arms × 6 tasks on staging, all correct. The child-result round showed up in every task-6 run, the workspace 404 in 5 runs, and rename workarounds in 4.

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing (new tests pass the test-audit authoring gate)
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel

vercel Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
docs Skipped Skipped Nov 25, 2026 12:25am UTC

Request Review

@cubic-dev-ai cubic-dev-ai Bot left a comment •

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.

All reported issues were addressed across 58 files

Reply with feedback, questions, or to request a fix.

Turn on auto-fix | Re-trigger cubic

@greptile-apps

greptile-apps Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no blocking issue remains.

Summary

The latest change restores the workflow-variable rename warning and shortens the primers without changing their command examples.

  • Parent workflows use child response fields as typed values.
  • Commands run from a source directory use its workspace.
  • Workflow applies can rename several names and rewrite function references.
  • The cookbook shows branches rejoining before one response.

Reviews (7) · Last reviewed commit: "fix(cli): the primers keep the one-workf..." · Reviewed by Greptile

… the child's Response body

A parent reading <call.result.data.<field>> of a child workflow that responds on
every run had no declared type, so a JSON field stored it bare with
W_JSON_REF_UNTYPED and every such edit paid an extra check cycle.

compileWorkflow and printWorkflow now take childResults (child workflow key ->
typed top-level fields of its Response data, from childResultFields), so compile
and print type the reference the same way: a text field is stored quoted and
prints bare, a typed one is stored and printed bare.

- CLI: a check in a workspace directory reads the fields from the workflows it
  already compiles. Block digests for .sim/stored-edges.json stay untyped, so a
  printed block a child types does not count as edited.
- Server: every source apply, dry run and get reads the fields of the children
  the workflow calls. A workspace apply reads a child it submits from its
  folder, and any other child from its stored draft in the workspace
  (loadChildResults, once per request). A single-workflow apply or get reads
  the stored children, so a workspace folder applied on its own stores what a
  workspace apply stores.
…er rename and rejoin wording

- A command run inside a source directory (nearest .sim/base.json at or above the cwd) acts on
  that directory's workspace when neither --workspace nor SIM_WORKSPACE names one. Precedence:
  flag > env > directory > profile, documented in sim --help. sim login opts out so a directory
  never becomes the profile's stored workspace. Source commands now refuse a SIM_WORKSPACE naming
  another workspace (SOURCE_OTHER_WORKSPACE), as they refuse the flag.
- Primers: a display-name rename also rewrites $ref.<key> in function files; any number of
  display-name or const renames per apply, both of one block only one per apply.
- Cookbook: one Response after condition branches rejoin, a function picking the value with ??.
…ll; promote-record and lock-layout docs match the code
…atched child reads, childSources on the per-apply loads
…equest layer, stored-edges under the printed typing

- resolveProfile is back to flag, env and config. The terminal reads the workspace the
  working directory names once before each action (enclosingWorkspace, the same rule
  recordedWorkspace uses: base, workspace folder, starter), and actingProfileFrom/clientFrom
  apply it below --workspace and SIM_WORKSPACE. 'directory' leaves SettingSource; whoami and
  the 404 wording read workspaceDirectory. sim login needs no opt-out. A starter directory
  now chooses the workspace for every command, as it does for source create.
- explicitWorkspaceSetting lives in config and is the one "flag then env" check.
- .sim/stored-edges.json digests blocks under the child results the get printed with: a
  workspace get/apply types each folder by the folders it answered with, a workflow get,
  create or apply into a workspace folder by that workspace directory's folders. The check
  compares its typed compile directly, so the untyped recompile is gone.
- A workspace check compiles each workflow once, with its env names, and reuses that compile
  for a workflow whose calls no child result types.
…ildren, the same on CLI and server

- An offline compile (storedUnread) leaves stored() on a block the lock binds unread instead of
  refusing it, so a child holding a secret still compiles and types its callers; the server
  compiles a submitted child folder with its lock through the same folderCompileInput.
- resolveChildResults types each workflow's Response fields by its callees' fields, callees
  first (strongly connected components; a call within a cycle stays untyped), shared by the
  workspace check, the stored-edges records, the apply and the read paths.
- The stored read lifts a child's own calls to keys, so a forwarded field is typed as the
  compile types it.
- The primers say source commands refuse a -w naming another workspace.
@waleedlatif1
waleedlatif1 force-pushed the improvement/workflow-code-r12-agent-efficiency branch from 4395482 to 69ad970 Compare November 24, 2026 23:49
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@waleedlatif1 I have started the AI code review. It will take a few minutes to complete.

@cubic-dev-ai cubic-dev-ai Bot left a comment •

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.

All reported issues were addressed across 63 files

Reply with feedback, questions, or to request a fix.

Turn on auto-fix | Re-trigger cubic

…alog; child results never fail a written apply
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@waleedlatif1 I have started the AI code review. It will take a few minutes to complete.

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@waleedlatif1 I have started the AI code review. It will take a few minutes to complete.

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@waleedlatif1 I have started the AI code review. It will take a few minutes to complete.

@cubic-dev-ai cubic-dev-ai Bot left a comment •

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.

All reported issues were addressed across 64 files

Reply with feedback, questions, or to request a fix.

Turn on auto-fix | Re-trigger cubic

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@waleedlatif1 I have started the AI code review. It will take a few minutes to complete.

@cubic-dev-ai cubic-dev-ai Bot left a comment •

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.

All reported issues were addressed across 64 files

Reply with feedback, questions, or to request a fix.

Turn on auto-fix | Re-trigger cubic

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@waleedlatif1 I have started the AI code review. It will take a few minutes to complete.

@cubic-dev-ai cubic-dev-ai Bot left a comment

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.

No issues found across 64 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

You've manually re-run cubic several times on this PR. Each manual re-review checks the full PR again and counts toward your usage quota. To preserve your usage limits, we recommend letting cubic automatically review new commits.

Turn on auto-fix | Re-trigger cubic

@waleedlatif1
waleedlatif1 merged commit 51205e9 into staging Nov 25, 2026
85 of 87 checks passed
@waleedlatif1
waleedlatif1 deleted the improvement/workflow-code-r12-agent-efficiency branch November 25, 2026 00:36

This branch was previously deployed

1 inactive deployment
Preview — 2db6bd81 Deployed Nov 25, 2026 by vercel[bot]
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.

1 participant