Skip to content
GitHub Agentic Workflows

Sandbox Configuration

The sandbox field configures sandbox environments for AI engines, providing two main capabilities:

  1. Agent Sandbox - Controls the agent runtime security (AWF or Sandbox Runtime)
  2. Model Context Protocol (MCP) Gateway - Routes MCP server calls through a unified HTTP gateway

Configure the agent sandbox type to control how the AI engine is isolated:

# Use AWF (Agent Workflow Firewall) - default
sandbox:
agent: awf
# Use Sandbox Runtime (SRT) - experimental
sandbox:
agent: srt
# Or omit sandbox entirely to use the default (awf)

Route MCP server calls through a unified HTTP gateway:

features:
mcp-gateway: true
sandbox:
mcp:
port: 8080
api-key: "${{ secrets.MCP_GATEWAY_API_KEY }}"

Use both agent sandbox and MCP gateway together:

features:
mcp-gateway: true
sandbox:
agent: awf
mcp:
port: 8080

AWF is the default agent sandbox that provides network egress control through domain-based access controls. Network permissions are configured through the top-level network field.

sandbox:
agent: awf
network:
firewall: true
allowed:
- defaults
- python
- "api.example.com"

AWF automatically mounts several paths from the host into the container to enable agent functionality:

Host PathContainer PathModePurpose
/tmp/tmprwTemporary files and cache
${HOME}/.cache${HOME}/.cacherwBuild caches (Go, npm, etc.)
${GITHUB_WORKSPACE}${GITHUB_WORKSPACE}rwRepository workspace directory
/opt/hostedtoolcache/opt/hostedtoolcacheroRuntimes (Node.js, Python, Go, Ruby, Java)
/opt/gh-aw/opt/gh-awroScript and configuration files
/usr/local/bin/copilot/usr/local/bin/copilotroCopilot CLI binary
/home/runner/.copilot/home/runner/.copilotrwCopilot configuration and state

These default mounts ensure the agent has access to essential tools and the repository files. Custom mounts specified via sandbox.agent.mounts are added alongside these defaults.

AWF mounts common system utilities from the host into the container as read-only binaries. These utilities are frequently used in workflow scripts and are organized by priority:

Essential Utilities (most commonly used):

UtilityPurpose
catDisplay file contents
curlHTTP client for API calls
dateDate/time operations
findLocate files by pattern
ghGitHub CLI operations
grepPattern matching
jqJSON processing
yqYAML processing

Common Utilities (frequently used for file operations):

UtilityPurpose
cpCopy files
cutExtract text columns
diffCompare files
headDisplay file start
lsList directory contents
mkdirCreate directories
rmRemove files
sedStream text editing
sortSort text lines
tailDisplay file end
wcCount lines/words
whichLocate commands

All utilities are mounted read-only (:ro) from /usr/bin/ on the host. They execute on the read-write workspace directory inside the container.

AWF automatically mirrors essential environment variables from the GitHub Actions runner into the agent container. This ensures compatibility with workflows that depend on runner-provided tool paths.

The following environment variables are mirrored (if they exist on the host):

CategoryEnvironment Variables
JavaJAVA_HOME, JAVA_HOME_8_X64, JAVA_HOME_11_X64, JAVA_HOME_17_X64, JAVA_HOME_21_X64, JAVA_HOME_25_X64
AndroidANDROID_HOME, ANDROID_SDK_ROOT, ANDROID_NDK, ANDROID_NDK_HOME, ANDROID_NDK_ROOT, ANDROID_NDK_LATEST_HOME
BrowsersCHROMEWEBDRIVER, EDGEWEBDRIVER, GECKOWEBDRIVER, SELENIUM_JAR_PATH
Package ManagersCONDA, VCPKG_INSTALLATION_ROOT, PIPX_HOME, PIPX_BIN_DIR, GEM_HOME, GEM_PATH
GoGOPATH, GOROOT
.NETDOTNET_ROOT
RustCARGO_HOME, RUSTUP_HOME
Node.jsNVM_DIR
HomebrewHOMEBREW_PREFIX, HOMEBREW_CELLAR, HOMEBREW_REPOSITORY
SwiftSWIFT_PATH
AzureAZURE_EXTENSION_DIR

AWF mounts the /opt/hostedtoolcache directory from the GitHub Actions runner, providing access to all runtimes installed via actions/setup-* steps. This directory contains pre-installed and dynamically-installed versions of popular development tools.

Available Runtimes:

RuntimeSetup ActionExample Versions
Node.jsactions/setup-node18.x, 20.x, 22.x
Pythonactions/setup-python3.9, 3.10, 3.11, 3.12, 3.13, 3.14
Goactions/setup-go1.22.x, 1.23.x, 1.24.x, 1.25.x
Rubyruby/setup-ruby3.2, 3.3, 3.4
Javaactions/setup-java8, 11, 17, 21, 25

PATH Integration:

All runtime binaries are automatically added to PATH inside the agent container. The PATH is configured using a dynamic find command that discovers all bin directories within /opt/hostedtoolcache:

Terminal window
# PATH includes all hostedtoolcache binaries
export PATH="$(find /opt/hostedtoolcache -maxdepth 4 -type d -name bin 2>/dev/null | tr '\n' ':')$PATH"

Version Priority:

When multiple versions of a runtime are installed, versions configured by actions/setup-* take precedence. The agent detects which specific version is active by reading environment variables like GOROOT, JAVA_HOME, and ensures that version’s binaries appear first in PATH.

Using Runtimes in Workflows:

---
jobs:
setup:
steps:
- uses: actions/setup-go@v5
with:
go-version: '1.25'
- uses: actions/setup-python@v5
with:
python-version: '3.12'
---
Use `go build` or `python3` in your workflow - both are available!

Use custom commands, arguments, and environment variables to replace the standard AWF installation with a custom setup:

sandbox:
agent:
id: awf
command: "/usr/local/bin/custom-awf-wrapper"
args:
- "--custom-logging"
- "--debug-mode"
env:
AWF_CUSTOM_VAR: "custom_value"
DEBUG_LEVEL: "verbose"

Add custom container mounts to make host paths available inside the AWF container:

sandbox:
agent:
id: awf
mounts:
- "/host/data:/data:ro"
- "/usr/local/bin/custom-tool:/usr/local/bin/custom-tool:ro"
- "/tmp/cache:/cache:rw"

Mount syntax follows Docker’s format: source:destination:mode

  • source: Path on the host system
  • destination: Path inside the container
  • mode: Either ro (read-only) or rw (read-write)

Custom mounts are useful for:

  • Providing access to datasets or configuration files
  • Making custom tools available in the container
  • Sharing cache directories between host and container
FieldTypeDescription
idstringAgent identifier: awf or srt
commandstringCustom command to replace AWF binary installation
argsstring[]Additional arguments appended to the command
envobjectEnvironment variables set on the execution step
mountsstring[]Container mounts using syntax source:destination:mode

When command is specified, the standard AWF installation is skipped and your custom command is used instead.

Sandbox Runtime provides enhanced isolation using Anthropic’s sandbox technology. It supports custom filesystem configuration while network permissions are controlled by the top-level network field.

features:
sandbox-runtime: true
sandbox:
agent:
type: srt
config:
filesystem:
allowWrite: [".", "/tmp", "/home/runner/.copilot"]
denyRead: ["/etc/passwd"]
enableWeakerNestedSandbox: true
network:
allowed:
- defaults
- python
FieldTypeDescription
filesystem.allowWritestring[]Paths allowed for write access
filesystem.denyReadstring[]Paths denied for read access
filesystem.denyWritestring[]Paths denied for write access
ignoreViolationsobjectMap of command patterns to paths that should ignore violations
enableWeakerNestedSandboxbooleanEnable weaker nested sandbox mode (use only when required)

Similar to AWF, SRT supports custom commands, arguments, and environment variables:

features:
sandbox-runtime: true
sandbox:
agent:
id: srt
command: "custom-srt-wrapper"
args:
- "--custom-arg"
- "--debug"
env:
SRT_DEBUG: "true"
SRT_CUSTOM_VAR: "test_value"
config:
filesystem:
allowWrite: [".", "/tmp"]

When command is specified, the standard SRT installation is skipped. The config field can still be used for filesystem configuration.

The MCP Gateway routes all MCP server calls through a unified HTTP gateway, enabling centralized management, logging, and authentication for MCP tools.

FieldTypeRequiredDescription
commandstringNoCustom command to execute (mutually exclusive with container)
containerstringNoContainer image for the MCP gateway (mutually exclusive with command)
versionstringNoVersion tag for the container image
portintegerNoHTTP server port (default: 8080)
api-keystringNoAPI key for gateway authentication
argsstring[]NoCommand/container execution arguments
entrypointArgsstring[]NoContainer entrypoint arguments (only valid with container)
envobjectNoEnvironment variables for the gateway

When MCP gateway is configured:

  1. The gateway starts using the specified execution mode (command or container)
  2. A health check verifies the gateway is ready
  3. All MCP server configurations are transformed to route through the gateway
  4. The gateway receives server configs via a configuration file
features:
mcp-gateway: true
sandbox:
mcp:
command: "/usr/local/bin/mcp-gateway"
args: ["--port", "9000", "--verbose"]
env:
LOG_LEVEL: "debug"
features:
mcp-gateway: true
sandbox:
mcp:
container: "ghcr.io/githubnext/gh-aw-mcpg:latest"
args: ["--rm", "-i"]
entrypointArgs: ["--routed", "--listen", "0.0.0.0:8000", "--config-stdin"]
port: 8000
env:
LOG_LEVEL: "info"

For backward compatibility, legacy formats are still supported:

# Legacy string format (deprecated)
sandbox: sandbox-runtime
# Legacy object format with 'type' field (deprecated)
sandbox:
agent:
type: awf
# Recommended format with 'id' field
sandbox:
agent:
id: awf

The id field replaces the legacy type field in the object format. When both are present, id takes precedence.

Some sandbox features require feature flags:

FeatureFlagDescription
Sandbox Runtimesandbox-runtimeEnable SRT agent sandbox
MCP Gatewaymcp-gatewayEnable MCP gateway routing

Enable feature flags in your workflow:

features:
sandbox-runtime: true
mcp-gateway: true