Bug: Inline sub-agents not extracted when workflow suppresses github-context block
Compiler version: v0.79.6
Affected workflow feature: Inline sub-agents (## agent: <name> blocks)
Summary
When a workflow defines inline sub-agents using ## agent: <name> blocks but suppresses the standard <github-context> prompt block (e.g. by setting tools: github: false), gh aw compile omits the "Interpolate variables and render templates" step from the generated activation job. This step calls interpolate_prompt.cjs, which is responsible for extracting ## agent: blocks and writing them as .agent.md files to /tmp/gh-aw/.github/agents/. Without this step, the activation artifact never contains the sub-agent files, so the subsequent "Restore inline sub-agents from activation artifact" step in the agent job silently finds nothing.
Steps to Reproduce
-
Create a workflow markdown file that:
- Has one or more
## agent: <name> inline sub-agent definitions
- Sets
tools: github: false (or any option that suppresses the injected <github-context> block with {{#if ...}} conditionals)
-
Run gh aw compile
-
Inspect the generated .lock.yml activation job — it will contain only a "Substitute placeholders" step, with no "Interpolate variables and render templates" step.
-
Trigger the workflow. In the agent job, the step "Restore inline sub-agents from activation artifact" logs:
[restore-sub-agents] source directory not found — no inline sub-agents to restore
Root Cause
The compiler decides whether to emit interpolate_prompt.cjs based on whether the generated prompt contains template expressions — specifically {{#if ...}} conditionals and __GH_AW_EXPR_*__ placeholders. These are injected automatically as part of the standard <github-context> boilerplate for most workflows. When they are present, interpolate_prompt.cjs is needed to evaluate the conditionals, so the step is emitted.
However, when a workflow sets tools: github: false, the compiler suppresses the <github-context> block and its template expressions. With no template expressions in the prompt, the compiler concludes interpolate_prompt.cjs is unnecessary and emits only substitute_placeholders.cjs instead.
The flaw: interpolate_prompt.cjs is also the step that extracts ## agent: blocks and writes them to /tmp/gh-aw/.github/agents/. This extraction is entirely unrelated to template expression evaluation. Skipping the step means:
- The
{{#runtime-import .github/workflows/<name>.md}} macro in the prompt is never expanded (the workflow body is never inlined into the prompt)
- The
## agent: \name`blocks are never extracted to/tmp/gh-aw/.github/agents/`
- The activation artifact is uploaded with an empty
.github/agents/ directory
restore_inline_sub_agents.sh in the agent job has nothing to copy
Verification
A minimal workflow with only on: workflow_dispatch and a ## agent: block compiles correctly — the compiler injects the <github-context> block, which carries template expressions, which triggers interpolate_prompt.cjs, which extracts the sub-agents as a side effect.
The same workflow with tools: github: false added would lose the <github-context> injection, drop interpolate_prompt.cjs, and silently break sub-agent discovery.
Expected Behaviour
gh aw compile should emit the "Interpolate variables and render templates" step whenever the workflow markdown contains either:
- Template expressions in the generated prompt (current behaviour), or
- One or more
## agent: <name> inline sub-agent definitions (missing from current behaviour)
The two concerns — template evaluation and sub-agent extraction — are independent and should each independently gate inclusion of the step.
Bug: Inline sub-agents not extracted when workflow suppresses github-context block
Compiler version: v0.79.6
Affected workflow feature: Inline sub-agents (
## agent: <name>blocks)Summary
When a workflow defines inline sub-agents using
## agent: <name>blocks but suppresses the standard<github-context>prompt block (e.g. by settingtools: github: false),gh aw compileomits the "Interpolate variables and render templates" step from the generated activation job. This step callsinterpolate_prompt.cjs, which is responsible for extracting## agent:blocks and writing them as.agent.mdfiles to/tmp/gh-aw/.github/agents/. Without this step, the activation artifact never contains the sub-agent files, so the subsequent "Restore inline sub-agents from activation artifact" step in the agent job silently finds nothing.Steps to Reproduce
Create a workflow markdown file that:
## agent: <name>inline sub-agent definitionstools: github: false(or any option that suppresses the injected<github-context>block with{{#if ...}}conditionals)Run
gh aw compileInspect the generated
.lock.ymlactivation job — it will contain only a "Substitute placeholders" step, with no "Interpolate variables and render templates" step.Trigger the workflow. In the agent job, the step "Restore inline sub-agents from activation artifact" logs:
Root Cause
The compiler decides whether to emit
interpolate_prompt.cjsbased on whether the generated prompt contains template expressions — specifically{{#if ...}}conditionals and__GH_AW_EXPR_*__placeholders. These are injected automatically as part of the standard<github-context>boilerplate for most workflows. When they are present,interpolate_prompt.cjsis needed to evaluate the conditionals, so the step is emitted.However, when a workflow sets
tools: github: false, the compiler suppresses the<github-context>block and its template expressions. With no template expressions in the prompt, the compiler concludesinterpolate_prompt.cjsis unnecessary and emits onlysubstitute_placeholders.cjsinstead.The flaw:
interpolate_prompt.cjsis also the step that extracts## agent:blocks and writes them to/tmp/gh-aw/.github/agents/. This extraction is entirely unrelated to template expression evaluation. Skipping the step means:{{#runtime-import .github/workflows/<name>.md}}macro in the prompt is never expanded (the workflow body is never inlined into the prompt)## agent: \name`blocks are never extracted to/tmp/gh-aw/.github/agents/`.github/agents/directoryrestore_inline_sub_agents.shin the agent job has nothing to copyVerification
A minimal workflow with only
on: workflow_dispatchand a## agent:block compiles correctly — the compiler injects the<github-context>block, which carries template expressions, which triggersinterpolate_prompt.cjs, which extracts the sub-agents as a side effect.The same workflow with
tools: github: falseadded would lose the<github-context>injection, dropinterpolate_prompt.cjs, and silently break sub-agent discovery.Expected Behaviour
gh aw compileshould emit the "Interpolate variables and render templates" step whenever the workflow markdown contains either:## agent: <name>inline sub-agent definitions (missing from current behaviour)The two concerns — template evaluation and sub-agent extraction — are independent and should each independently gate inclusion of the step.