Skip to content

feat(composition): allow self-referential sub-workflows with depth tracking (#103)#111

Open
PolyphonyRequiem wants to merge 5 commits intomicrosoft:mainfrom
PolyphonyRequiem:feat/self-referential-workflows
Open

feat(composition): allow self-referential sub-workflows with depth tracking (#103)#111
PolyphonyRequiem wants to merge 5 commits intomicrosoft:mainfrom
PolyphonyRequiem:feat/self-referential-workflows

Conversation

@PolyphonyRequiem
Copy link
Copy Markdown
Member

Summary

Removes the overly conservative circular reference check that prevented workflows from referencing themselves. The existing MAX_SUBWORKFLOW_DEPTH=10 limit already prevents infinite recursion — the path equality check was redundant.

Closes #103

Example

agents:
  - name: plan_children
    type: workflow
    workflow: ./self.yaml
    max_depth: 3
    input_mapping:
      work_item_id: "{{ item.id }}"

Changes

  • Remove file-path equality check in _execute_subworkflow()
  • Add optional max_depth field to AgentDef for per-agent depth control
  • Depth tracking (_subworkflow_depth) continues to enforce the global limit
  • Tests included

Dependency

Builds on #101 (input_mapping, PR #109) and #102 (for_each workflows, PR #110).

Daniel Green and others added 3 commits April 20, 2026 14:39
…rosoft#101)

Add input_mapping field to AgentDef for type='workflow' agents. When
present, each value is a Jinja2 expression rendered against the parent
context to build sub-workflow inputs. When absent, existing behavior
(forwarding parent's workflow.input.*) is preserved.

- Schema: Add input_mapping to AgentDef with validation for workflow-only
- Engine: Render input_mapping templates in _execute_subworkflow()
- Tests: Schema validation for all agent types
- Experimental workflows: test-input-mapping parent/child pair

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
)

Remove validator restriction blocking type='workflow' in for_each groups.
Wire execute_single_item() to call _execute_subworkflow_with_inputs()
for workflow agents, rendering input_mapping with loop variables in scope.

- Validator: Remove workflow rejection in for_each validation
- Engine: Add workflow branch in execute_single_item(), new helper
  _execute_subworkflow_with_inputs() for pre-built inputs
- Tests: Update test_workflow_in_for_each to validate (not reject)
- Experimental workflows: test-for-each-workflow parent/child pair

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…acking (microsoft#103)

Remove the circular reference path check that blocked workflows from
referencing themselves. The existing MAX_SUBWORKFLOW_DEPTH=10 already
prevents infinite recursion. Add optional per-agent max_depth field for
tighter author-controlled bounds.

- Engine: Remove self-reference path equality check in both
  _execute_subworkflow() and _execute_subworkflow_with_inputs()
- Engine: Add per-agent max_depth enforcement alongside global limit
- Schema: Add max_depth field to AgentDef with validation
- Tests: Replace circular reference test with depth-limit tests
- Experimental: test-recursive.yaml self-referential countdown

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@PolyphonyRequiem PolyphonyRequiem marked this pull request as draft April 21, 2026 21:13
@PolyphonyRequiem
Copy link
Copy Markdown
Member Author

Converted to draft — lint check failing. Schema and type check pass. Needs lint fixes before merging. Depends on PR #109 and PR #110 landing first.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Apr 21, 2026

Codecov Report

❌ Patch coverage is 45.45455% with 24 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (main@873c72b). Learn more about missing BASE report.

Files with missing lines Patch % Lines
src/conductor/engine/workflow.py 25.00% 21 Missing ⚠️
src/conductor/config/schema.py 81.25% 3 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main     #111   +/-   ##
=======================================
  Coverage        ?   84.64%           
=======================================
  Files           ?       53           
  Lines           ?     7202           
  Branches        ?        0           
=======================================
  Hits            ?     6096           
  Misses          ?     1106           
  Partials        ?        0           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@PolyphonyRequiem PolyphonyRequiem marked this pull request as ready for review April 21, 2026 21:41
- Remove json.loads coercion from input_mapping rendering (values stay
  as strings; use {{ expr | json }} filter for structured data)
- Add error context identifying which input_mapping key failed to render
- Fix falsy check: use 'is not None' instead of truthiness for input_mapping
- Deduplicate _execute_subworkflow_with_inputs into _execute_subworkflow
  with an optional sub_inputs parameter

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.

feat(composition): allow self-referential sub-workflows with depth tracking

2 participants