fix(respect): keep step outputs on a same-workflow goto - #3081
fix(respect): keep step outputs on a same-workflow goto#3081ariesclark wants to merge 3 commits into
Conversation
🦋 Changeset detectedLatest commit: f158d11 The changes in this PR will be included in the next version bump. This PR includes changesets to release 4 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Performance Benchmark (Lower is Faster)
|
There was a problem hiding this comment.
🟡 Changes recommended
Resuming without clearing entries for steps at/after fromStepId can expose stale outputs (and stale $workflows step data) if a goto targets an earlier step.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Adjusts Respect’s workflow execution context handling so same-workflow goto stepId does not discard previously produced step outputs, aligning runtime $steps.<id>.outputs.* resolution with expected Arazzo semantics and adding an e2e regression test.
Changes:
- Update
runWorkflowto avoid wipingctx.$stepswhen resuming execution from afromStepId(same-workflowgotopath). - Add a new Respect e2e fixture + snapshot validating that a cleanup step reached via
onFailure: gotocan read outputs from an earlier step. - Add a patch changeset for
@redocly/respect-coreand@redocly/cli.
File summaries
| File | Description |
|---|---|
packages/respect-core/src/modules/flow-runner/runner.ts |
Changes when $steps is cleared on workflow (re-)entry to preserve step outputs across same-workflow goto. |
tests/e2e/respect/goto-step-keeps-outputs/goto-step-keeps-outputs.test.ts |
Adds e2e test invoking respect against the new fixture. |
tests/e2e/respect/goto-step-keeps-outputs/goto-step-keeps-outputs.arazzo.yaml |
Adds an Arazzo workflow fixture that fails a step then gotos a cleanup step referencing earlier outputs. |
tests/e2e/respect/goto-step-keeps-outputs/__snapshots__/goto-step-keeps-outputs.test.ts.snap |
Snapshot asserting the expected CLI output for the new e2e scenario. |
.changeset/tall-moons-repeat.md |
Patch changeset documenting the fix. |
Review details
- Files reviewed: 5/5 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
What/Why/How?
Note
This was heavily assisted by Anthropic's Opus 5. I'm submitting it by hand, having done my due diligence on it. If I've missed something obvious, just say and I'll sort it out.
runWorkflowclearsctx.$stepson entry. Agototargeting astepIdre-entersrunWorkflowwithfromStepId, so outputs of steps that already ran are discarded:When
represent-groupfails, the goto fires anddelete-grouperrors:The Arazzo specification describes a
stepIdgoto as "a one-way transfer of workflow control" to a step "within the current workflow", and separately requires tools to treat runtime expression output references such as$steps.stepId.outputs.fieldas implicit dependencies and to ensure the referenced step completes before the referencing step executes.Neither statement discards step context, so clearing it on re-entry was never spec behaviour.
ctx.$stepsis now cleared only whenfromStepIdis absent. Agotoorretrythat names aworkflowIdstill goes throughresolveWorkflowContextand still gets a clean$stepsnamespace.Reference
No existing issue. #2735 and #2796 add action
parameters, which the specification limits to actions referencing aworkflowId, so they do not reach thestepIdcase.https://github.com/OAI/Arazzo-Specification/blob/main/versions/1.1.0.md#failure-action-object
Testing
tests/e2e/respect/goto-step-keeps-outputsruns the CLI against an Arazzo document where a failing step routesonFailure: gototo a later step that reads an earlier step's output. It fails onmainwith the error above and passes with this change.Screenshots (optional)
Check yourself
Security
Note
Medium Risk
Changes workflow execution context for goto/retry paths; behavior is narrower and spec-aligned but could affect workflows that accidentally relied on full
$stepsreset on re-entry.Overview
respectno longer wipes all$stepswhen agoto(or step retry) resumes a workflow from astepId. PreviouslyrunWorkflowalways resetctx.$stepson entry, so a same-workflowgotodropped outputs from steps that had already run and broke expressions like$steps.list-menu-items.outputs.menuItems.On a fresh workflow run,
$stepsis still cleared entirely. On resume viafromStepId, outputs from steps before the jump are kept; only step IDs in the slice that will run again are removed from$steps. Goto/retry that targets another workflow still goes throughresolveWorkflowContextand gets a clean step namespace as before.An e2e Respect test covers
onFailure: gototo a later step that reads an earlier step’s output.Reviewed by Cursor Bugbot for commit f158d11. Bugbot is set up for automated code reviews on this repo. Configure here.