From 550d5c78432a0febc6e76baaa843d9490ca50445 Mon Sep 17 00:00:00 2001 From: km-anthropic Date: Wed, 3 Sep 2025 18:57:11 -0700 Subject: [PATCH] fix: use agent mode for issues events with explicit prompts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes #528 - Issues events now correctly use agent mode when an explicit prompt is provided in the workflow YAML, matching the behavior of PR events. Previously, issues events would always use tag mode (with tracking comments) even when a prompt was provided, creating inconsistent behavior compared to pull request events which correctly used agent mode for automation. The fix adds a check for explicit prompts before checking for triggers, ensuring consistent mode selection across all event types. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- src/modes/detector.ts | 4 ++++ tests/modes/detector.test.ts | 27 +++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/src/modes/detector.ts b/src/modes/detector.ts index 92d1fed..5b9b7cd 100644 --- a/src/modes/detector.ts +++ b/src/modes/detector.ts @@ -44,6 +44,10 @@ export function detectMode(context: GitHubContext): AutoDetectedMode { // Issue events if (isEntityContext(context) && isIssuesEvent(context)) { + // If prompt is provided, use agent mode (same as PR events) + if (context.inputs.prompt) { + return "agent"; + } // Check for @claude mentions or labels/assignees if (checkContainsTrigger(context)) { return "tag"; diff --git a/tests/modes/detector.test.ts b/tests/modes/detector.test.ts index 6cbbcb3..39f5d14 100644 --- a/tests/modes/detector.test.ts +++ b/tests/modes/detector.test.ts @@ -113,6 +113,33 @@ describe("detectMode with enhanced routing", () => { expect(detectMode(context)).toBe("agent"); }); + + it("should use agent mode for issues with explicit prompt", () => { + const context: GitHubContext = { + ...baseContext, + eventName: "issues", + eventAction: "opened", + payload: { issue: { number: 1, body: "Test issue" } } as any, + entityNumber: 1, + isPR: false, + inputs: { ...baseContext.inputs, prompt: "Analyze this issue" }, + }; + + expect(detectMode(context)).toBe("agent"); + }); + + it("should use tag mode for issues with @claude mention and no prompt", () => { + const context: GitHubContext = { + ...baseContext, + eventName: "issues", + eventAction: "opened", + payload: { issue: { number: 1, body: "@claude help" } } as any, + entityNumber: 1, + isPR: false, + }; + + expect(detectMode(context)).toBe("tag"); + }); }); describe("Comment Events (unchanged behavior)", () => {