Skip to content

Inline sub-agents not extracted when workflow suppresses github-context block #39382

Description

@tsm-harmoney

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

  1. 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)
  2. Run gh aw compile

  3. Inspect the generated .lock.yml activation job — it will contain only a "Substitute placeholders" step, with no "Interpolate variables and render templates" step.

  4. 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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions