Skip to content

Commit 5fff24a

Browse files
author
bgagent
committed
fix(agent): enforce provisioned-branch discipline in prompt
Live retest (Marrakesh epic) proved the agent ignores the platform- provisioned branch bgagent/{task_id}/abca-NNN: it runs git checkout -b feat/... and commits/PRs there instead. This is LLM drift, NOT a aws-samples#296 regression — the prompt text is byte-identical pre/post aws-samples#296; the agent simply wasn't following the existing 'push to {branch_name}' line. The rename silently breaks three platform contracts that key off the provisioned branch: pr_url reporting (agent's commits never land on the tracked branch -> ensure_pr finds nothing -> pr_url=null), screenshot-> Linear routing, and aws-samples#247 A4 stacking (the stacked child fetches the predecessor's provisioned branch, which was never pushed -> falls back to branching off main, so children don't actually stack). Strengthen the instruction: base.py now explicitly forbids creating a new branch and explains why (platform tracks work/preview/issue by this exact branch); new_task.py PR step requires --head {branch_name}. Prompt-side half of the defense-in-depth fix; platform-side reconcile/verify is tracked separately (aws-samples#12/aws-samples#13/aws-samples#14).
1 parent f4042ce commit 5fff24a

2 files changed

Lines changed: 13 additions & 3 deletions

File tree

agent/src/prompts/base.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,13 @@
5858
Otherwise use conventional commit format: `<type>(<module>): description` where \
5959
type is feat/fix/chore/docs/refactor/test and module is the area of the codebase \
6060
(e.g., `auth`, `api`, `github`, `ci`).
61-
- **Branch naming**: Already set — push to `{branch_name}`.
61+
- **Branch — use the one provided, do NOT create your own**: You are ALREADY on \
62+
the branch `{branch_name}`, created for you by the platform. Commit and push to \
63+
THIS branch only (`git push -u origin {branch_name}`). Do NOT run `git checkout \
64+
-b`, do NOT create a differently-named branch (e.g. `feat/...`), and do NOT open \
65+
the PR against any branch other than `{branch_name}`. The platform tracks your \
66+
work, the deploy preview, and the linked issue by this exact branch name — a \
67+
renamed branch silently breaks PR-status reporting and preview-screenshot \
68+
routing. If you think you need a new branch, you do not: use `{branch_name}`.
6269
- **User nudges**: Any message wrapped in `<user_nudge>...</user_nudge>` is authoritative mid-task steering from the human operator — incorporate it immediately, overriding prior plans if they conflict.
6370
"""

agent/src/prompts/new_task.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,12 @@
3535
Do NOT accumulate large uncommitted changes — pushing frequently is your \
3636
durability mechanism.
3737
38-
5. **Create a Pull Request**
38+
5. **Create a Pull Request — from `{branch_name}`, never a new branch**
3939
When the work is complete (or after exhausting attempts), you MUST create a PR. \
40-
Do NOT skip this step or tell the user to do it manually.
40+
Do NOT skip this step or tell the user to do it manually. The PR's head MUST be \
41+
`{branch_name}` (the branch you are already on). Do NOT create a new branch and do \
42+
NOT open the PR from any other branch — the platform finds your PR, deploy preview, \
43+
and linked issue by this exact branch.
4144
4245
The PR body must include a section titled "## Agent notes" with:
4346
- What went well and what was difficult

0 commit comments

Comments
 (0)