You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A type="workflow" step's inline workflow {} body is compiled as an independent sub-workflow that does not inherit the parent workflow's agent blocks. Body steps that set agent = "<name>" fail at compile time with unknown agent. There is also no syntactic way to declare agents inside the body. As a result, the workflow-body iteration feature (W10) only works for adapter-only steps (shell, noop); any agent-driven sub-loop is currently impossible.
This also limits workflow_file = "..." since externally loaded body files are compiled through the same path — they cannot reference parent agents either, and the body-spec schema doesn't accept agent declarations of their own. The natural mental model — "a workflow body is a workflow, possibly loaded from a file, that should accept any block type a top-level workflow accepts" — does not currently hold.
WorkflowBodySpec has no Agents field (and no Variables, no Permissions).workflow/schema.go:108-118 declares only Steps, States, Waits, Approvals, Branches, Outputs. Agents cannot be declared inside a workflow {} block, even when the block is loaded from an external file via workflow_file.
buildBodySpec does not copy parent agents into the synthetic body Spec.workflow/compile_steps.go:421-469 constructs the body's Spec from wb.Steps/wb.States/etc. only. The enclosing workflow's agents are not threaded through. The same applies to variables and any other top-level workflow concept that should be visible to body steps.
The compile-time agent-existence check therefore fails on body steps.workflow/compile_steps.go:60-63 checks g.Agents[sp.Agent] against the body's own (empty) agent map.
— is the cleanest expression of "loop the executor↔reviewer cycle up to N times, exit early on approval, abort on failure." Without agent-in-body support, workstream automation has to fall back to flat explicit transitions and a hand-rolled shell-step counter, which obscures intent and hard-codes the bound across multiple state edges.
This blocks rewriting examples/workstream_review_loop.hcl to use the W10 iteration feature for its main agent loop. It also makes workflow_file = "..." substantially less useful: an external file cannot declare its own agents and cannot reference any from the loading workflow, so it's restricted to adapter-only chains.
Related
Add per-step visit limit to bound loops in workflows #12 — per-step max_visits is an alternative bounding mechanism for flat loops; it does not replace this gap because flat loops with a visit limit can't express "all_succeeded vs any_failed" aggregate routing the way type="workflow" + count does.
Summary
A
type="workflow"step's inlineworkflow {}body is compiled as an independent sub-workflow that does not inherit the parent workflow'sagentblocks. Body steps that setagent = "<name>"fail at compile time withunknown agent. There is also no syntactic way to declare agents inside the body. As a result, the workflow-body iteration feature (W10) only works for adapter-only steps (shell,noop); any agent-driven sub-loop is currently impossible.This also limits
workflow_file = "..."since externally loaded body files are compiled through the same path — they cannot reference parent agents either, and the body-spec schema doesn't accept agent declarations of their own. The natural mental model — "a workflow body is a workflow, possibly loaded from a file, that should accept any block type a top-level workflow accepts" — does not currently hold.Repro
Root cause
Three related gaps:
WorkflowBodySpechas noAgentsfield (and noVariables, noPermissions). workflow/schema.go:108-118 declares onlySteps,States,Waits,Approvals,Branches,Outputs. Agents cannot be declared inside aworkflow {}block, even when the block is loaded from an external file viaworkflow_file.buildBodySpecdoes not copy parent agents into the synthetic body Spec. workflow/compile_steps.go:421-469 constructs the body'sSpecfromwb.Steps/wb.States/etc. only. The enclosing workflow's agents are not threaded through. The same applies to variables and any other top-level workflow concept that should be visible to body steps.The compile-time agent-existence check therefore fails on body steps. workflow/compile_steps.go:60-63 checks
g.Agents[sp.Agent]against the body's own (empty) agent map.The two existing examples that exercise
type="workflow"(examples/for_each_review_loop.hcl, workflow/testdata/iteration_workflow_step.hcl) both useadapter = "noop"exclusively — there is zero coverage for the agent-in-body path.Impact
The natural pattern for a bounded agent review loop —
— is the cleanest expression of "loop the executor↔reviewer cycle up to N times, exit early on approval, abort on failure." Without agent-in-body support, workstream automation has to fall back to flat explicit transitions and a hand-rolled shell-step counter, which obscures intent and hard-codes the bound across multiple state edges.
This blocks rewriting
examples/workstream_review_loop.hclto use the W10 iteration feature for its main agent loop. It also makesworkflow_file = "..."substantially less useful: an external file cannot declare its own agents and cannot reference any from the loading workflow, so it's restricted to adapter-only chains.Related
max_visitsis an alternative bounding mechanism for flat loops; it does not replace this gap because flat loops with a visit limit can't express "all_succeeded vs any_failed" aggregate routing the waytype="workflow"+countdoes.