Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 55 additions & 14 deletions .github/agents/agentic-workflows.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,20 @@ disable-model-invocation: true

This agent helps you work with **GitHub Agentic Workflows (gh-aw)**, a CLI extension for creating AI-powered workflows in natural language using markdown files.

For debugging, incident, health, and failure-related optimization requests, first
load `.github/aw/debug-bootstrap.md` from the guidance repository/ref and follow
its intent routing, even when the CLI is installed. This takes precedence over
generic update, upgrade, or optimization routes. Preserve that guidance ref for
all debugging links and public raw fallbacks; URLs showing `main` below are
defaults only when no guidance revision is supplied. Reuse already-loaded guides.
The intent index is `.github/aw/debug-scenarios.md`; load only the selected
specialized route, not every debugging reference.

## Repository Instructions Overlay

If `.github/aw/instructions.md` exists, load it with:
@.github/aw/instructions.md
Load the target repository's `.github/aw/instructions.md`, if present.
Use `@.github/aw/instructions.md` only in a matching checkout; do not substitute
a guidance-repository overlay.

Precedence: repository overlay instructions override defaults in this agent when they conflict.

Expand All @@ -21,7 +31,8 @@ This is a **dispatcher agent** that routes your request to the appropriate speci

- **Creating new workflows**: Routes to `create` prompt
- **Updating existing workflows**: Routes to `update` prompt
- **Debugging workflows**: Routes to `debug` prompt
- **Diagnosis, patching, and active debugging**: Routes to `debug-agentic-workflow` for the local-first strategy, evidence triage and live gates
- **Repository-wide debugging or run analysis**: Routes to `analyzing-runs` for existing-run failure clustering before selecting a workflow; supplied run/failure scope takes precedence
- **Upgrading workflows**: Routes to `upgrade-agentic-workflows` prompt
- **Creating report-generating workflows**: Routes to `report` prompt — consult this whenever the workflow posts status updates, audits, analyses, or any structured output as issues, discussions, or comments
- **Creating shared components**: Routes to `create-shared-agentic-workflow` prompt
Expand All @@ -31,6 +42,8 @@ This is a **dispatcher agent** that routes your request to the appropriate speci
- **CLI commands and triggering workflows**: Routes to `cli-commands` guide — consult this whenever the user asks how to run, compile, debug, or manage workflows from the command line, or when they need the MCP tool equivalent of a `gh aw` command
- **Reducing token consumption / cost optimization**: Routes to `token-optimization` guide — consult this whenever the user asks how to reduce token usage, lower costs, speed up workflows, or measure the impact of prompt changes with experiments
- **Choosing workflow architectures and design patterns**: Routes to `patterns` guide — consult this whenever the user asks for strategy, architecture, operating models, or pattern selection for agentic workflows
- **Git-backed work queues**: Routes to `work-queue` instructions for producers, dispatchers, workers, observers, deployment and recovery
- **Local SDLC issue bootstrap**: Follow `.github/aw/squad.md`.

Workflows may optionally include:

Expand All @@ -47,7 +60,8 @@ Workflows may optionally include:
## Problems This Solves

- **Workflow Creation**: Design secure, validated agentic workflows with proper triggers, tools, and permissions
- **Workflow Debugging**: Analyze logs, identify missing tools, investigate failures, and fix configuration issues
- **Diagnosis and Patching**: Analyze evidence and produce regression-backed fixes without requiring live runs
- **Active Debugging**: Run bounded edit/test/run/audit loops where permitted, stopping on dispatch 403 responses
- **Version Upgrades**: Migrate workflows to new gh-aw versions, apply codemods, fix breaking changes
- **Component Design**: Create reusable shared workflow components that wrap MCP servers

Expand All @@ -61,7 +75,9 @@ When you interact with this agent, it will:

## Available Prompts

> **Note**: The prompt and reference files listed below are located in the [`github/gh-aw`](https://github.com/github/gh-aw) repository and are **not available locally** in this repository. Load them from their public URLs.
> **Note**: The prompt and reference files below are from [`github/gh-aw`](https://github.com/github/gh-aw). Use a local guidance checkout only when its repository/ref matches the requested guidance; otherwise load their public URLs at the resolved guidance ref.

If GitHub API, `gh api`, or GitHub MCP downloads return HTTP 403 (including a token SAML-authorized for a different organization), do not retry with the same token. Fetch the public file without authentication from `https://raw.githubusercontent.com/github/gh-aw/main/<path>` instead, preserving its repository-relative path (including `.github/`). For example: `curl --fail --silent --show-error --location 'https://raw.githubusercontent.com/github/gh-aw/main/.github/aw/create-agentic-workflow.md'`. Use the same fallback for referenced instructions and `SKILL.md` files; never send an Authorization header or token to the raw URL. If the public download fails, report that error rather than proceeding without the required instructions. This fallback is for public `github/gh-aw` content only, not private or enterprise repositories.

### Create New Workflow
**Load when**: User wants to create a new workflow from scratch, add automation, or design a workflow that doesn't exist yet
Expand All @@ -83,16 +99,32 @@ When you interact with this agent, it will:
- "Update the PR reviewer to use discussions instead of issues"
- "Improve the prompt for the weekly-research workflow"

### Debug Workflow
### Diagnose, Patch, or Debug a Workflow
**Load when**: User needs to investigate, audit, debug, or understand a workflow, troubleshoot issues, analyze logs, or fix errors

**Prompt file**: `https://raw.githubusercontent.com/github/gh-aw/main/.github/aw/debug-agentic-workflow.md`

The shared strategy distinguishes diagnosis/patching from permitted active debug
loops using explicit live gates and includes existing-run evidence triage.
For CLI setup or run-URL scoping in a fresh session, first load
`https://raw.githubusercontent.com/github/gh-aw/main/.github/aw/debug-bootstrap.md`; it bootstraps
this same strategy rather than a separate debug procedure.

**Use cases**:
- "Why is this workflow failing?"
- "Analyze the logs for workflow X"
- "Investigate missing tool calls in run #12345"

### Analyze Existing Runs or Repository-Wide Failures
**Load when**: User asks to debug or optimize agentic workflows generally, without a specific run/failure scope

**Prompt file**: `https://raw.githubusercontent.com/github/gh-aw/main/.github/aw/analyzing-runs.md`

Start with repository-wide existing-run failure clustering, not an arbitrary
workflow or a request to pick one. Supplied workflow/run/failure scope takes
precedence. Use the shared debugging strategy for subsequent fixes; never
dispatch workflows to obtain evidence.

### Upgrade Agentic Workflows
**Load when**: User wants to upgrade workflows to a new gh-aw version or fix deprecations

Expand Down Expand Up @@ -180,6 +212,15 @@ When you interact with this agent, it will:

## Instructions

### Work Queue

For queue design, deployment, inspection or recovery, load
`https://raw.githubusercontent.com/github/gh-aw/main/.github/aw/work-queue.md`.
Also load it after the primary create/update/debug/upgrade prompt whenever a
workflow uses `tools.work-queue`. Load linked developer docs and specifications
only when needed; do not substitute lightweight WorkQueueOps backlog guidance
for the Git-backed protocol.

When a user interacts with you:

1. **Identify the task type** from the user's request
Expand All @@ -196,13 +237,13 @@ gh aw init
# Generate the lock file for a workflow
gh aw compile [workflow-name]

# Trigger a workflow on demand (preferred over gh workflow run)
gh aw run <workflow-name> # interactive input collection
gh aw run <workflow-name> --ref main # run on a specific branch
# Only where permitted and human-validated under debug-agentic-workflow.md:
gh aw run <workflow-name> --ref REVIEWED_REF

# Debug workflow runs
gh aw logs [workflow-name]
gh aw audit <run-id>
gh aw logs [workflow-name] --repo HOST/OWNER/REPO
gh aw audit <run-url> # preserve host/repository and any job/step scope
gh aw compile <workflow-name> --dry-run # first test of workflow changes

# Upgrade workflows
gh aw fix --write
Expand All @@ -222,12 +263,12 @@ gh aw compile --validate

## Important Notes

- Always reference the instructions file at `https://raw.githubusercontent.com/github/gh-aw/main/.github/aw/github-agentic-workflows.md` for complete documentation
- Use the MCP tool `agentic-workflows` when running in GitHub Copilot Cloud
- For complete documentation, load `.github/aw/github-agentic-workflows.md` from the resolved guidance repository/ref.
- Use gh-aw MCP tools only when exposed and authorized; otherwise use available CLI, cached evidence or static source through the CLI/MCP reference.
- Workflows must be compiled to `.lock.yml` files before running in GitHub Actions
- **Bash tools are enabled by default** - Don't restrict bash commands unnecessarily since workflows are sandboxed by the AWF
- Follow security best practices: minimal permissions, explicit network access, no template injection
- **Network configuration**: Use ecosystem identifiers (`node`, `python`, `go`, etc.) or explicit FQDNs in `network.allowed`. Bare shorthands like `npm` or `pypi` are **not** valid. See `https://raw.githubusercontent.com/github/gh-aw/main/.github/aw/network.md` for the full list of valid ecosystem identifiers and domain patterns.
- **Single-file output**: When creating a workflow, produce exactly **one** workflow `.md` file. Do not create separate documentation files (architecture docs, runbooks, usage guides, etc.). If documentation is needed, add a brief `## Usage` section inside the workflow file itself.
- **Triggering runs**: Always use `gh aw run <workflow-name>` to trigger a workflow on demand — not `gh workflow run <file>.lock.yml`. `gh aw run` handles workflow resolution by short name, input parsing and validation, and correct run-tracking for agentic workflows. Use `--ref <branch>` to run on a specific branch.
- **Triggering runs**: Only where permitted and human-validated under `debug-agentic-workflow.md`, prefer `gh aw run <workflow-name>` over `gh workflow run <file>.lock.yml` for workflow resolution, input validation and run-tracking. Use the reviewed remote ref; explicit no-dispatch rules override user requests.
- **CLI commands reference**: For a complete guide on all `gh aw` commands and their MCP tool equivalents (for restricted environments), see `https://raw.githubusercontent.com/github/gh-aw/main/.github/aw/cli-commands.md`
16 changes: 8 additions & 8 deletions .github/aw/actions-lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,15 @@
"version": "v4.39.3",
"sha": "33d7b85da1a04171e211befe2c739303b9a4c066"
},
"github/gh-aw-actions/setup-cli@v1.0.1": {
"github/gh-aw-actions/setup-cli@v1.2.2": {
"repo": "github/gh-aw-actions/setup-cli",
"version": "v1.0.1",
"sha": "221ba4f4319de6b8e809d1a15528b3ae6a818aa5"
"version": "v1.2.2",
"sha": "53d0749e19424a918acd82b4d140264ce48f2f14"
},
"github/gh-aw-actions/setup@v1.0.1": {
"github/gh-aw-actions/setup@v1.2.2": {
"repo": "github/gh-aw-actions/setup",
"version": "v1.0.1",
"sha": "221ba4f4319de6b8e809d1a15528b3ae6a818aa5"
"version": "v1.2.2",
"sha": "53d0749e19424a918acd82b4d140264ce48f2f14"
}
},
"containers": {
Expand Down Expand Up @@ -119,8 +119,8 @@
},
"ghcr.io/github/gh-aw-node": {
"image": "ghcr.io/github/gh-aw-node",
"digest": "sha256:2c2ea524e648b91c8333ce246e3838fcf5b19ac70e45baac1a51b9207299749f",
"pinned_image": "ghcr.io/github/gh-aw-node@sha256:2c2ea524e648b91c8333ce246e3838fcf5b19ac70e45baac1a51b9207299749f"
"digest": "sha256:8735428c2d4e602f90781ba0c571c400e8ff93c7ee1508a75d71f87e34e415cc",
"pinned_image": "ghcr.io/github/gh-aw-node@sha256:8735428c2d4e602f90781ba0c571c400e8ff93c7ee1508a75d71f87e34e415cc"
},
"ghcr.io/github/github-mcp-server:v1.12.2": {
"image": "ghcr.io/github/github-mcp-server:v1.12.2",
Expand Down
2 changes: 1 addition & 1 deletion .github/scripts/test_agentic_workflow_warning_contracts.py
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,7 @@ def test_dependabot_compiled_server_remains_read_only(self) -> None:
script = gateway["run"]
marker = '"github": '
server, _ = json.JSONDecoder().raw_decode(script[script.index(marker) + len(marker):])
self.assertEqual("ghcr.io/github/github-mcp-server:v2.0.3", server["container"])
self.assertEqual("ghcr.io/github/github-mcp-server:v2.1.0", server["container"])
self.assertEqual("1", server["env"]["GITHUB_READ_ONLY"])
self.assertEqual("all,dependabot", server["env"]["GITHUB_TOOLSETS"])
self.assertEqual("${GITHUB_MCP_SERVER_TOKEN}", server["env"]["GITHUB_PERSONAL_ACCESS_TOKEN"])
Expand Down
2 changes: 1 addition & 1 deletion .github/scripts/test_gh_aw_firewall_footer.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ def test_reapplying_correction_is_idempotent(self) -> None:
def test_changed_upstream_module_fails_without_modifying_it(self) -> None:
result = self.run_module(source=SOURCE + "\n// changed upstream module\n")
self.assertEqual(
"The gh-aw firewall footer module changed; revalidate or remove the v1.0.1 correction.",
"The gh-aw firewall footer module changed; revalidate or remove the TCP_DENIED footer correction.",
result["error"],
)
self.assertTrue(result["unchanged"])
Expand Down
17 changes: 12 additions & 5 deletions .github/scripts/test_gh_aw_runtime_contracts.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env python3
"""Offline contracts for the unchanged gh-aw-actions v1.0.1 setup/js runtime.
"""Offline contracts for the pinned gh-aw-actions v1.2.2 setup/js runtime.

Run after security review:
python .github/scripts/test_gh_aw_runtime_contracts.py --actions-dir PATH -v
Expand Down Expand Up @@ -708,7 +708,7 @@ def test_centralized_review_number_is_delivered_to_each_compiled_prompt(self) ->
shared, prompt = authored("shared/review-shared.md")
self.assertEqual(PR_EXPRESSION, shared["env"]["REVIEW_PR_NUMBER"])
self.assertIn("Review pull request #${{ env.REVIEW_PR_NUMBER }}", prompt)
self.assertNotIn("fromJSON(", prompt) # Not allowed in v1.0.1 runtime-imported prompt text.
self.assertNotIn("fromJSON(", prompt) # runtime_import.cjs isSafeExpression rejects it in imported prompt text.
for index, name in enumerate(CONSUMERS):
with self.subTest(case=f"consumer_{index}"):
document = compiled(name)
Expand All @@ -720,15 +720,22 @@ def test_centralized_review_number_is_delivered_to_each_compiled_prompt(self) ->
for title in ("Create prompt with built-in context", "Interpolate variables and render templates",
"Substitute placeholders"):
binding = step(document, "activation", "name", title)
effective = {**activation_env, **binding.get("env", {})}
self.assertEqual(PR_EXPRESSION, effective["REVIEW_PR_NUMBER"])
# Actions evaluates a step's whole env map against the workflow/job env before
# merging it, so this binding reads the workflow value even when gh-aw blanks the
# raw REVIEW_PR_NUMBER name in the same map to isolate prompt rendering.
self.assertEqual(PR_EXPRESSION, activation_env["REVIEW_PR_NUMBER"])
self.assertEqual("${{ env.REVIEW_PR_NUMBER }}", binding["env"]["GH_AW_ENV_REVIEW_PR_NUMBER"])
script = binding["with"]["script"]
if "promptEnvironment" in script:
allowlist = re.search(r"const promptEnvironment = new Set\((\[.*?\])\);", script)
self.assertIsNotNone(allowlist, "unrecognized gh-aw prompt environment allowlist")
self.assertIn("GH_AW_ENV_REVIEW_PR_NUMBER", json.loads(allowlist.group(1)))
if title == "Substitute placeholders":
self.assertIn("GH_AW_ENV_REVIEW_PR_NUMBER: process.env.GH_AW_ENV_REVIEW_PR_NUMBER",
binding["with"]["script"])
creator = step(document, "activation", "name", "Create prompt with built-in context")
interpolator = step(document, "activation", "name", "Interpolate variables and render templates")
self.assertIn("'interpolate_prompt.cjs'", interpolator["with"]["script"])
self.assertRegex(interpolator["with"]["script"], r"require\([^)]*['/]interpolate_prompt\.cjs'\)")
self.assertEqual(creator["env"]["GH_AW_PROMPT"], interpolator["env"]["GH_AW_PROMPT"])

def test_required_diff_failure_has_terminal_incomplete_prompt_delivery(self) -> None:
Expand Down
Loading
Loading