gh-aw icon indicating copy to clipboard operation
gh-aw copied to clipboard

Self-hosted: agent sandbox and session copy assume the runner home is empty and writable by root

Open priyanka9990 opened this issue 2 weeks ago • 1 comments

Summary

On a self-hosted runner, the agent container inherits the runner user's $HOME, and two gh-aw behaviors depend on that directory:

  1. The firewall mounts /dev/null over credential files under $HOME. If $HOME is on NFS, Docker runs as root and cannot create those paths, so the container never starts.
  2. After the agent step, copy_copilot_session_state.sh copies every Copilot session under $HOME/.copilot/session-state when the job's own session directory is empty. On a runner user that already has local Copilot history, that copy fills the disk and the log parser crashes.

A private empty home on local disk avoids both. There is no frontmatter setting for the home directory, so the workaround lives outside the workflow.

Environment

  • gh-aw v1.2.2, stock compile
  • Self-hosted Linux runner, not ARC/DinD
  • runner.installation: rootless
  • Runner user's $HOME is an NFS mount
  • That user has an existing ~/.copilot/session-state from normal Copilot CLI use
  • Docker is available

1. Container cannot start when $HOME is on NFS

The agent step does not set HOME. AWF starts the container with the runner user's home, then mounts /dev/null over credential paths under that home.

Observed:

error mounting "/dev/null" to rootfs at "/host$HOME/.config/glab-cli/config.yml":
lstat .../merged/host$HOME/.config/glab-cli: permission denied

docker compose up exits 1, and the agent produces no output. Root can create the same paths on a local filesystem. This is the NFS root-squash restriction, and there is no frontmatter field for a different home.

2. Session copy reads every session in $HOME

actions/setup/sh/copy_copilot_session_state.sh (v1.2.2) picks a source in this order:

  1. /tmp/gh-aw/sandbox/agent/session-state, the current job's session.
  2. Otherwise $HOME/.copilot/session-state, the runner user's whole history.

When the first directory has no redactable files, the script copies every matching file from the second. The job log shows:

Copying Copilot session state from $HOME/.copilot/session-state to /tmp/gh-aw/sandbox/agent/logs/copilot-session-state
cp: error writing '...': No space left on device
Failed to write agent output file: ENOSPC: no space left on device, open '/tmp/gh-aw/agent_output.json'
ERR_API: Maximum call stack size exceeded

The parser then emits one Agent source: .../events.jsonl line per past session, not only the session from this run. The current job's session is the directory under /tmp/gh-aw/sandbox/agent/session-state. The fallback should not copy unrelated sessions.

Expected

  • A way to give the agent job a home directory that is not the runner user's real home, or a mount policy that does not require root to create paths under $HOME when it is on NFS.
  • Copy and parse only the session created by the current run. If the job's own session directory is empty, skip the copy instead of reading $HOME/.copilot/session-state.

Workaround we used

Outside the workflow, point the runner at an empty home on local disk and clear its session directory before each job:

HOME=/var/tmp/runner-home-<runner-name>
ACTIONS_RUNNER_HOOK_JOB_STARTED=<path-to-a-script-that-empties-$HOME/.copilot/session-state>

The real $HOME/.copilot is then never read. This is a runner configuration change, not a workflow setting, and sessions still accumulate in the new home unless the hook keeps clearing them.

Notes

  • Separate from #75441. That issue is the shared /tmp/gh-aw directory. This one is $HOME.
  • An empty home hides problem 2, which is why it does not show up on a fresh runner user.

priyanka9990 avatar Nov 11 '26 16:11 priyanka9990

🔗 AWF tracking issue: github/gh-aw-firewall#11726

Generated by Firewall Issue Dispatcher · copilot · routed: haiku55 xhigh · ~2 AIC · ⊞ 3K · ◷

lpcox avatar Nov 17 '26 12:11 lpcox