Skip to content

Commit ddfbc43

Browse files
Copilotlpcox
andauthored
feat: add volume mount for ~/.copilot/session-state to persist events.jsonl (#1469)
* Initial plan * feat: add volume mount for ~/.copilot/session-state Agent-Logs-Url: https://github.com/github/gh-aw-firewall/sessions/44f79fbe-75fd-4c92-ae2a-fe47fee65922 * [WIP] Fix failing GitHub Actions workflow Audit Main Package (#1498) * Initial plan * fix: update handlebars and brace-expansion to fix npm audit vulnerabilities Agent-Logs-Url: https://github.com/github/gh-aw-firewall/sessions/41a2d615-b628-46d7-bf1f-2e21f94f7f5b Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>
1 parent 8fcfbb8 commit ddfbc43

2 files changed

Lines changed: 36 additions & 3 deletions

File tree

docs/usage.md

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -845,6 +845,12 @@ sudo awf \
845845
- Location: `/tmp/awf-agent-logs-<timestamp>/`
846846
- View with: `cat /tmp/awf-agent-logs-<timestamp>/*.log`
847847

848+
**Agent Session State:**
849+
- Contains structured conversation data written by Copilot CLI (e.g., `events.jsonl`)
850+
- Location: `/tmp/awf-agent-session-state-<timestamp>/`
851+
- View with: `cat /tmp/awf-agent-session-state-<timestamp>/events.jsonl`
852+
- Useful for triage dashboards, benchmarking, and debugging Copilot CLI runs
853+
848854
**Squid Logs:**
849855
- Contains all HTTP/HTTPS traffic (allowed and denied)
850856
- Location: `/tmp/squid-logs-<timestamp>/`
@@ -859,9 +865,15 @@ sudo cat /tmp/squid-logs-<timestamp>/access.log
859865
```
860866

861867
**How it works:**
862-
- GitHub Copilot CLI writes to `~/.copilot/logs/`, Squid writes to `/var/log/squid/`
863-
- Volume mounts map these to `${workDir}/agent-logs/` and `${workDir}/squid-logs/`
864-
- Before cleanup, logs are automatically moved to `/tmp/awf-agent-logs-<timestamp>/` and `/tmp/squid-logs-<timestamp>/` (if they exist)
868+
- GitHub Copilot CLI writes to `~/.copilot/logs/` and `~/.copilot/session-state/`; Squid writes to `/var/log/squid/`
869+
- Volume mounts map container paths to:
870+
- `${workDir}/agent-logs/``~/.copilot/logs/`
871+
- `${workDir}/agent-session-state/``~/.copilot/session-state/`
872+
- `${workDir}/squid-logs/``/var/log/squid/`
873+
- Before cleanup, non-empty directories are automatically moved to timestamped `/tmp` paths:
874+
- `/tmp/awf-agent-logs-<timestamp>/`
875+
- `/tmp/awf-agent-session-state-<timestamp>/`
876+
- `/tmp/squid-logs-<timestamp>/`
865877
- Empty log directories are not preserved (avoids cluttering /tmp)
866878

867879
### Keep Containers for Inspection

src/docker-manager.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -754,6 +754,8 @@ export function generateDockerCompose(
754754
`${workspaceDir}:${workspaceDir}:rw`,
755755
// Mount agent logs directory to workDir for persistence
756756
`${config.workDir}/agent-logs:${effectiveHome}/.copilot/logs:rw`,
757+
// Mount agent session-state directory to workDir for persistence (events.jsonl)
758+
`${config.workDir}/agent-session-state:${effectiveHome}/.copilot/session-state:rw`,
757759
// Init signal volume for iptables init container coordination
758760
`${initSignalDir}:/tmp/awf-init:rw`,
759761
];
@@ -1566,6 +1568,13 @@ export async function writeConfigs(config: WrapperConfig): Promise<void> {
15661568
}
15671569
logger.debug(`Agent logs directory created at: ${agentLogsDir}`);
15681570

1571+
// Create agent session-state directory for persistence (events.jsonl written by Copilot CLI)
1572+
const agentSessionStateDir = path.join(config.workDir, 'agent-session-state');
1573+
if (!fs.existsSync(agentSessionStateDir)) {
1574+
fs.mkdirSync(agentSessionStateDir, { recursive: true });
1575+
}
1576+
logger.debug(`Agent session-state directory created at: ${agentSessionStateDir}`);
1577+
15691578
// Create squid logs directory for persistence
15701579
// If proxyLogsDir is specified, write directly there (timeout-safe)
15711580
// Otherwise, use workDir/squid-logs (will be moved to /tmp after cleanup)
@@ -2122,6 +2131,18 @@ export async function cleanup(workDir: string, keepFiles: boolean, proxyLogsDir?
21222131
}
21232132
}
21242133

2134+
// Preserve agent session-state before cleanup (contains events.jsonl from Copilot CLI)
2135+
const agentSessionStateDir = path.join(workDir, 'agent-session-state');
2136+
const agentSessionStateDestination = path.join(os.tmpdir(), `awf-agent-session-state-${timestamp}`);
2137+
if (fs.existsSync(agentSessionStateDir) && fs.readdirSync(agentSessionStateDir).length > 0) {
2138+
try {
2139+
fs.renameSync(agentSessionStateDir, agentSessionStateDestination);
2140+
logger.info(`Agent session state preserved at: ${agentSessionStateDestination}`);
2141+
} catch (error) {
2142+
logger.debug('Could not preserve agent session state:', error);
2143+
}
2144+
}
2145+
21252146
// Preserve api-proxy logs before cleanup
21262147
if (proxyLogsDir) {
21272148
// Logs were written directly to sibling of proxyLogsDir during runtime (timeout-safe)

0 commit comments

Comments
 (0)