diff --git a/factory/agents/prompts/ceo.md b/factory/agents/prompts/ceo.md index 5f730e4..78694b5 100644 --- a/factory/agents/prompts/ceo.md +++ b/factory/agents/prompts/ceo.md @@ -1143,7 +1143,37 @@ Save the printed experiment ID as `$EXP_ID`. #### 2c. Create GitHub Issue -For **code-only** hypotheses (`**Type:** code` or no Type field): +**Pre-check: Reuse existing issues before creating new ones.** + +Before creating a new issue, check if the hypothesis text or the backlog item tag references an existing issue number. + +1. Parse the hypothesis text and the `**Backlog item:**` tag (if present) for issue references. Prefer matches in this order: + a. Explicit references: `Addresses:? #NNN`, `**Backlog item:** #NNN`, or `issue #NNN` + b. If no explicit match and exactly one bare `#NNN` is present, fall back to it + c. If multiple bare `#NNN` references remain ambiguous, skip reuse and create a new issue (link the others in the body) +2. If a reference is found, verify the issue is open: + ```bash + (cd "$PROJECT_PATH" && gh issue view --json state --jq '.state') 2>/dev/null + ``` + If the command fails or returns anything other than `OPEN`, treat as no existing issue and proceed to create a new one. +3. If the issue is open, reuse it: set `$ISSUE_NUM` to that number, post an update comment with the current experiment context, and **skip issue creation**: + ```bash + gh issue comment "$ISSUE_NUM" --body "**Updated for experiment $EXP_ID** + + ## Current hypothesis + + + ## What to build (this cycle) + + + ## Acceptance criteria (this cycle) + - [ ] + - [ ] Tests pass + - [ ] Eval score does not regress" + ``` +4. Only create a new issue if no existing open reference is found + +For **code-only** hypotheses (`**Type:** code` or no Type field), when no existing issue is found: ```bash gh issue create \ @@ -1164,7 +1194,7 @@ gh issue create \ - Do NOT touch files outside declared scope" ``` -For **operational or mixed** hypotheses (`**Type:** operational` or `**Type:** mixed`), add execution sections: +For **operational or mixed** hypotheses (`**Type:** operational` or `**Type:** mixed`), when no existing issue is found, add execution sections: ```bash gh issue create \ @@ -2059,6 +2089,38 @@ factory begin "$PROJECT_PATH" --hypothesis "" Save the printed experiment ID as `$EXP_ID`. +**Pre-check: Reuse existing issues before creating new ones.** + +Before creating a new issue, check if the hypothesis text references an existing issue number. + +1. Parse the hypothesis text and the `**Backlog item:**` tag (if present) for issue references. Prefer matches in this order: + a. Explicit references: `Addresses:? #NNN`, `**Backlog item:** #NNN`, or `issue #NNN` + b. If no explicit match and exactly one bare `#NNN` is present, fall back to it + c. If multiple bare `#NNN` references remain ambiguous, skip reuse and create a new issue (link the others in the body) +2. If a reference is found, verify the issue is open: + ```bash + (cd "$PROJECT_PATH" && gh issue view --json state --jq '.state') 2>/dev/null + ``` + If the command fails or returns anything other than `OPEN`, treat as no existing issue and proceed to create a new one. +3. If the issue is open, reuse it: set `$ISSUE_NUM` to that number, post an update comment with the current experiment context, and **skip issue creation**: + ```bash + gh issue comment "$ISSUE_NUM" --body "**Updated for experiment $EXP_ID** + + ## Current hypothesis + + + ## What to build (this cycle) + + + ## Acceptance criteria (this cycle) + - [ ] + - [ ] Tests pass + - [ ] Eval score does not regress" + ``` +4. Only create a new issue if no existing open reference is found + +When no existing issue is found: + ```bash gh issue create \ --title "" \