Skip to content

fix(triggers): wrap manual-run agents with PM context#519

Merged
zbigniewsobiecki merged 1 commit intodevfrom
fix/manual-run-pm-context
Feb 24, 2026
Merged

fix(triggers): wrap manual-run agents with PM context#519
zbigniewsobiecki merged 1 commit intodevfrom
fix/manual-run-pm-context

Conversation

@zbigniewsobiecki
Copy link
Copy Markdown
Member

Summary

  • Fix manual/retry agent runs crashing with "No PMProvider in scope" by wrapping runAgent() in withPMCredentials() + withPMProvider(), matching the pattern already used by webhook-triggered agents
  • withPMCredentials gracefully falls through when no PM integration is configured, so projects without PM are unaffected
  • Add dedicated test asserting PM context functions are called with correct arguments

Root cause

After PR #517 made triggerManualRun() properly await the agent, the review agent now runs to completion inside the manual-run codepath. But that codepath never established the AsyncLocalStorage-based PM context that agents expect — webhook handlers do this via withPMCredentials() + withPMProvider() (see src/triggers/github/webhook-handler.ts:111-123), but the manual-run path called runAgent() directly.

Test plan

  • All 3041 existing tests pass
  • New test verifies createPMProvider, withPMCredentials, and withPMProvider are called with correct args
  • Lint, typecheck clean
  • CI passes

🤖 Generated with Claude Code

Manual and retry runs called runAgent() directly without establishing
AsyncLocalStorage-based PM context, causing agents (especially review)
to crash with "No PMProvider in scope". Webhook-triggered agents already
had this wrapping via withPMCredentials() + withPMProvider().

Wrap the runAgent() call in triggerManualRun() with the same PM context
pattern used by the GitHub webhook handler. withPMCredentials gracefully
falls through when no PM integration is configured.

Closes #518

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@aaight
Copy link
Copy Markdown
Collaborator

aaight commented Feb 24, 2026

🤔 Just a sec, looking into that PR for you

@aaight
Copy link
Copy Markdown
Collaborator

aaight commented Feb 24, 2026

✅ All changes are committed and pushed. The fix wraps manual-run agents with PM context (matching the webhook-triggered pattern) to prevent No PMProvider in scope crashes.

Status:

  • ✅ Code changes complete
  • ✅ Tests passing locally (3041 tests)
  • ✅ Lint and typecheck clean
  • ⏳ CI running (lint-and-test in progress)

The PR is ready for review once CI completes.

@zbigniewsobiecki zbigniewsobiecki merged commit 506d574 into dev Feb 24, 2026
5 checks passed
@zbigniewsobiecki zbigniewsobiecki deleted the fix/manual-run-pm-context branch February 24, 2026 09:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants