Skip to content

improvement(workflow-code): fewer agent turns on the source loop: apply --run, get by name, tail-safe output - #10440

Merged
waleedlatif1 merged 5 commits into
stagingfrom
improvement/workflow-code-agent-turns
Nov 26, 2026
Merged

waleedlatif1 merged 5 commits into
stagingfrom
improvement/workflow-code-agent-turns

Conversation

@waleedlatif1

Copy link
Copy Markdown
Collaborator

Summary

A transcript analysis of the workflows-as-code benchmark found that a coding agent spends 11.3 turns per task, and each turn costs about 82k tokens. This PR removes the turns that come from how the CLI is shaped:

  • Apply, test and deploy in one command. sim workflows source apply --yes --run '<input json>' --deploy (and create) applies the source, dry-runs the saved draft with that input, and deploys only if the run completed. It prints one result. If the run fails, the command exits 1, maps the failing block to file:line, deploys nothing, and its next is the same command again. It sends the same request as workflows run --dry --input (dryRunDraft, extracted from the run command) and runs the existing deploy step. Without --deploy, the next for a deployed workflow whose draft now differs is this command; the untested, fingerprint-pinned deploy command is named in its reason.
  • source get <workflow> takes an id or an exact name. If no workflow or several workflows match, it fails with WORKFLOW_NOT_FOUND or WORKFLOW_NAME_AMBIGUOUS and lists each candidate with its id. A name never resolves to a workflow whose name only contains it.
  • The primer comes with the get. The first loop line in --help is now get <workflow> --dir ./wf && cat ./wf/.sim/AGENTS.md. This removes the separate cat turn without printing the primer twice. workflow.ts is not chained, because at 192 blocks it is 57 KB, and agents grep it instead.
  • Primer. The Retry line, the Child line (now naming runWorkflow) and the api .error / Function-only .errorMessage line are checked against the cookbook. The edit loop is check && apply --yes --run '{…}' --deploy. The primer is now workflow 3913 → 3983 B and workspace 3941 → 4010 B (budget 4096); the space came from trimming the Run line and folding in the Deploy bullet.
  • Output that survives | head and | tail.
    • apply and create print a one-line summary first (counts, findings, test run, live) and end with errors, warnings, live and next.
    • added, removed and modified are now one string per block (key (type), key (field, …)).
    • Deployment results end with live.
    • A lint report keeps only its findings in every format, so the graph's sources/sinks (3.5 KB of 5.5 KB at 192 blocks) are no longer printed.
  • Shorter help. sim --help 4858 → 4541 B, sim workflows source --help 4064 → 3518 B, sim workspaces source --help 2868 → 2380 B.

Machine-output changes for consumers of --output json:

  • added, removed and modified are now string lists.
  • lint drops sources/sinks, and is absent when it has no findings.
  • live has moved from first to last.

The get positional is now <workflow>. The primer text and the command inventory (the new --run option, plus executeWorkflow and listWorkflows on apply, create and get) both feed the Mothership grammar sync.

Type of Change

  • Other: CLI agent-efficiency improvement

Testing

  • New tests, each shown failing when its guard is reverted:
    • apply --run completes, then deploys: checks the request body and order.
    • A failed test run deploys nothing, exits 1 and keeps the saved draft.
    • --run beside --dry is refused before any request.
    • get <name>: an exact match among substring hits succeeds; ambiguous or missing names are refused and list each candidate's id.
  • Updated tests for the new result order and compact lists. The primer-vs-cookbook and byte-budget tests pass.
  • Ran locally: bun run generate, bun run lint, bun run type-check, bun run check:audits, bun run check:api-validation:strict, bun run test (the sim-cli suite: 91 files, 1237 tests), and check-block-registry.ts origin/staging.
  • Reviewers should check the machine-output shape changes listed above.

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • 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 26, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated
docs Ready Ready Preview Nov 26, 2026 10:17pm UTC

Request Review

@greptile-apps

greptile-apps Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Confidence Score: 5/5 · The PR appears safe to merge.RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge.

Summary

Adds --run to workflow source writes, exact-name lookup to source get, and shorter output that keeps the outcome near both ends.

  • Source apply and create can test a saved draft before deploying it.
  • Workflow source get accepts an id or an exact workflow name.
  • CLI results put the key workflow and deployment outcome up front and at the end.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Apply or create source] --> B[Save draft and local files]
  B --> C{--run supplied?}
  C -->|Yes| D[Dry-run saved draft]
  D --> E{Run completed?}
  E -->|No| F[Print result and exit 1]
  E -->|Yes| G{--deploy supplied?}
  C -->|No| G
  G -->|Yes| H[Deploy with saved draft fingerprint]
  G -->|No| I[Print result and next step]
  H --> I
Loading

Reviews (4) · Last reviewed commit: "fix(workflow-code): review round 3: a st..." · Reviewed by Greptile

@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.

1 issue found and verified against the latest diff

Confidence score: 3/5

  • In workflow-source-apply.ts, this follow-up reruns the workflow from the start, even when no source block can be entered, so it may repeat unrelated work or produce a rerun with no valid target. Use error.rerunFromBlockId and the run ID to build a targeted rerun.
Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="packages/sim-cli/src/commands/protocol/workflow-source-apply.ts">

<violation number="1" location="packages/sim-cli/src/commands/protocol/workflow-source-apply.ts:304">
P2: This follow-up always reruns the workflow from its start and is emitted even when no source block is enterable. Use `error.rerunFromBlockId` and the run id to build the targeted rerun (the outermost loop/parallel when applicable), and omit `next` when the server provides no enterable block; otherwise upstream blocks run again and input or timeout failures get a misleading source-fix command.

(Based on your team's feedback about choosing an enterable rerun start.) [07afeeb8-4946-46b1-9966-1431082ea3b1]</violation>
</file>

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

Turn on auto-fix | Re-trigger cubic

Comment thread packages/sim-cli/src/runtime/result.ts Resolved
Comment thread packages/sim-cli/src/program.ts Resolved
@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 26, 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.

1 issue found across 23 files

Confidence score: 3/5

  • source-primer.ts may lead agents to treat the default dry run as side-effect-free, even though sandboxed code runs unchecked and generated GET requests are sent. Clarify that agents must inspect the relevant sideEffects setting before running it.
Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="packages/sim-cli/src/commands/protocol/source-primer.ts">

<violation number="1" location="packages/sim-cli/src/commands/protocol/source-primer.ts:52">
P1: This run guidance can lead agents to treat the default dry run as side-effect-free even though sandboxed code executes unchecked and code-generated GET requests are sent. State that agents must inspect `sideEffects.unchecked`, use test resources for GET endpoints, and treat `--allow <block>` and `--draft` as real writes.</violation>
</file>

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 26, 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 23 files

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

Turn on auto-fix | Re-trigger cubic

…ly --run, get by name, tail-safe output

- `source apply|create --yes --run '<input>' [--deploy]`: apply, dry-run the saved draft with
  that input, deploy only if the run completed; one result, exit 1 at a failed run with the
  failing block mapped to file:line. Reuses the `workflows run --dry` request and the deploy step.
- `source get <workflow>` takes an id or the exact name; none or several matches are refused
  with each candidate's id.
- Help chains `get … && cat .sim/AGENTS.md`, so the primer arrives with the get.
- Primer: Retry, Child (`runWorkflow`) and api `.error` lines; edit loop is
  `check && apply --yes --run '{…}' --deploy`.
- Output survives `| head` and `| tail`: apply opens with `summary` and ends with
  errors, warnings, live, next; block lists are one string per block; deploy ends with `live`;
  a lint report keeps only its findings in every format.
- Shorter `sim --help` and `source --help`.
- get <name> reads every page of matches before deciding exact or ambiguous.
- A create whose --run fails names the apply of the created workflow next.
- A failed test run carries the server's rerun from its enterable block.
- Starters are taught create, not apply (primer, AGENTS.md pointer, root help);
  --allow keeps its test-resources warning; the standalone test run includes --input.
- A deploy answering lint: null prints no lint field.
- Record the intended `source get <workflow>` usage change in the docs baseline.
- get <name> --dir looks the name up in the workspace the directory was read from.
- A starter's next keeps --run and --deploy.
- Guide: flags that imply the draft, and sideEffects.omitted before trusting a list.
- Drop the test that compared two help strings.
@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 26, 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 23 files

Confidence score: 5/5

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

Turn on auto-fix | Re-trigger cubic

@waleedlatif1
waleedlatif1 merged commit 23a4c2d into staging Nov 26, 2026
87 checks passed
waleedlatif1 added a commit that referenced this pull request Nov 26, 2026
* fix(sim-cli): keep the workflow primer within its byte budget

#10440 and #10444 each fit the 4096-byte budget, but together the workflow
primer reached 4127 bytes and the primer budget test failed on staging.
Tighten two sentences (88 bytes of headroom) without dropping any rule.

* fix(sim-cli): keep the primer's note that --run tests the draft

This branch was successfully deployed

1 active deployment
Preview — f906574f Deployed Nov 26, 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