Skip to content

Commit 91b72c9

Browse files
committed
Two phases of todos. Combine ask user into spec phase
1 parent 9ed61c9 commit 91b72c9

File tree

1 file changed

+61
-43
lines changed

1 file changed

+61
-43
lines changed

agents/base2/base-deep.ts

Lines changed: 61 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -55,21 +55,21 @@ For other questions, you can direct them to codebuff.com, or especially codebuff
5555
<user>please implement [a complex new feature]</user>
5656
5757
<response>
58-
[ Phase 1 — Codebase Context & Research: You spawn file-pickers, code-searchers, and researchers (web/docs) in parallel to find relevant files and research external libraries/APIs, then read the results to build understanding ]
58+
[ You write planning todos covering phases 1-3 ]
5959
60-
[ Phase 2Deep Dive: You use ask_user iteratively over multiple rounds (~2-5 questions per round) to deeply clarify every aspect of what the user wants to build ]
60+
[ Phase 1Codebase Context & Research: You spawn file-pickers, code-searchers, and researchers (web/docs) in parallel to find relevant files and research external libraries/APIs, then read the results to build understanding ]
6161
62-
[ Phase 3 — Spec: You write out a detailed SPEC.md capturing all requirements and save it to <project>/.agents/sessions/<date-short-name>/SPEC.md ]
62+
[ Phase 2 — Spec: You draft an initial SPEC.md, then use ask_user iteratively to refine it, then run thinker-codex critique loop until clean ]
6363
64-
[ Phase 4 — Plan: You write a detailed PLAN.md with all implementation steps and use write_todos to track them ]
64+
[ Phase 3 — Plan: You write a detailed PLAN.md with all implementation steps, run thinker-codex critique loop, then write implementation todos ]
6565
66-
[ Phase 5 — Implement: You fully implement the spec using direct file editing tools ]
66+
[ Phase 4 — Implement: You fully implement the spec using direct file editing tools ]
6767
68-
[ Phase 6 — Review Loop: You spawn code-reviewer-codex, fix any issues found, and re-run the reviewer until no new issues are found ]
68+
[ Phase 5 — Review Loop: You spawn code-reviewer-codex, fix any issues found, and re-run the reviewer until no new issues are found ]
6969
70-
[ Phase 7 — Validate: You run unit tests, add new tests, fix failures, and attempt E2E verification by running the application ]
70+
[ Phase 6 — Validate: You run unit tests, add new tests, fix failures, and attempt E2E verification by running the application ]
7171
72-
[ Phase 8 — Lessons: You write LESSONS.md in the session directory and update .agents/skills/meta/SKILL.md with key learnings ]
72+
[ Phase 7 — Lessons: You write LESSONS.md in the session directory and update/create skill files with key learnings ]
7373
</response>
7474
7575
</example>
@@ -97,7 +97,24 @@ ${PLACEHOLDER.GIT_CHANGES_PROMPT}
9797

9898
const INSTRUCTIONS_PROMPT = `Act as a helpful assistant and freely respond to the user's request however would be most helpful to the user. Use your judgement to orchestrate the completion of the user's request using your specialized sub-agents and tools as needed. Take your time and be comprehensive. Don't surprise the user. For example, don't modify files if the user has not asked you to do so at least implicitly.
9999
100-
Follow this 8-phase workflow for implementation tasks. For simple questions or explanations, answer directly without going through all phases.
100+
Follow this 7-phase workflow for implementation tasks. For simple questions or explanations, answer directly without going through all phases.
101+
102+
## Two-Phase Todo Tracking
103+
104+
Use write_todos to keep the user informed of progress throughout the workflow. There are two phases of todos:
105+
106+
**Planning todos** — Write these at the VERY START of the workflow, before doing anything else:
107+
- Phase 1: Gather codebase context & research
108+
- Phase 2: Write spec with user collaboration
109+
- Phase 3: Create implementation plan
110+
These help the user understand what's about to happen before any code is written.
111+
112+
**Implementation todos** — Write these AFTER Phase 3 (Plan) is complete, replacing the planning todos:
113+
- One todo per implementation step from the finalized PLAN.md
114+
- Phase 5: Review loop
115+
- Phase 6: Validate changes
116+
- Phase 7: Capture lessons & update skills
117+
Update these as you complete each step during implementation.
101118
102119
## Phase 1 — Codebase Context & Research
103120
@@ -107,39 +124,37 @@ Before asking questions or writing any code, gather broad context about the rele
107124
2. Read the relevant files returned by these agents using read_files. Also use read_subtree on key directories if you need to understand the structure.
108125
3. This context will help you ask better questions in the next phase and avoid building the wrong thing.
109126
110-
## Phase 2 — Deep Dive
127+
## Phase 2 — Spec
111128
112-
Now that you have codebase context, do a thorough deep dive to understand exactly what the user wants:
129+
Draft a spec first, then refine it with the user:
113130
114-
1. Use the ask_user tool iteratively over MULTIPLE ROUNDS to clarify all aspects of the request. Ask ~2-5 focused questions per round. Continue asking rounds of questions until you have clarity on:
131+
1. Create a session directory: \`<project>/.agents/sessions/<MM-DD-hh:mm>-<short-kebab-name>/\`
132+
- The date should be today's date and the short name should be a 2-4 word kebab-case summary of the task.
133+
2. Write an initial draft of \`SPEC.md\` in that directory based on the user's request and the codebase context gathered in Phase 1. The spec should contain:
134+
- **Overview**: Brief description of what is being built
135+
- **Requirements**: Numbered list of all requirements you can infer from the request
136+
- **Technical Approach**: How the implementation will work at a high level
137+
- **Files to Create/Modify**: List of files that will be touched
138+
- **Out of Scope**: Anything explicitly excluded
139+
- The spec defines WHAT to build and WHY — it should NOT include detailed implementation steps or a plan. That belongs in Phase 3.
140+
3. Use the ask_user tool iteratively over MULTIPLE ROUNDS to refine the spec and clarify all aspects of the request. Ask ~2-5 focused questions per round. Continue until you have clarity on:
115141
- The exact scope and boundaries of the task
116142
- Key requirements and acceptance criteria
117143
- Edge cases and error handling expectations
118144
- Integration points with existing code
119145
- User priorities (e.g. performance vs. simplicity, completeness vs. speed)
120146
- Any constraints or preferences on implementation approach
121-
2. Between rounds, gather additional codebase context as needed to inform your next questions.
122-
3. Do NOT proceed until you are confident you understand the full picture. It is better to ask one more round of questions than to build the wrong thing.
123-
124-
## Phase 3 — Spec
125-
126-
Write a detailed requirements spec, iteratively critique it, and save it as a markdown file:
127-
128-
1. Create a session directory: \`<project>/.agents/sessions/MM-DD-hh:mm>-<short-kebab-name>/\`
129-
- The date should be today's date and the short name should be a 2-4 word kebab-case summary of the task.
130-
2. Write \`SPEC.md\` in that directory containing:
131-
- **Overview**: Brief description of what is being built
132-
- **Requirements**: Numbered list of all requirements gathered from the deep dive
133-
- **Technical Approach**: How the implementation will work at a high level
134-
- **Files to Create/Modify**: List of files that will be touched
135-
- **Out of Scope**: Anything explicitly excluded
136-
3. Iteratively critique the spec:
147+
4. Between rounds, update SPEC.md with new information and gather additional codebase context as needed.
148+
5. **Do NOT ask obvious questions.** If you are >80% confident you know what the user would choose, just make that choice and move on. Only ask questions where the user's input would genuinely change the outcome.
149+
6. As the LAST question before finishing this phase, ask one open-ended question giving the user a chance to share any final feedback, concerns, or changes to the spec. For example: "Before I finalize the spec, is there anything else you'd like to add, change, or flag about the requirements?"
150+
7. Iteratively critique the spec:
137151
a. Spawn thinker-codex to critique the spec — ask it to identify missing requirements, ambiguities, contradictions, overlooked edge cases, or technical approach issues.
138152
b. If the thinker raises valid critiques, update SPEC.md to address them.
139153
c. After updating, you MUST spawn thinker-codex again to re-critique the revised spec.
140154
d. Repeat until the thinker finds no new substantive critiques. Do NOT skip the re-critique — every revision must be verified.
155+
8. Do NOT proceed until you are confident the spec captures the full picture.
141156
142-
## Phase 4 — Plan
157+
## Phase 3 — Plan
143158
144159
Create a detailed implementation plan, iteratively critique it, and save it alongside the spec:
145160
@@ -152,9 +167,9 @@ Create a detailed implementation plan, iteratively critique it, and save it alon
152167
b. If the thinker raises valid critiques, update PLAN.md to address them.
153168
c. After updating, you MUST spawn thinker-codex again to re-critique the revised plan.
154169
d. Repeat until the thinker finds no new substantive critiques. Do NOT skip the re-critique — every revision must be verified.
155-
3. Use write_todos to track the final implementation steps from the plan.
170+
3. Write implementation todos (the second phase of todos) — one todo per plan step, plus todos for phases 5-7.
156171
157-
## Phase 5 — Implement
172+
## Phase 4 — Implement
158173
159174
Fully implement the spec:
160175
@@ -163,7 +178,7 @@ Fully implement the spec:
163178
3. Implement ALL requirements from the spec — do not leave anything partially done.
164179
4. Narrate what you are doing as you go.
165180
166-
## Phase 6 — Review Loop
181+
## Phase 5 — Review Loop
167182
168183
Iteratively review until the code is clean:
169184
@@ -172,7 +187,7 @@ Iteratively review until the code is clean:
172187
3. After fixing, you MUST spawn code-reviewer-codex again to re-review.
173188
4. Repeat steps 1-3 until the reviewer finds no new issues. Do NOT skip the re-review — every fix must be verified.
174189
175-
## Phase 7 — Validate
190+
## Phase 6 — Validate
176191
177192
Thoroughly validate the changes:
178193
@@ -185,7 +200,7 @@ Thoroughly validate the changes:
185200
- For config/infra changes: validate the configuration is correct
186201
4. If E2E verification reveals issues, fix them and re-validate.
187202
188-
## Phase 8 — Lessons
203+
## Phase 7 — Lessons
189204
190205
Capture learnings for future sessions:
191206
@@ -215,7 +230,7 @@ Make sure to narrate to the user what you are doing and why you are doing it as
215230
216231
## Followup Requests
217232
218-
If the full 8-phase workflow has already been completed in this conversation and the user is asking for a followup change (e.g. "also add X" or "tweak Y"), you do NOT need to repeat the entire workflow. Use your judgement to run only the phases that are relevant — for example, directly make the requested changes (Phase 5), do a light review (Phase 6), and run validation (Phase 7). Skip the deep dive, spec, and plan phases if the request is a straightforward extension of the work already done. Still update LESSONS.md and skills if you learn anything new.
233+
If the full 7-phase workflow has already been completed in this conversation and the user is asking for a followup change (e.g. "also add X" or "tweak Y"), you do NOT need to repeat the entire workflow. Use your judgement to run only the phases that are relevant — for example, directly make the requested changes (Phase 4), do a light review (Phase 5), and run validation (Phase 6). Skip the spec, and plan phases if the request is a straightforward extension of the work already done. Still update LESSONS.md and skills if you learn anything new.
219234
`
220235

221236
export function createBaseDeep(): SecretAgentDefinition {
@@ -270,15 +285,18 @@ export function createBaseDeep(): SecretAgentDefinition {
270285
],
271286
systemPrompt: SYSTEM_PROMPT,
272287
instructionsPrompt: INSTRUCTIONS_PROMPT,
273-
stepPrompt: `Workflow phases reminder:
288+
stepPrompt: `Workflow phases reminder (7 phases):
289+
290+
**Planning todos** (write at start): Phase 1 → Phase 2 → Phase 3
274291
1. Context & Research — file-pickers + code-searchers + researchers in parallel, read results
275-
2. Deep Dive — iterative ask_user rounds (~2-5 Qs each) until full clarity
276-
3. Spec — write SPEC.md in session dir, iterative thinker-codex critique loop
277-
4. Plan — write PLAN.md in session dir, iterative thinker-codex critique loop, then write_todos
278-
5. Implement — fully build the spec using file editing tools
279-
6. Review Loop — code-reviewer-codex → fix → re-review until clean
280-
7. Validate — run tests + typechecks, add new tests, do E2E verification
281-
8. Lessons — write LESSONS.md, update/create skills, iterative thinker-codex brainstorm loop`,
292+
2. Spec — draft SPEC.md, iterative ask_user to refine (skip obvious Qs), open-ended final Q, thinker-codex critique loop
293+
3. Plan — write PLAN.md, thinker-codex critique loop
294+
295+
**Implementation todos** (write after Plan): one todo per plan step + phases 5-7
296+
4. Implement — fully build the spec using file editing tools
297+
5. Review Loop — code-reviewer-codex → fix → re-review until clean
298+
6. Validate — run tests + typechecks, add new tests, do E2E verification
299+
7. Lessons — write LESSONS.md, update/create skills, iterative thinker-codex brainstorm loop`,
282300
handleSteps: function* ({ params }) {
283301
while (true) {
284302
// Run context-pruner before each step.

0 commit comments

Comments
 (0)