Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/actions/strands-agent-runner/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
24 changes: 22 additions & 2 deletions .github/scripts/javascript/process-input.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -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}"`);

Expand Down Expand Up @@ -76,10 +77,29 @@ 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 substantial user feedback beyond just the command keyword, include it as the main instruction
// Otherwise, use the default "review and continue" for initial triggers
if (userFeedback && userFeedback.length > 0) {
prompt += userFeedback;
} else {
prompt += 'review and continue';
}

return { sessionId, systemPrompt, prompt };
}
Expand Down
13 changes: 6 additions & 7 deletions .github/scripts/python/agent_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Loading