fix(workflows): propagate run cancellation into sub_workflow children (#675) - #767
Conversation
Advances the vendor/openhuman submodule to pick up tinyflows 0.6.1, which threads a parent run's cancellation token into sub_workflow children. The [patch] path dependency now resolves to 0.6.1 in Cargo.lock.
A full-stack regression: parent trigger -> sub_workflow(child) -> done, child trigger -> slow -> marker -> done. Cancelling while the child's slow node is mid-flight must reach the child run so its downstream marker node never executes, the run settles cancelled, and it winds down cleanly (bounded by the in-flight node's remainder, not the hard-abort grace). Verified to fail before the tinyflows fix (marker ran) and pass after.
📝 WalkthroughWalkthroughThe vendored workflow engine reference is updated. A regression test verifies cancellation propagation from a parent workflow to a nested child workflow and confirms clean cancellation before the hard-abort grace period. ChangesNested workflow cancellation
Estimated code review effort: 3 (Moderate) | ~20 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (4 passed)
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 |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/workflows/runner.rs (1)
2256-2269: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueRemove the unused
promptkeys from the child workflow fixture.
parse_workflowtolerates unknown keys, andtranslate::prompt_forusessummaryto generate the agent prompt. Keepsummaryand remove bothpromptassignments.🤖 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 `@src/workflows/runner.rs` around lines 2256 - 2269, Remove the unused prompt assignments from the child workflow fixture nodes slow and marker. Keep their summary fields unchanged so translate::prompt_for continues generating the agent prompts from summary.
🤖 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.
Nitpick comments:
In `@src/workflows/runner.rs`:
- Around line 2256-2269: Remove the unused prompt assignments from the child
workflow fixture nodes slow and marker. Keep their summary fields unchanged so
translate::prompt_for continues generating the agent prompts from summary.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: a407d770-6ad1-4aab-9daf-9743926b5df4
⛔ Files ignored due to path filters (1)
Cargo.lockis excluded by!**/*.lock
📒 Files selected for processing (2)
src/workflows/runner.rsvendor/openhuman
|
This fixes our #675, which this fleet investigated earlier today, so I reviewed it against what that investigation established. Not an approval. It matches the diagnosis, including the part that was easy to get wrongOur investigation concluded the child receives More importantly, it does not take the workaround we considered and rejected on mechanism. That idea was to have the child's capability refuse once the parent was cancelled — rejected because a refusing capability surfaces as a node error, so a graph with The type system is already on your side here, which is worth stating because it is why the test's assertion is meaningful rather than incidental: The test itself is well built: a node that holds open until the operator cancels makes the cancel land deterministically while the child is mid-flight, One question, on the audit trail rather than the mechanismThe test asserts the parent run reports The concern is an orphan: if the child run is abandoned mid-flight rather than settled, its record could sit at "running" indefinitely, which is the same audit-trail damage as the rejected workaround, reached from the other side. If the upstream fix settles the child, one extra assertion on the child's run state would pin it and make this test cover the whole boundary. If it does not settle it, that is worth knowing before this merges — and I would rather ask than assert, since the mechanism lives in the submodule and I did not read the tinyflows side. HousekeepingCurrently DIRTY — Not coveredI did not read the tinyflows/openhuman side of the fix, and I did not build or run the test. |
…ncel fix (tinyhumansai#675) Pins vendor/openhuman to acab11b9 (openhuman main tip, merge of #5520), which pins vendor/tinyflows at 4357473 — the merged tinyflows tinyhumansai#31 sub-workflow cancel-token fix that this chain (tinyhumansai#675) exists to deliver. Conflict resolution: - vendor/openhuman: fast-forward pin 2826259d..acab11b9 (clean descendant). - Cargo.lock: took main's, then `cargo check` reconciled the vendored tinyflows bump to 0.6.1. tinyflows 0.6.1 also introduces NodeKind::Shell + Capabilities.shell (Option<Arc<dyn ShellRunner>>). Adapted OC to the new API per the repo's own convention: shell is left unwired (`shell: None`, mirroring `memory`) so a shell node fails with a capability error, and NodeKind::Shell joins Code/Memory in gate.rs's `=> None` arm as an effectful-but-stubbed capability. Both sites are documented; the exhaustive match by design turned the new variant into a compile error to force this decision.
Summary
Propagates run cancellation into
sub_workflowchildren. Previously, cancelling a run did not stop a running sub_workflow child — the child kept scheduling node work after the operator hit Cancel, and its cancelled outcome was reported as a hard error, falsely failing a run the operator merely stopped.The actual engine fix lives in the vendored
tinyflowscrate (parent cancellation token now threaded throughrun_sub_workflowinto child node contexts, transitively at any depth). This PR pulls that fix in via the openhuman submodule bump and pins the behavior with an opencompany-side regression test.Closes #675.
Cross-repo chain — now complete (this PR is the final step):
4357473.vendor/openhumanatacab11b9(openhuman main tip, the merge of #5520), which carriesvendor/tinyflowsat4357473. Both upstream links are merged, so submodule pointers resolve on upstream and this is unblocked to merge.API Or Behavior Changes
Behavior: cancelling a run now winds down in-flight
sub_workflowchildren instead of letting them run effectful nodes past Cancel, and an operator-cancelled child settles as cancelled rather than erroring. Cancellation remains boundary-only — settle is bounded by the in-flight node's remainder (parity with existing top-level run cancellation; no mid-node preemption). No public API surface added on the opencompany side.Adaptation carried by the pin bump: tinyflows 0.6.1 also adds
NodeKind::ShellandCapabilities.shell(Option<Arc<dyn ShellRunner>>). OC adapts to the new API following the repo's existing convention —shellis left unwired (shell: None, mirroringmemory), so ashellnode fails at run time with a capability error, andNodeKind::ShelljoinsCode/Memoryingate.rs's=> Nonearm as an effectful-but-stubbed capability. Noshellnode is authorable from a company manifest today.Tests
The
runner.rsregression testa_parent_cancel_propagates_into_a_sub_workflow_childis the OC-side proof that cancellation now propagates through the vendored engine. The engine-level T1–T5 matrix (with T1/T2 failing on the pre-fix engine) lives in the tinyflows PR.Union build run locally against the freshly-synced main (this is #779's new openhuman integration + the cancel test together):
cargo fmt --all -- --checkcargo clippy --no-deps --features openhuman,tinycortex --all-targets -- -D warningscargo check --all-targetsandcargo check --all-featuresRUST_MIN_STACK=16777216 cargo test --locked --features openhuman,tinycortex --tests— green, including the cancel test above (the CI stack size is required; the agent loop overflows the default stack).Honest note: live-host manual cancel has not been run — the deterministic
runner.rstest harness stands in for it.Documentation
N/A: behavior fix with no user-facing doc surface; the cancellation semantics are described inline in the regression test and the tinyflows PR.
Summary by CodeRabbit
Bug Fixes
Tests