fix: capture Copilot CLI session state (events.jsonl) in AWF sandbox artifacts#1945
fix: capture Copilot CLI session state (events.jsonl) in AWF sandbox artifacts#1945
Conversation
Add --session-state-dir to AWF invocations and replace the copy_copilot_session_state.sh step with an inline script that reads from the AWF-managed host path instead of $HOME/.copilot/ session-state (which is empty when CLI ran inside the container). Agent-Logs-Url: https://github.com/github/gh-aw-firewall/sessions/6833d315-fdff-4cf9-b5a6-7e322a307397
There was a problem hiding this comment.
Pull request overview
This PR ensures Copilot CLI session state (events.jsonl) generated inside the AWF Docker sandbox is written to a host-accessible directory and included in existing workflow artifacts.
Changes:
- Post-process all
*.lock.ymlworkflows to inject--session-state-dir /tmp/gh-aw/sandbox/agent/session-stateinto AWF invocations (idempotently). - Replace the compiler-generated “Copy Copilot session state” step with an inline copy script that reads from the AWF-managed session-state directory and copies into the existing agent logs artifact path.
- Add unit tests covering the new regex transforms and the replacement-step builder, including idempotency checks.
Show a summary per file
| File | Description |
|---|---|
| scripts/ci/postprocess-smoke-workflows.ts | Adds two post-processing transforms: inject --session-state-dir and replace the session-state copy step with an AWF-aware inline script. |
| scripts/ci/postprocess-smoke-workflows.test.ts | Adds unit tests for the new regexes and the step builder, including idempotency coverage. |
| .github/workflows/build-test.lock.yml | Applies injected --session-state-dir and replaces session-state copy step to capture session state in artifacts. |
| .github/workflows/ci-cd-gaps-assessment.lock.yml | Applies injected --session-state-dir and replaces session-state copy step to capture session state in artifacts. |
| .github/workflows/ci-doctor.lock.yml | Applies injected --session-state-dir and replaces session-state copy step to capture session state in artifacts. |
| .github/workflows/claude-token-optimizer.lock.yml | Applies injected --session-state-dir and replaces session-state copy step (no-op if no session state) for consistent artifact behavior. |
| .github/workflows/claude-token-usage-analyzer.lock.yml | Applies injected --session-state-dir and replaces session-state copy step (no-op if no session state) for consistent artifact behavior. |
| .github/workflows/cli-flag-consistency-checker.lock.yml | Applies injected --session-state-dir and replaces session-state copy step to capture session state in artifacts. |
| .github/workflows/copilot-token-optimizer.lock.yml | Applies injected --session-state-dir and replaces session-state copy step to capture session state in artifacts. |
| .github/workflows/copilot-token-usage-analyzer.lock.yml | Applies injected --session-state-dir and replaces session-state copy step to capture session state in artifacts. |
| .github/workflows/dependency-security-monitor.lock.yml | Applies injected --session-state-dir and replaces session-state copy step to capture session state in artifacts. |
| .github/workflows/doc-maintainer.lock.yml | Applies injected --session-state-dir and replaces session-state copy step to capture session state in artifacts. |
| .github/workflows/firewall-issue-dispatcher.lock.yml | Applies injected --session-state-dir and replaces session-state copy step to capture session state in artifacts. |
| .github/workflows/issue-duplication-detector.lock.yml | Applies injected --session-state-dir and replaces session-state copy step to capture session state in artifacts. |
| .github/workflows/issue-monster.lock.yml | Applies injected --session-state-dir and replaces session-state copy step to capture session state in artifacts. |
| .github/workflows/pelis-agent-factory-advisor.lock.yml | Applies injected --session-state-dir and replaces session-state copy step to capture session state in artifacts. |
| .github/workflows/plan.lock.yml | Applies injected --session-state-dir and replaces session-state copy step to capture session state in artifacts. |
| .github/workflows/secret-digger-claude.lock.yml | Applies injected --session-state-dir and replaces session-state copy step (no-op if no session state) for consistent artifact behavior. |
| .github/workflows/secret-digger-codex.lock.yml | Applies injected --session-state-dir and replaces session-state copy step (no-op if no session state) for consistent artifact behavior. |
| .github/workflows/secret-digger-copilot.lock.yml | Applies injected --session-state-dir and replaces session-state copy step to capture session state in artifacts (including multi-invocation workflows). |
| .github/workflows/security-guard.lock.yml | Applies injected --session-state-dir and replaces session-state copy step (no-op if no session state) for consistent artifact behavior. |
| .github/workflows/security-review.lock.yml | Applies injected --session-state-dir and replaces session-state copy step to capture session state in artifacts. |
| .github/workflows/smoke-chroot.lock.yml | Applies injected --session-state-dir and replaces session-state copy step to capture session state in artifacts. |
| .github/workflows/smoke-claude.lock.yml | Applies injected --session-state-dir and replaces session-state copy step (no-op if no session state) for consistent artifact behavior. |
| .github/workflows/smoke-codex.lock.yml | Applies injected --session-state-dir and replaces session-state copy step (no-op if no session state) for consistent artifact behavior. |
| .github/workflows/smoke-copilot.lock.yml | Applies injected --session-state-dir and replaces session-state copy step to capture session state in artifacts. |
| .github/workflows/smoke-services.lock.yml | Applies injected --session-state-dir and replaces session-state copy step to capture session state in artifacts. |
| .github/workflows/test-coverage-improver.lock.yml | Applies injected --session-state-dir and replaces session-state copy step to capture session state in artifacts. |
| .github/workflows/update-release-notes.lock.yml | Applies injected --session-state-dir and replaces session-state copy step to capture session state in artifacts. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 29/29 changed files
- Comments generated: 0
✅ Coverage Check PassedOverall Coverage
📁 Per-file Coverage Changes (1 files)
Coverage comparison generated by |
Smoke Test Results✅ GitHub MCP: fix: always route Gemini through api-proxy sidecar when --enable-api-proxy is active (#1946), feat: collect diagnostic logs on container startup failure (#1941) Overall: PASS
|
🔥 AWF Smoke Test Results
Overall: PASS PR: fix: capture Copilot CLI session state (events.jsonl) in AWF sandbox artifacts
|
Smoke Test: GitHub Actions Services Connectivity ✅All connectivity checks passed:
|
|
Smoke Test (Codex)
|
|
@copilot resolve the merge conflicts in this pull request |
🏗️ Build Test Suite Results
Overall: 8/8 ecosystems passed — ✅ PASS
|
Resolved. The only conflict was in |
When Copilot CLI runs inside the AWF Docker container,
events.jsonlis written to$HOME/.copilot/session-stateinside the container. The compiled workflow's "Copy Copilot session state" step calledcopy_copilot_session_state.sh, which reads from the host runner's$HOME/.copilot/session-state— always empty in this case — soevents.jsonlnever made it into the artifact.Changes
scripts/ci/postprocess-smoke-workflows.tsTwo new idempotent transformations applied to all lock files:
--session-state-dirinjection — anchors to--audit-dir /tmp/gh-aw/sandbox/firewall/audit(present in every compiled lock file) and appends--session-state-dir /tmp/gh-aw/sandbox/agent/session-state. AWF bind-mounts this host path into the container at$HOME/.copilot/session-state, so the CLI writes session state directly to a host-accessible path.Copy step replacement — replaces the
copy_copilot_session_state.shcall with an inline script that copies from the AWF-managed path into the agent logs directory (/tmp/gh-aw/sandbox/agent/logs/session-state/), which is already included in the artifact upload.scripts/ci/postprocess-smoke-workflows.test.tsUnit tests for both new regex patterns (
sessionStateDirInjectionRegex,copySessionStateStepRegex) and thebuildCopySessionStateStepbuilder, including idempotency coverage.Lock files (27 files)
All
*.lock.ymlfiles updated by running the post-process script.