Skip to content

Commit 50e5e74

Browse files
authored
feat: provide extra command content as the the prompt to the agent (#1419)
Previously triggering the agent would always provide the prompt of "review and continue" to the agent; this meant that if you gave the agent explicit commands in the comment it wouldn't necessarily receive/act on those. For example: /strands you didn't do X, please do it It would not actually receive the extra text; this updates it so that everything after the "strands command" is added as the prompt, defaulting to "review and continue" if non is provided --------- Co-authored-by: Mackenzie Zastrow <zastrowm@users.noreply.github.com>
1 parent 695ca66 commit 50e5e74

File tree

3 files changed

+25
-10
lines changed

3 files changed

+25
-10
lines changed

.github/actions/strands-agent-runner/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ runs:
149149
STRANDS_TOOL_CONSOLE_MODE: 'enabled'
150150
BYPASS_TOOL_CONSENT: 'true'
151151
run: |
152-
uv run --no-project ${{ runner.temp }}/strands-agent-runner/.github/scripts/python/agent_runner.py "$INPUT_TASK"
152+
uv run --no-project ${{ runner.temp }}/strands-agent-runner/.github/scripts/python/agent_runner.py
153153
154154
- name: Capture repository state
155155
shell: bash

.github/scripts/javascript/process-input.cjs

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@ async function getIssueInfo(github, context, inputs) {
88
const issueId = context.eventName === 'workflow_dispatch'
99
? inputs.issue_id
1010
: context.payload.issue.number.toString();
11+
const commentBody = context.payload.comment?.body || '';
1112
const command = context.eventName === 'workflow_dispatch'
1213
? inputs.command
13-
: (context.payload.comment.body.match(/^\/strands\s*(.*?)$/m)?.[1]?.trim() || '');
14+
: (commentBody.startsWith('/strands') ? commentBody.slice('/strands'.length).trim() : '');
1415

1516
console.log(`Event: ${context.eventName}, Issue ID: ${issueId}, Command: "${command}"`);
1617

@@ -76,10 +77,25 @@ function buildPrompts(mode, issueId, isPullRequest, command, branchName, inputs)
7677
const scriptFile = scriptFiles[mode] || scriptFiles['refiner'];
7778
const systemPrompt = fs.readFileSync(scriptFile, 'utf8');
7879

80+
// Extract the user's feedback/instructions after the mode keyword
81+
// e.g., "release-notes Move #123 to Major Features" -> "Move #123 to Major Features"
82+
const modeKeywords = {
83+
'release-notes': /^(?:release-notes|release notes)\s*/i,
84+
'implementer': /^implement\s*/i,
85+
'refiner': /^refine\s*/i
86+
};
87+
88+
const modePattern = modeKeywords[mode];
89+
const userFeedback = modePattern ? command.replace(modePattern, '').trim() : command.trim();
90+
7991
let prompt = (isPullRequest)
8092
? 'The pull request id is:'
8193
: 'The issue id is:';
82-
prompt += `${issueId}\n${command}\nreview and continue`;
94+
prompt += `${issueId}\n`;
95+
96+
// If there's any user feedback beyond the command keyword, include it as the main instruction,
97+
// otherwise default to "review and continue"
98+
prompt += userFeedback || 'review and continue';
8399

84100
return { sessionId, systemPrompt, prompt };
85101
}

.github/scripts/python/agent_runner.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -142,13 +142,12 @@ def run_agent(query: str):
142142
def main() -> None:
143143
"""Main entry point for the agent runner."""
144144
try:
145-
# Read task from command line arguments
146-
if len(sys.argv) < 2:
147-
raise ValueError("Task argument is required")
148-
149-
task = " ".join(sys.argv[1:])
150-
if not task.strip():
151-
raise ValueError("Task cannot be empty")
145+
# Prefer INPUT_TASK env var (avoids shell escaping issues), fall back to CLI args
146+
task = os.getenv("INPUT_TASK", "").strip()
147+
if not task and len(sys.argv) > 1:
148+
task = " ".join(sys.argv[1:]).strip()
149+
if not task:
150+
raise ValueError("Task is required (via INPUT_TASK env var or CLI argument)")
152151
print(f"🤖 Running agent with task: {task}")
153152

154153
run_agent(task)

0 commit comments

Comments
 (0)