Skip to content
GitHub Agentic Workflows

Environment Variables

Environment variables in GitHub Agentic Workflows can be defined at multiple scopes, each serving a specific purpose in the workflow lifecycle. Variables defined at more specific scopes override those at more general scopes, following GitHub Actions conventions while adding AWF-specific contexts.

GitHub Agentic Workflows supports environment variables in 13 distinct contexts:

ScopeSyntaxContextTypical Use
Workflow-levelenv:All jobsShared configuration
Job-leveljobs.<job_id>.envAll steps in jobJob-specific config
Step-levelsteps[*].envSingle stepStep-specific config
Engineengine.envAI engineEngine secrets, timeouts
Containercontainer.envContainer runtimeContainer settings
Servicesservices.<id>.envService containersDatabase credentials
Sandbox Agentsandbox.agent.envSandbox runtimeSandbox configuration
Sandbox MCPsandbox.mcp.envModel Context Protocol (MCP) gatewayMCP debugging
MCP Toolstools.<name>.envMCP server processMCP server secrets
MCP Scriptsmcp-scripts.<name>.envMCP script executionTool-specific tokens
Safe Outputs Globalsafe-outputs.envAll safe-output jobsShared safe-output config
Safe Outputs Jobsafe-outputs.jobs.<name>.envSpecific safe-output jobJob-specific config
GitHub Actions StepgithubActionsStep.envPre-defined stepsStep configuration

Workflow-level shared configuration:

---
env:
NODE_ENV: production
API_ENDPOINT: https://api.example.com
---

Job-specific overrides:

---
jobs:
validation:
env:
VALIDATION_MODE: strict
steps:
- run: npm run build
env:
BUILD_ENV: production # Overrides job and workflow levels
---

AWF-specific contexts:

---
# Engine configuration
engine:
id: copilot
env:
OPENAI_API_KEY: ${{ secrets.CUSTOM_KEY }}
# MCP server with secrets
tools:
database:
command: npx
args: ["-y", "mcp-server-postgres"]
env:
DATABASE_URL: ${{ secrets.DATABASE_URL }}
# Safe outputs with custom PAT
safe-outputs:
create-issue:
env:
GITHUB_TOKEN: ${{ secrets.CUSTOM_PAT }}
---

Agents can write markdown content to the $GITHUB_STEP_SUMMARY environment variable to publish a formatted summary visible in the GitHub Actions run view.

Inside the AWF sandbox, $GITHUB_STEP_SUMMARY is redirected to a file at /tmp/gh-aw/agent-step-summary.md. After agent execution completes, the framework automatically appends the contents of that file to the real GitHub step summary. Secret redaction runs before the content is published.

Example: an agent writing a brief analysis result to the step summary:

Terminal window
echo "## Analysis complete" >> "$GITHUB_STEP_SUMMARY"
echo "Found 3 issues across 12 files." >> "$GITHUB_STEP_SUMMARY"

The output appears in the Summary tab of the GitHub Actions workflow run.

GitHub Agentic Workflows automatically injects the following environment variables into every agentic engine execution step (both the main agent run and the threat detection run). These variables are read-only from the agent’s perspective and are useful for writing workflows or agents that need to detect their execution context.

VariableValueDescription
GITHUB_AW"true"Present in every gh-aw engine execution step. Agents can check for this variable to confirm they are running inside a GitHub Agentic Workflow.
GH_AW_PHASE"agent" or "detection"Identifies which execution phase is active. "agent" for the main run; "detection" for the threat-detection safety check run that precedes the main run.
GH_AW_VERSIONe.g. "0.40.1"The gh-aw compiler version that generated the workflow. Useful for conditional logic that depends on a minimum feature version.

These variables appear alongside other GH_AW_* context variables in the compiled workflow:

env:
GITHUB_AW: "true"
GH_AW_PHASE: agent # or "detection"
GH_AW_VERSION: "0.40.1"
GH_AW_PROMPT: /tmp/gh-aw/aw-prompts/prompt.txt

Environment variables follow a most-specific-wins model, consistent with GitHub Actions. Variables at more specific scopes completely override variables with the same name at less specific scopes.

  1. Step-level (steps[*].env, githubActionsStep.env)
  2. Job-level (jobs.<job_id>.env)
  3. Workflow-level (env:)
  1. Job-specific (safe-outputs.jobs.<job_name>.env)
  2. Global (safe-outputs.env)
  3. Workflow-level (env:)

These scopes are independent and operate in different contexts: engine.env, container.env, services.<id>.env, sandbox.agent.env, sandbox.mcp.env, tools.<tool>.env, mcp-scripts.<tool>.env.

---
env:
API_KEY: default-key
DEBUG: "false"
jobs:
test:
env:
API_KEY: test-key # Overrides workflow-level
EXTRA: "value"
steps:
- run: |
# API_KEY = "test-key" (job-level override)
# DEBUG = "false" (workflow-level inherited)
# EXTRA = "value" (job-level)
---