Repository navigation
fix(cli): propagate caller context to agent log session parser subprocess - #77628
Conversation
|
✅ Ponytail Reviewer completed successfully! Ponytail ReviewerOutcome: The agent completed and reported no action. A no-op output alone does not verify that all required work was completed or that publication was possible. Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.
|
|
✅ Test Quality Sentinel completed test quality analysis. Test Quality SentinelOutcome: The agent completed and reported no action. A no-op output alone does not verify that all required work was completed or that publication was possible. Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.
|
|
🧠 Matt Pocock Skills Reviewer has completed the skills-based review. ✅
|
|
✅ PR Code Quality Reviewer completed the code quality review. PR Code Quality ReviewerOutcome: The agent completed and reported one or more actions. The no-op output is a completion signal, not a claim that no action was taken. Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.
|
|
✅ Design Decision Gate 🏗️ completed the design decision gate check. See the comment below for the result and any generated ADR draft. Design Decision Gate 🏗️Outcome: The agent completed and reported no action. A no-op output alone does not verify that all required work was completed or that publication was possible. Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.
|
|
✅ PR Specification Reviewer completed successfully! PR Specification ReviewerOutcome: The agent completed and reported one or more actions. The no-op output is a completion signal, not a claim that no action was taken. Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.
|
There was a problem hiding this comment.
🟡 Changes recommended
The tests do not exercise cancellation during parsing, leaving the fix unprotected against regressions that ignore the supplied context or create log.md despite cancellation.
1 open issue
What changed in this PR
This PR threads caller contexts through the CLI’s agent-log parsing chain so Node session-parser subprocesses can be cancelled with gh aw logs and gh aw audit.
Changes:
- Pass caller contexts through persisted, unified, and engine-specific log parsers.
- Connect download, stdin, and audit callers to the updated helpers.
- Update existing tests to pass
t.Context().
| File | Description |
|---|---|
pkg/cli/session_parser_test.go |
Update parser tests for context parameters. |
pkg/cli/logs_parsing_persisted.go |
Forward context to reconstruction and rendering subprocesses. |
pkg/cli/logs_parsing_persisted_test.go |
Update persisted-log tests for context parameters. |
pkg/cli/logs_parsing_javascript.go |
Forward context through all agent-parser paths. |
pkg/cli/logs_parse_test.go |
Update missing-input tests for context parameters. |
pkg/cli/logs_orchestrator_stdin.go |
Pass the stdin orchestrator’s context to parsing. |
pkg/cli/logs_orchestrator_download.go |
Pass the collector’s context through artifact parsing. |
pkg/cli/logs_engine_definition_test.go |
Update engine-parser tests for context parameters. |
pkg/cli/audit_render_output.go |
Thread the audit context through log-parsing helpers. |
pkg/cli/audit_render_output_test.go |
Update audit helper tests for context parameters. |
Review effort: Balanced (dynamic)
| args = append(args, engineID) | ||
| } | ||
| session, err := runSessionParser(context.Background(), args...) | ||
| session, err := runSessionParser(ctx, args...) |
|
One or more custom setup steps configured for this repository failed during this Copilot code review run: Setup steps run before each review. If the review above is missing context, or no review was posted at all, the failing step above may be the cause. See the workflow run for failure details, fix your setup steps configuration, and re-request a review. Note You can configure setup steps for Copilot code review separately from Copilot cloud agent with a |
Comment MemoryPeek at saved memory (spec-review-history)History |
There was a problem hiding this comment.
Reviewed the context propagation changes across the agent-log parsing chain. The updated call sites consistently pass their existing caller contexts into the Node session parser, and the changes preserve existing behavior while enabling cancellation. No blocking correctness or maintainability issues found in the diff.
🔎 Code quality review by PR Code Quality Reviewer · copilot · gpt50 · ~2 AIC · ⌖ ~1 AIC · ⊞ 1.5K
Comment /review to run again
There was a problem hiding this comment.
Skills-Based Review 🧠
Applied /diagnosing-bugs and /tdd. The signature change is mechanically sound: no context.Background() remains in the parse chain, and every caller now passes a context. Two inline suggestions below; neither blocks merge.
📋 Key Themes & Highlights
Key Themes
- Incomplete propagation:
parseFirewallLogsin the same audit path still runs an unscopednodechild (inline onaudit_render_output.go:189). - No cancellation regression test: every updated test passes
t.Context(), which is never cancelled (inline onsession_parser_test.go:382). - Compile not verified:
go vet ./pkg/cli/fails atpkg/workflow/imports.go:585(undefined: topRawSafeOutputs). The base commitb4b6c18has the same break, so it predates this PR and is out of scope here, butpkg/clicannot be type-checked from this checkout to confirm the new signatures. - Misleading error on cancel (nit):
session_parser.go:138reports every non-zero exit asNode.js is required. A mid-run cancel kills the child and may surface that message. I only confirmed the pre-cancelled path, which returnscontext.Canceledcorrectly.
Positive Highlights
- ✅ Consistent change across all six functions and their tests
- ✅ Changed files are gofmt-clean
- ✅ The collector passes its batch-scoped
c.ctx, so cancellation reaches the right parser
@copilot please address the review comments above.
🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · copilot · routed: haiku55 xhigh · ~4 AIC · ⌖ ~2 AIC · ⊞ 6.6K
Comment /matt to run again
| root := t.TempDir() | ||
| writeSessionTestFile(t, root, "agent-stdio.log", `{"type":"assistant","message":{"content":[{"type":"text","text":"Audit parser works"}]}}`+"\n") | ||
| require.NoError(t, parseAgentLog(root, workflow.NewClaudeEngine(), false)) | ||
| require.NoError(t, parseAgentLog(t.Context(), root, workflow.NewClaudeEngine(), false)) |
There was a problem hiding this comment.
[/tdd] This test now passes t.Context(), which is never cancelled. It shows nothing regressed, but not that the fix works. Add a test that cancels the context before the call and asserts the cancellation is returned. It catches any of the five sites reverting to context.Background().
💡 Suggested test
Write an agent-stdio.log first, or the parser is never reached and the assertion cannot exercise cancellation:
ctx, cancel := context.WithCancel(t.Context())
cancel()
err := parseAgentLog(ctx, root, workflow.NewClaudeEngine(), false)
require.ErrorIs(t, err, context.Canceled)The %w wrap in runSessionParserWithSources keeps errors.Is working. Call requireSessionTestNode(t) first, as the sibling tests do.
@copilot please address this.
| auditLog.Printf("Parsing agent and firewall logs for run %d", runID) | ||
| parseAgentLogIfRequested(runID, runOutputDir, opts.Verbose) | ||
| parseAgentLogIfRequested(ctx, runID, runOutputDir, opts.Verbose) | ||
| parseFirewallLogsIfRequested(runID, runOutputDir, opts.Verbose) |
There was a problem hiding this comment.
[/diagnosing-bugs] The cancellation fix stops at this call. parseAuditLogsIfRequested now receives ctx, but parseFirewallLogsIfRequested is still called without it, and parseFirewallLogs runs exec.Command("node", ...) at pkg/cli/logs_parsing_firewall.go:219. Ctrl+C or a deadline will still leave that node child running, which is the same symptom this PR fixes.
💡 Suggested change
Thread ctx through the firewall helpers the same way, and switch the child to exec.CommandContext(ctx, "node", nodeFile). If the firewall path is deliberately deferred, say so in the PR description.
@copilot please address this.
Comment MemoryPeek at saved memory (review-history)History |
|
🍳 A little prep to help this PR along! Copilot assignment requested for the following outstanding work:
Keeping the changes focused; human review and CI get the final taste test. No merging or CI triggering. Structured data{
"completed_task": 0,
"head": "1a3ee94442516f7c287a5b84cbdf2f838d8c5c2d",
"kind": "requested",
"schema_version": "1",
"state": "30d653b5d27dd8efc35ae36b6cc7116b3a8932e19f660f6cde4b3f346f581450",
"work": [
"1027833686a7050a64d8bfe136387980a34b94be7e9b120f51fd825652824672",
"12e2d92b8c5b535f1d3147e14962e78f9a50d376e8a16f13e4326968dc5aa3f5",
"20c5fb9e2e37672daf5b7271dae9c95ff59f03cf41d0cde5ac7e2acc9456d2d1",
"3015d50f40986eeb1f70f6abd38b628ae18e0dd02ea748d522efe0d66f80a51f",
"41c633c50467b0f2dc87116833139ebf287e1ad59f1a015d8d1dfedd9d1b23f1",
"42e5d572d9d75b7168fe7d0aeda0717cc07e65ed240f6d299e6fec661214f1ac",
"4ce4dd407e604d374ecd66edfd2afc18c54e2d0b3733dbac37ac8e9c8834fdba",
"6890db2d1f5ad1e52f17f44fea3b0f5de9e2441b83440ac6d6a8b68ece43deff",
"8acb61a077717e3a460018aacdfde96fd489f77606cd36169e2328d9079b75bb",
"9f329b57d351108a3c97449b5c5517fec3d320c266cdf992b531b7673be16e95",
"b855fc6fcb55b78d8a97b8924885cae846819f33bbc1dec6e0b470fbcf24991c",
"cabafb2817b103330ac0d1e2e098f214c40c4ca2be128895a8b14391f7e3306f",
"e2b1dcdd50909d11ea908683e207665058785302844e162780d5fdb2120a01e0",
"f608a3b4d2ea8983984f0ad739cad7561bee404a606e877bbdf42d2f19569a73",
"f7883e8c8105930e955354caa741d783bcca067e66097fe9612fb72b90823998"
],
"workflow": "pr-sous-chef"
}
|
…t-log-parse-r128-5b0808500d677171 Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Merged |
|
🍳 A little prep to help this PR along! Copilot assignment requested for the following outstanding work:
Keeping the changes focused; human review and CI get the final taste test. No merging or CI triggering. Structured data{
"completed_task": 0,
"head": "b18a0b59c2de744b3f373c8b967ad9bbc66684b8",
"kind": "requested",
"schema_version": "1",
"state": "7ad13d99c65e2d51a73386ee9b465eb9e30bc56e841e3d0fd24b67d62d50c6ce",
"work": [
"42e5d572d9d75b7168fe7d0aeda0717cc07e65ed240f6d299e6fec661214f1ac"
],
"workflow": "pr-sous-chef"
}
|
…t-log-parse-r128-5b0808500d677171 Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
| if parserSource := behaviorEngine.GetLogParserScriptSource(); parserSource != "" { | ||
| output, err = runSessionParserWithSources( | ||
| context.Background(), | ||
| ctx, |
| } | ||
| output, err := runSessionParserWithSources( | ||
| context.Background(), | ||
| ctx, |
Merged the latest |
|
🎉 This pull request is included in a new release. Release: |

Summary
Thread the caller's
context.Contextthrough the agent-log parsing helpers so the Node session-parser subprocess is cancelled together withgh aw logs/gh aw audit.Evidence
runSessionParserWithSources(pkg/cli/session_parser.go:123) usesexec.CommandContext(ctx, "node", ...), but these callers passedcontext.Background():pkg/cli/logs_parsing_persisted.goparseUnifiedAgentLog: 2 sitespkg/cli/logs_parsing_javascript.goparseAgentLog: 3 sitesEvery production caller already held a cancellable context and dropped it:
orderedLogsRunCollector.processReadyResult→parseWorkflowRunArtifactsc.ctxlogs_orchestrator_stdin.go)ctxrenderPreparedAuditReport→parseAuditLogsIfRequested→parseAgentLogIfRequestedctxImpact: on Ctrl+C or a deadline,
nodesession-parser children kept running to completion. The sibling session parsers (sessions_download.go,session_normalization.go,session_atif.go) already passctx.Change
Add a leading
ctx context.Contextparameter toparseAgentLog,parseUnifiedAgentLog,parsePersistedAgentLog,parseWorkflowRunArtifacts,parseAuditLogsIfRequestedandparseAgentLogIfRequested, and pass the caller's context. Existing tests now passt.Context(). No behaviour change when the context is never cancelled.Validation
audit_render_output.go,logs_parsing_javascript.go,logs_orchestrator_download.goandlogs_parsing_persisted_test.go: 0 errors.go build,go test,make fmt. Thegoandmakecommands were denied in this sandbox, so please rely on CI for compile and test results.context.Background()sites inpkg/cliwere not audited in this PR.🤖 Generated with [Claude Code]((claude.com/redacted)