feat(engine): add workflow.dir, workflow.file, workflow.name template variables#121
Open
PolyphonyRequiem wants to merge 1 commit intomicrosoft:mainfrom
Open
feat(engine): add workflow.dir, workflow.file, workflow.name template variables#121PolyphonyRequiem wants to merge 1 commit intomicrosoft:mainfrom
PolyphonyRequiem wants to merge 1 commit intomicrosoft:mainfrom
Conversation
… variables
Adds three new template variables available in all agent contexts:
- {{ workflow.dir }} - absolute path to the workflow YAML's directory
- {{ workflow.file }} - absolute path to the workflow YAML file
- {{ workflow.name }} - workflow name from the YAML config
These enable script agents to resolve co-located scripts relative to
the workflow file rather than CWD, which is critical for registry-based
workflows where scripts live alongside the YAML in the registry directory.
Example:
args:
- -File
- {{ workflow.dir }}/scripts/detect-state.ps1
Available in all context modes (accumulate, last_only, explicit).
Empty strings are omitted from context to avoid polluting templates.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #121 +/- ##
=======================================
Coverage ? 84.88%
=======================================
Files ? 53
Lines ? 7178
Branches ? 0
=======================================
Hits ? 6093
Misses ? 1085
Partials ? 0 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds three new template variables available in all agent contexts:
{{ workflow.dir }}— absolute path to the workflow YAML's parent directory{{ workflow.file }}— absolute path to the workflow YAML file itself{{ workflow.name }}— workflow name from the YAML configMotivation
Script agents specify script paths in
args, but these resolve relative to CWD (whereconductor runis invoked). When workflows live in a registry (e.g.,~/.conductor/registries/twig/), co-located scripts can't be found because CWD is the user's project directory, not the registry.{{ workflow.dir }}solves this by letting scripts build paths relative to the workflow file:This matches how
!filetags already resolve prompt file paths relative to the workflow file.Changes
src/conductor/engine/context.py: Addworkflow_dir,workflow_file,workflow_namefields toWorkflowContext. Include them inbuild_for_agent()output under theworkflowdict (all context modes).src/conductor/engine/workflow.py: Set the new fields fromworkflow_pathduringWorkflowEngine.__init__().tests/test_engine/test_context.py: Tests for metadata in accumulate/explicit modes, and empty-string omission.Design decisions
workflow_pathis None (e.g., tests), the fields are empty strings and excluded from the context dict to avoid polluting templates.workflow.inputbehavior is unchanged. New fields are additive.Testing