diff --git a/.github/actions/strands-agent-runner/action.yml b/.github/actions/strands-agent-runner/action.yml index 6d4c2d7fb..d0e93effe 100644 --- a/.github/actions/strands-agent-runner/action.yml +++ b/.github/actions/strands-agent-runner/action.yml @@ -149,7 +149,7 @@ runs: STRANDS_TOOL_CONSOLE_MODE: 'enabled' BYPASS_TOOL_CONSENT: 'true' run: | - uv run --no-project ${{ runner.temp }}/strands-agent-runner/.github/scripts/python/agent_runner.py "$INPUT_TASK" + uv run --no-project ${{ runner.temp }}/strands-agent-runner/.github/scripts/python/agent_runner.py - name: Capture repository state shell: bash diff --git a/.github/scripts/javascript/process-input.cjs b/.github/scripts/javascript/process-input.cjs index b7ed29263..395e37b64 100644 --- a/.github/scripts/javascript/process-input.cjs +++ b/.github/scripts/javascript/process-input.cjs @@ -8,9 +8,10 @@ async function getIssueInfo(github, context, inputs) { const issueId = context.eventName === 'workflow_dispatch' ? inputs.issue_id : context.payload.issue.number.toString(); + const commentBody = context.payload.comment?.body || ''; const command = context.eventName === 'workflow_dispatch' ? inputs.command - : (context.payload.comment.body.match(/^\/strands\s*(.*?)$/m)?.[1]?.trim() || ''); + : (commentBody.startsWith('/strands') ? commentBody.slice('/strands'.length).trim() : ''); console.log(`Event: ${context.eventName}, Issue ID: ${issueId}, Command: "${command}"`); @@ -76,10 +77,25 @@ function buildPrompts(mode, issueId, isPullRequest, command, branchName, inputs) const scriptFile = scriptFiles[mode] || scriptFiles['refiner']; const systemPrompt = fs.readFileSync(scriptFile, 'utf8'); + // Extract the user's feedback/instructions after the mode keyword + // e.g., "release-notes Move #123 to Major Features" -> "Move #123 to Major Features" + const modeKeywords = { + 'release-notes': /^(?:release-notes|release notes)\s*/i, + 'implementer': /^implement\s*/i, + 'refiner': /^refine\s*/i + }; + + const modePattern = modeKeywords[mode]; + const userFeedback = modePattern ? command.replace(modePattern, '').trim() : command.trim(); + let prompt = (isPullRequest) ? 'The pull request id is:' : 'The issue id is:'; - prompt += `${issueId}\n${command}\nreview and continue`; + prompt += `${issueId}\n`; + + // If there's any user feedback beyond the command keyword, include it as the main instruction, + // otherwise default to "review and continue" + prompt += userFeedback || 'review and continue'; return { sessionId, systemPrompt, prompt }; } diff --git a/.github/scripts/python/agent_runner.py b/.github/scripts/python/agent_runner.py index db10ceadb..9d92c2ac4 100644 --- a/.github/scripts/python/agent_runner.py +++ b/.github/scripts/python/agent_runner.py @@ -142,13 +142,12 @@ def run_agent(query: str): def main() -> None: """Main entry point for the agent runner.""" try: - # Read task from command line arguments - if len(sys.argv) < 2: - raise ValueError("Task argument is required") - - task = " ".join(sys.argv[1:]) - if not task.strip(): - raise ValueError("Task cannot be empty") + # Prefer INPUT_TASK env var (avoids shell escaping issues), fall back to CLI args + task = os.getenv("INPUT_TASK", "").strip() + if not task and len(sys.argv) > 1: + task = " ".join(sys.argv[1:]).strip() + if not task: + raise ValueError("Task is required (via INPUT_TASK env var or CLI argument)") print(f"🤖 Running agent with task: {task}") run_agent(task)