Repository navigation
Thread caller context through dispatcher skill content fetch - #78596
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.
|
|
✅ 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.
|
|
🧠 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.
|
Comment MemoryPeek at saved memory (pr-code-quality-reviewer)Note This comment is managed by comment memory.Expand the saved memory block to view or edit the persistent context for this thread.
|
There was a problem hiding this comment.
Found two cancellation correctness issues that should be fixed before merge.
Highlights
- Cancelled dispatcher fetches are silently converted to fallback content and may still write files.
- Interactive
addstill drops context on its actual initialization path.
🔎 Code quality review by PR Code Quality Reviewer · copilot · gpt50 · ~4 AIC · ⌖ ~1 AIC · ⊞ 1.5K
Comment /review to run again
| func buildAgenticWorkflowsSkillContent() (string, error) { | ||
| awFiles, err := listAgenticWorkflowsMarkdownFiles(context.Background()) | ||
| func buildAgenticWorkflowsSkillContent(ctx context.Context) (string, error) { | ||
| awFiles, err := listAgenticWorkflowsMarkdownFiles(ctx) |
There was a problem hiding this comment.
Passing the caller context here does not actually honor cancellation: buildAgenticWorkflowsSkillContent converts every fetch error, including context.Canceled/DeadlineExceeded, into embedded fallback content, so Ctrl-C can still report success and write a stale SKILL.md.
💡 Preserve cancellation semantics
Return cancellation errors instead of falling back (for example, check ctx.Err() before selecting the embedded list); only use the fallback for unrelated fetch failures. Add a cancelled-context test that verifies no generated artifact is written.
There was a problem hiding this comment.
The dispatcher now returns the caller’s context error before applying fallback content, and the regression test verifies cancellation leaves the skill file unwritten. Fixed in c025330.
| } | ||
|
|
||
| func initializeAddRepositoryFiles(markers []string, engineOverride string, verbose bool, noGitattributes bool) ([]string, error) { | ||
| func initializeAddRepositoryFiles(ctx context.Context, markers []string, engineOverride string, verbose bool, noGitattributes bool) ([]string, error) { |
There was a problem hiding this comment.
This context-aware init path is still bypassed by interactive add: applyAddRepositoryInitialization calls ensureAddRepositoryInitializedFromPlan, whose InitOptions does not carry the context used during confirmation, so the dispatcher fetch triggered by that real initialization remains on context.Background() and Ctrl-C cannot interrupt it.
💡 Thread context through the plan-application path
Add ctx to applyAddRepositoryInitialization and ensureAddRepositoryInitializedFromPlan, then set InitOptions.Ctx when invoking addInitRepository. This keeps both regular and interactive add cancellation behavior consistent.
There was a problem hiding this comment.
The interactive add plan path now carries its context into InitOptions; the regression test verifies cancellation propagates through initialization. Fixed in c025330.
Comment MemoryPeek at saved memory (spec-review-history)History |
Comment MemoryPeek at saved memory (review-history)History |
| func buildAgenticWorkflowsSkillContent() (string, error) { | ||
| awFiles, err := listAgenticWorkflowsMarkdownFiles(context.Background()) | ||
| func buildAgenticWorkflowsSkillContent(ctx context.Context) (string, error) { | ||
| awFiles, err := listAgenticWorkflowsMarkdownFiles(ctx) |
There was a problem hiding this comment.
🟡 Changes recommended
Caller cancellation is swallowed by the embedded fallback, allowing init or upgrade to overwrite SKILL.md and continue after Ctrl-C instead of returning the context error.
1 open issue
What changed in this PR
This PR threads caller context through gh-aw’s dispatcher skill fetch so cancellation can interrupt the GitHub API request.
Changes:
- Passes context through dispatcher generation and bootstrap marker checks.
- Connects command contexts from
init,upgrade,fix,compile --fix, and regularadd, with a nil-context fallback forFixConfig. - Updates existing test calls and mocks for the new signatures.
| File | Description |
|---|---|
pkg/cli/upgrade_command.go |
Passes upgrade context to fixes and dispatcher updates. |
pkg/cli/init.go |
Passes initialization context to dispatcher generation. |
pkg/cli/fix_command.go |
Adds context support to fix configuration and execution. |
pkg/cli/copilot_agents.go |
Forwards caller context to the markdown-list fetch. |
pkg/cli/copilot_agents_test.go |
Updates skill-generation tests to pass context. |
pkg/cli/bootstrap_shared.go |
Threads context through bootstrap marker checks. |
pkg/cli/add_interactive_orchestrator_test.go |
Updates marker-check mock signatures. |
pkg/cli/add_init.go |
Propagates context through regular add initialization. |
pkg/cli/add_command.go |
Supplies command context to repository initialization. |
pkg/cli/add_command_test.go |
Updates initialization tests and mocks for context. |
cmd/gh-aw/main.go |
Supplies command context to compile --fix. |
Review effort: Balanced (adaptive)
| func buildAgenticWorkflowsSkillContent() (string, error) { | ||
| awFiles, err := listAgenticWorkflowsMarkdownFiles(context.Background()) | ||
| func buildAgenticWorkflowsSkillContent(ctx context.Context) (string, error) { | ||
| awFiles, err := listAgenticWorkflowsMarkdownFiles(ctx) |
There was a problem hiding this comment.
The dispatcher now returns the caller’s context error before applying fallback content, preventing cancelled init or upgrade from writing fallback SKILL.md. Fixed in c025330.
There was a problem hiding this comment.
Skills-Based Review 🧠
Applied /diagnosing-bugs, /tdd and /codebase-design. Requesting changes because the new cancellation plumbing is silently swallowed.
📋 Key Themes & Highlights
Key Themes
- Cancellation is swallowed:
buildAgenticWorkflowsSkillContentfalls back to the embedded list and returnsnilwhen the context is cancelled. Ctrl-C aborts the HTTP call only, soinit,upgrade,fixandaddkeep running (copilot_agents.go:203). - Missing ctx-propagation test: the mock ignores its context, so a regression that drops
ctxwould still pass (copilot_agents_test.go:330). - Partial
addcoverage: the plan and interactive paths still dropctx(add_init.go:121). - Nil-context hardening:
upgradepassesopts.ctxwithoutctxutil.OrBackground, unlikeinitandfix(upgrade_command.go:466). This is latent, not an active bug.
Verification
gofmt -lis clean on all 10 touched Go files.go build ./cmd/gh-aw/ ./pkg/cli/andgo vet ./pkg/cli/pass.- Targeted
go test ./pkg/cli/passes for the affected tests. - A throwaway red test asserting
context.Canceledfails on the current code. The probe files were removed. - I did not run the full
make test-unitsuite.
Positive Highlights
- ✅ The signature changes are consistent across all non-test callers and test call sites.
- ✅
initializeAddRepositoryFilescorrectly forwardsCtxintoInitOptions. - ✅
initandfixnormalise nil contexts withctxutil.OrBackground.
@copilot please address the review comments above.
🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · copilot · routed: haiku55 xhigh · ~7 AIC · ⌖ ~2 AIC · ⊞ 6.6K
Comment /matt to run again
| func buildAgenticWorkflowsSkillContent() (string, error) { | ||
| awFiles, err := listAgenticWorkflowsMarkdownFiles(context.Background()) | ||
| func buildAgenticWorkflowsSkillContent(ctx context.Context) (string, error) { | ||
| awFiles, err := listAgenticWorkflowsMarkdownFiles(ctx) |
There was a problem hiding this comment.
[/diagnosing-bugs] Cancellation is swallowed here. When ctx is cancelled, the fetch fails, this block logs a warning and falls back to the embedded list, and the function returns err == nil. Ctrl-C therefore only aborts the HTTP call; init, upgrade, fix and add keep running and write the fallback skill.
💡 Suggested fix
Return the cancellation before falling back:
awFiles, err := listAgenticWorkflowsMarkdownFiles(ctx)
if err != nil {
if ctxErr := ctx.Err(); ctxErr != nil {
return "", ctxErr
}
// existing warning and fallback
awFiles = embeddedFallbackAWMarkdownFiles()
}A regression test should assert that a cancelled context returns an error wrapping context.Canceled. I ran that test against this branch and it fails with Expected error with "context canceled" in chain but got nil.
@copilot please address this.
There was a problem hiding this comment.
Added a cancellation regression test and now return the caller’s context error before applying embedded fallback content. Fixed in c025330.
| withMockAWMarkdownFileList(t, []string{"workflow-z.md", "workflow-a.md"}, nil) | ||
|
|
||
| content, err := buildAgenticWorkflowsSkillContent() | ||
| content, err := buildAgenticWorkflowsSkillContent(t.Context()) |
There was a problem hiding this comment.
[/tdd] This call now passes t.Context(), but nothing checks that the context is actually threaded. withMockAWMarkdownFileList ignores its context argument, so a regression that drops ctx (for example passing context.Background() again) would still pass.
💡 Suggested test
Add a test that cancels the context, captures the context the mock receives, and fails if the cancellation is lost. Write it first so it fails on the current code, then fix the swallowed error.
func TestBuildAgenticWorkflowsSkillContentReturnsCancellation(t *testing.T) {
ctx, cancel := context.WithCancel(t.Context())
cancel()
var seen context.Context
previous := listAgenticWorkflowsMarkdownFiles
listAgenticWorkflowsMarkdownFiles = func(c context.Context) ([]string, error) {
seen = c
return nil, c.Err()
}
t.Cleanup(func() { listAgenticWorkflowsMarkdownFiles = previous })
_, err := buildAgenticWorkflowsSkillContent(ctx)
require.ErrorIs(t, err, context.Canceled)
assert.Equal(t, ctx, seen)
}@copilot please address this.
There was a problem hiding this comment.
The regression test now verifies the cancelled caller context reaches the fetch and that cancellation is returned. Fixed in c025330.
|
|
||
| func ensureAddRepositoryInitialized(engineOverride string, verbose bool, noGitattributes bool) error { | ||
| _, err := ensureAddRepositoryInitializedWithDetails(engineOverride, verbose, noGitattributes) | ||
| func ensureAddRepositoryInitialized(ctx context.Context, engineOverride string, verbose bool, noGitattributes bool) error { |
There was a problem hiding this comment.
[/codebase-design] The add coverage is only partial. ensureAddRepositoryInitialized now takes ctx, but the plan path still drops it: add_init.go:110 calls addInitRepository without Ctx, and the interactive flow calls applyAddRepositoryInitialization without a context at add_interactive_orchestrator.go:254. Ctrl-C during interactive add therefore still cannot abort the init work.
💡 Suggestion
Thread ctx through applyAddRepositoryInitialization and ensureAddRepositoryInitializedFromPlan as well, and set Ctx: ctx in the InitOptions literal at add_init.go:110, matching the change already made in initializeAddRepositoryFiles. Either fix the coverage or narrow the PR description so it no longer claims add is covered.
@copilot please address this.
There was a problem hiding this comment.
The interactive plan-application path now forwards context to InitOptions; the test verifies the exact context and cancellation propagation. Fixed in c025330.
|
@copilot run pr-finisher skill |
|
🍳 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": "7ebd1a783cc871b3119b3dc865d4a3cac7c0df85",
"kind": "requested",
"schema_version": "1",
"state": "0af34f8a235bb102a2128e811f8dfef114837e50edda8d181cf4a8cd38a6cb5e",
"work": [
"71efdf047fdea86e14c92efec14411dbc48cb98fcaba30241e8a022e5206e0b3"
],
"workflow": "pr-sous-chef"
}
|
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Updated the branch with |
|
🎉 This pull request is included in a new release. Release: |

Evidence
buildAgenticWorkflowsSkillContent(pkg/cli/copilot_agents.go) calledlistAgenticWorkflowsMarkdownFiles(context.Background()), which performs an HTTP request to the GitHub API for the.github/awmarkdown file list. Every caller already held a cancellable context (or a cobra command), so Ctrl-C / cancellation duringinit,upgrade,fixoraddcould not interrupt that network call.Found by Serena-assisted trace of the remaining non-test
context.Background()candidates listed in the previous run (copilot_agents.go:203).Change
buildAgenticWorkflowsSkillContent(ctx)andensureAgenticWorkflowsDispatcher(ctx, ...)now take a context.upgradepassesopts.ctx;initpasses itsctx;fixvia newFixConfig.Ctx(nil falls back viactxutil.OrBackground), set fromcmd.Context()in the cobrafixcommand,compile --fix(cmd/gh-aw/main.go) andupgrade.missingBootstrapInitMarkers/isBootstrapInitMarkerSatisfiedtake ctx;addpassescmd.Context()throughensureAddRepositoryInitialized[WithDetails]/initializeAddRepositoryFiles, which now also setsInitOptions.Ctx.addMissingInitMarkersstubs updated (t.Context()).No behaviour change when the context is never cancelled.
Not changed (out of scope)
applyAddRepositoryInitialization/ensureAddRepositoryInitializedFromPlanstill buildInitOptionswithoutCtx;compile_scanner_source.go:109still usescontext.Background()(no ctx on the scanner source loader chain).Validation
get_diagnostics_for_filereturned 0 diagnostics for:copilot_agents.go,add_init.go,fix_command.go,bootstrap_shared.go,upgrade_command.go,add_command_test.go,copilot_agents_test.go,add_interactive_orchestrator_test.go.go build,go test,make fmt,make agent-report-progresswere denied by the sandbox in this run, so compilation, gofmt and tests were NOT executed. Please rely on CI; gofmt alignment of the newCtxfield inFixConfigand thefixConfigliteral inupgrade_command.goshould be checked.🤖 Generated with [Claude Code]((claude.com/redacted)