Skip to content
Open
Changes from all commits
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
66 changes: 64 additions & 2 deletions factory/agents/prompts/ceo.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <number> --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
<hypothesis text>

## What to build (this cycle)
<specific changes>

## Acceptance criteria (this cycle)
- [ ] <outcomes>
- [ ] 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 \
Expand All @@ -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 \
Expand Down Expand Up @@ -2059,6 +2089,38 @@ factory begin "$PROJECT_PATH" --hypothesis "<hypothesis text>"

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 <number> --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
<hypothesis text>

## What to build (this cycle)
<specific changes>

## Acceptance criteria (this cycle)
- [ ] <outcomes>
- [ ] 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 "<hypothesis title>" \
Expand Down
Loading