Description
When a workflow .md file contains inline {{#runtime-import}} macros in the prompt body, those macros are expanded twice in the final prompt sent to the agent.
Root cause
The compiled .lock.yml always includes the workflow body itself as the last runtime-import entry:
{{#runtime-import .github/workflows/shared/agent/some-shared-content.md}} ← Import 5
{{#runtime-import .github/workflows/shared/agent/another-content.md}} ← Import 6
{{#runtime-import .github/workflows/my-workflow.md}} ← Import 8 (self)
At runtime, the import resolver:
- Expands Import 5 (
some-shared-content.md) → content appears once
- Expands Import 6 (
another-content.md) → content appears once
- Expands Import 8 (
my-workflow.md) → recursively processes the workflow body, which contains the {{#runtime-import}} macros for Imports 5 and 6 → content appears a second time
The recursive expansion of the self-import does not skip macros that were already resolved in the top-level pass.
Observed impact
- Content from shared
.md imports appears 2x in the generated prompt
- In a real workflow with 3 inline runtime-imports, the prompt contained each shared block duplicated, wasting tokens and potentially confusing the model with redundant instructions
- Verified by inspecting the "Print prompt" step in the activation job logs —
<wiki-context> block appeared twice, <subagent-delegation> appeared 4 times
Expected behavior
Each {{#runtime-import}} macro should be resolved exactly once in the final prompt, regardless of whether it appears in a top-level import or is discovered during recursive expansion of the workflow body.
Suggested fix
During recursive import processing, track which import paths have already been resolved. Skip any macro whose target path matches an already-expanded import. This would be a simple set-based deduplication in the runtime import resolver.
Reproduction
- Create a workflow
.md with an inline {{#runtime-import shared/agent/foo.md}} in the prompt body
- Compile with
gh aw compile
- Dispatch the workflow
- Check the "Print prompt" activation step — the content of
foo.md will appear twice
Version
gh aw v0.71.5
Description
When a workflow
.mdfile contains inline{{#runtime-import}}macros in the prompt body, those macros are expanded twice in the final prompt sent to the agent.Root cause
The compiled
.lock.ymlalways includes the workflow body itself as the last runtime-import entry:At runtime, the import resolver:
some-shared-content.md) → content appears onceanother-content.md) → content appears oncemy-workflow.md) → recursively processes the workflow body, which contains the{{#runtime-import}}macros for Imports 5 and 6 → content appears a second timeThe recursive expansion of the self-import does not skip macros that were already resolved in the top-level pass.
Observed impact
.mdimports appears 2x in the generated prompt<wiki-context>block appeared twice,<subagent-delegation>appeared 4 timesExpected behavior
Each
{{#runtime-import}}macro should be resolved exactly once in the final prompt, regardless of whether it appears in a top-level import or is discovered during recursive expansion of the workflow body.Suggested fix
During recursive import processing, track which import paths have already been resolved. Skip any macro whose target path matches an already-expanded import. This would be a simple set-based deduplication in the runtime import resolver.
Reproduction
.mdwith an inline{{#runtime-import shared/agent/foo.md}}in the prompt bodygh aw compilefoo.mdwill appear twiceVersion
gh aw v0.71.5