Skip to content

Commit 0fe4139

Browse files
NagyViktNagyVikt
andauthored
Keep Guardex prompts from encouraging fragmented probe loops (#346)
Guardex already preferred phase-based execution, but the copied task-loop prompt was still too sparse. This change makes the repo contract and gx prompt say low output is fine when bounded, and that long runs should collapse back to inspect once, patch once, verify once, then finish. Constraint: Prompt copy must stay short enough for gx prompt output Rejected: Only patch AGENTS.md | gx prompt would keep emitting weaker task-loop wording Confidence: high Scope-risk: narrow Directive: Keep task-loop copy phase-shaped; do not reintroduce vague micro-step prompt text Tested: node --test test/prompt.test.js; openspec validate --specs; git diff --check Not-tested: Full gx prompt output in a live protected-repo bootstrap Co-authored-by: NagyVikt <nagy.viktordp@gmail.com>
1 parent 28e388b commit 0fe4139

5 files changed

Lines changed: 37 additions & 1 deletion

File tree

AGENTS.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ When writing complex features or significant refactors, use an ExecPlan (as desc
2121
2. grouped edits or grouped repo actions
2222
3. focused verification
2323
4. compact summary
24+
- Low output alone is not a defect. A bounded run that finishes in roughly <=10 steps is usually fine; low output stretched across 20+ steps with rising input is fragmentation.
2425
- Treat obvious follow-on actions as part of the active phase; do not stop for tiny internal checkpoints.
2526
- If context grows or the session becomes fragmented, write a short working summary and continue from it.
2627

@@ -30,12 +31,14 @@ When writing complex features or significant refactors, use an ExecPlan (as desc
3031
- Prefer targeted reads: `rg`, `head`, `tail`, `git diff`, and exact line ranges.
3132
- Keep command output compact and relevant.
3233
- Avoid repeated status checks unless something changed.
34+
- Treat repeated `sed` / `cat` peeks, tiny diagnostic retries, and repeated `write_stdin` as red flags. When they appear, stop the probe loop and reset to one bounded phase.
3335

3436
### Command Discipline
3537

3638
- Batch related shell commands whenever safe.
3739
- Prefer one-shot non-interactive commands, scripts, or exact invocations over interactive loops or repeated stdin driving.
3840
- For diagnosis, gather the relevant evidence in one pass, then summarize once.
41+
- If the session turns fragmented, collapse back to inspect once, patch once, verify once, and summarize once.
3942

4043
### Git And PR Workflow
4144

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Proposal: tighten Guardex token-fragmentation prompts
2+
3+
Guardex already prefers phase-based execution, but the copied `gx prompt` task loop still underspecifies the anti-fragmentation pattern. This change makes the repo contract and prompt output teach the stronger classifier: low output alone is fine when the run is bounded, while long low-output sessions with repeated peeks or `write_stdin` loops are fragmentation.
4+
5+
- add the bounded-vs-fragmented classifier to `AGENTS.md`
6+
- teach `gx prompt` to say inspect once, patch once, verify once, then finish
7+
- lock the prompt wording with focused tests
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
## 1. Spec
2+
3+
- [x] 1.1 Capture why Guardex prompt surfaces should blame long fragmented runs, not low output alone.
4+
5+
## 2. Implementation
6+
7+
- [x] 2.1 Update `AGENTS.md` with the bounded-vs-fragmented classifier and stop-loop guidance.
8+
- [x] 2.2 Update `src/context.js` task-loop prompt text to push inspect-once / patch-once / verify-once execution.
9+
- [x] 2.3 Update `test/prompt.test.js` to lock the new prompt wording.
10+
11+
## 3. Verification
12+
13+
- [x] 3.1 Run `node --test test/prompt.test.js`.
14+
- [x] 3.2 Run `openspec validate --specs`.
15+
16+
Verification evidence:
17+
- `node --test test/prompt.test.js` (pass)
18+
- `openspec validate --specs` (no items found to validate)
19+
20+
## 4. Cleanup
21+
22+
- [ ] 4.1 Commit, push, open/update PR, merge, and clean up the worktree.

src/context.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,8 @@ const AI_SETUP_PARTS = [
425425
label: 'Task loop',
426426
promptLines: [
427427
'gx branch start "<task>" "<agent>"',
428-
'then gx locks claim --branch "<agent-branch>" <file...> -> gx branch finish',
428+
'then gx locks claim --branch "<agent-branch>" <file...> -> inspect once -> patch once -> verify once -> gx branch finish',
429+
'batch discovery, git/PR, and CI by phase; avoid repeated peeks or stdin loops',
429430
],
430431
execLines: [
431432
'gx branch start "<task>" "<agent>"',

test/prompt.test.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ test('prompt outputs AI setup instructions', () => {
7373
assert.match(result.stdout, /gx doctor/);
7474
assert.match(result.stdout, /gx branch start/);
7575
assert.match(result.stdout, /gx locks claim/);
76+
assert.match(result.stdout, /inspect once -> patch once -> verify once -> gx branch finish/);
77+
assert.match(result.stdout, /avoid repeated peeks or stdin loops/);
7678
assert.match(result.stdout, /gx finish --all/);
7779
assert.match(result.stdout, /\/opsx:propose/);
7880
assert.match(result.stdout, /https:\/\/github\.com\/apps\/pull/);
@@ -101,6 +103,7 @@ test('prompt --part outputs only the selected checklist slices', () => {
101103
assert.equal(result.status, 0, result.stderr || result.stdout);
102104
assert.match(result.stdout, /^Task loop:/m);
103105
assert.match(result.stdout, /gx branch start "<task>" "<agent>"/);
106+
assert.match(result.stdout, /inspect once -> patch once -> verify once -> gx branch finish/);
104107
assert.match(result.stdout, /^Finish:/m);
105108
assert.match(result.stdout, /gx finish --all/);
106109
assert.doesNotMatch(result.stdout, /GitGuardex \(gx\) setup checklist/);

0 commit comments

Comments
 (0)