Skip to content

Prompt content from imports with steps: appears after prompt-only imports, breaking declared import order #36678

@yskopets

Description

@yskopets

🤖 This issue has been filed by Claude Code.

Problem

When a workflow declares imports in a specific order, you would expect the combined agent prompt to present content in that same order. The compiler, however, treats shared files differently depending on whether they contain steps::

  • Prompt-only files (no steps:) — prose is inlined at compile time, in place.
  • Files with steps: — their prose documentation is emitted as a compiler-generated {{#runtime-import …}} placeholder at the end of the prompt heredoc, after all inlined content.

This means the effective prompt ordering can differ significantly from the declared import order.

Minimal Reproduction

# my-workflow.md
imports:
  - shared/infra.md        # has steps: AND some prose/docs
  - shared/instructions.md # prompt-only, no steps

Compiled lock file prompt body (schematic):

# shared/instructions.md prose (inlined at compile time)
...instructions content...

{{#runtime-import .github/workflows/shared/infra.md}}   ← placed last, despite being declared first
{{#runtime-import .github/workflows/my-workflow.md}}

Even though shared/infra.md was declared first in imports:, its prose ends up after shared/instructions.md's content in the running agent's context.

This is particularly surprising because:

  1. The imports: list looks sequential — developers naturally expect the agent to see content in that order.
  2. The behaviour is undocumented: the reference docs describe {{#runtime-import}} as something authors write explicitly, not as something the compiler generates automatically for any import that happens to have steps:.
  3. When the prose of a "setup" import is meant to orient the agent before task-specific instructions, having it appear after them can change agent behaviour.

Expected Behaviour

Prompt content (whether statically inlined or emitted as a {{#runtime-import}}) should appear in the order the imports are declared. If shared/infra.md is listed before shared/instructions.md, the agent should see shared/infra.md's prose before shared/instructions.md's prose — regardless of whether each is rendered statically or dynamically.

Suggested Fix Direction

Preserve the relative ordering of compiler-generated {{#runtime-import}} placeholders according to import declaration order, interleaved with any statically inlined content at the positions those imports occupy in the list.

Alternatively, document the current behaviour clearly so authors can work around it by reordering their imports: list or using explicit {{#runtime-import}} in the workflow body.

Metadata

Metadata

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions