fix: emit interpolation step when prompt contains runtime-import macros - #49122
Conversation
The compiler always emits a {{#runtime-import}} self-import macro in
normal (non-inline) mode, but generateInterpolationAndTemplateStep
skipped generating the "Interpolate variables and render templates"
step when there were no expressions, no {{#if}} patterns, no GitHub
tool, and no inline sub-agents — even though that step is the only
consumer of {{#runtime-import}} macros (via interpolate_prompt.cjs).
Fix: compute hasRuntimeImports from the userPromptChunks in generatePrompt
(where chunks are already known) and pass it as an explicit bool parameter
to generateInterpolationAndTemplateStep. The step is now emitted whenever
any chunk starts with '{{#runtime-import '.
Closes #49102
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Updates prompt compilation to emit interpolation for runtime-import macros.
Changes:
- Detects runtime imports and passes that state into step generation.
- Extends interpolation-step guards and logging.
- Adds unit and end-to-end regression tests.
Show a summary per file
| File | Description |
|---|---|
pkg/workflow/compiler_yaml_prompt.go |
Detects runtime-import prompt chunks. |
pkg/workflow/template.go |
Includes runtime imports in interpolation-step generation. |
pkg/workflow/template_test.go |
Updates and expands unit tests. |
pkg/workflow/compiler_yaml_test.go |
Adds compilation regression coverage. |
Review details
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 4/4 changed files
- Comments generated: 1
- Review effort level: Medium
|
|
||
| c.generateInterpolationAndTemplateStep(yaml, expressionMappings, data) | ||
| hasRuntimeImports := sliceutil.Any(userPromptChunks, func(chunk string) bool { | ||
| return strings.HasPrefix(chunk, "{{#runtime-import ") |
|
Warning threat detection engine error DetailsThe threat detection engine failed to produce results. Review the workflow run logs for details. @copilot please run the Failed checks:
|
Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>
…w files JSON
- Change hasRuntimeImports detection from strings.HasPrefix to
strings.Contains so macros embedded after other text in a chunk are
detected correctly
- Also detect the optional form {{#runtime-import? ...}}
- Add github-mcp-server-pagination.md, syntax-engine.md, and
token-optimization-caching-budgets.md to the fallback aw files JSON
to fix TestFallbackAWFilesMatchesLocalAWDirectory
Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>
Fixed in commit Two changes:
The remaining CI failures ( |
PR Triage
Rationale: Small, well-scoped compiler fix (111+/13-, 6 files) with new unit tests covering the
|
|
@copilot add a integration workflow test that ensure the expansion is hapening |
|
Warning threat detection engine error DetailsThe threat detection engine failed to produce results. Review the workflow run logs for details. @copilot please run the
|
Add runtime_import_expansion_integration_test.go with three integration
tests covering the scenarios from the bug fix:
- TestRuntimeImportExpansionWithGitHubFalse: primary regression case —
github:false + no expressions must still emit the interpolation step
for the compiler's self-import runtime-import macro
- TestRuntimeImportExpansionWithOptionalMacro: optional {{#runtime-import?}}
form also triggers the interpolation step
- TestRuntimeImportExpansionWithMacroAfterText: macro embedded after other
body text is still detected (strings.Contains, not HasPrefix)
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Added
|
|
Warning threat detection engine error DetailsThe threat detection engine failed to produce results. Review the workflow run logs for details. 🎯 Excellent Work on This Runtime-Import FixThanks for addressing the silent failure in #49102! This fix correctly identifies a critical compiler bug where workflows with ✅ Evaluation Against GuidelinesThis PR aligns perfectly with the project's contribution model:
Implementation QualityThe fix is surgical and well-reasoned:
The PR is ready for review and merge. Warning Firewall blocked 1 domainThe following domain was blocked by the firewall during workflow execution:
To allow these domains, add them to the network:
allowed:
- defaults
- "patchdiff.githubusercontent.com"See Network Configuration for more information.
|
|
🎉 This pull request is included in a new release. Release: |
In normal (non-inline) compilation mode the compiler unconditionally emits a
{{#runtime-import <workflow>.md}}self-import macro into the prompt, butgenerateInterpolationAndTemplateStepwould skip generating the "Interpolate variables and render templates" step when none of its four existing guards fired — most commonly whentools.github: falsewith no expressions or{{#if}}blocks. Sinceinterpolate_prompt.cjsis the only consumer of{{#runtime-import}}macros, the macro reached the agent unresolved and the entire workflow body was silently dropped.Changes
pkg/workflow/compiler_yaml_prompt.go— after buildinguserPromptChunks, computehasRuntimeImportsby checking whether any chunk starts with{{#runtime-import(usingsliceutil.Any), then pass it as a new parameter togenerateInterpolationAndTemplateStep.pkg/workflow/template.go— addhasRuntimeImports boolparameter; fold it into the skip guard so the step is always emitted when runtime-import macros are present:pkg/workflow/template_test.go— update existing call sites; addTestGenerateInterpolationAndTemplateStep_WithRuntimeImportcovering the previously-silent skip.pkg/workflow/compiler_yaml_test.go— addTestInterpolationStepPresentWithGitHubFalse, an end-to-end regression that compiles the exact failing frontmatter (github: false, no expressions, no{{#if}}) and asserts both the{{#runtime-import}}macro and the interpolation step are present in the generated lock file.Warning
threat detection engine error
The threat detection engine encountered an error and could not complete analysis. This is a tooling failure, not a security finding.
Details
The threat detection engine failed to produce results.
Review the workflow run logs for details.