Skip to content

Commit 5dca529

Browse files
committed
docs(examples): update supervised workflows
Document --supervised usage and update demo workflows/scripts to run review via OPENCODE and completion_check via CODEX_CLI, plus fix todo-loop and todo-check grep pattern.
1 parent b04391a commit 5dca529

6 files changed

Lines changed: 73 additions & 19 deletions

File tree

‎docs/guide/daemon.md‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -642,6 +642,7 @@ bun run src/daemon/cli.ts <daemon.yaml> [options]
642642
|-----------|------|
643643
| `--workspace`, `-w` | override `workspace` via CLI |
644644
| `--verbose`, `-v` | enable verbose logging |
645+
| `--supervised` | run workflows via Core IPC (Supervisor -> Core -> Worker) |
645646
| `--help`, `-h` | show help |
646647

647648
Notes:
@@ -661,10 +662,12 @@ bun run src/daemon/cli.ts my-daemon.yaml --verbose
661662
On `Ctrl+C` (SIGINT) or SIGTERM, Daemon performs a graceful shutdown:
662663

663664
1. stop receiving new events
664-
2. stop all event sources
665-
3. wait for running workflows to finish (30s timeout)
666-
4. stop webhook server
667-
5. flush state and exit
665+
2. abort running workflows (best-effort)
666+
3. stop all event sources
667+
4. wait for running workflows to finish (30s timeout)
668+
5. stop webhook server
669+
6. (supervised mode) shut down Core
670+
7. flush state and exit
668671

669672
---
670673

‎docs/guide/workflow.md‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -478,6 +478,7 @@ bun run src/workflow/run.ts <workflow.yaml>
478478
|-----------|--------|------|----------|
479479
| `--workspace <dir>` | `-w` | working directory | temp directory |
480480
| `--verbose` | `-v` | show step output | off |
481+
| `--supervised` | - | delegate steps via Core IPC (Supervisor -> Core -> Worker) | off |
481482
| `--help` | `-h` | show help | - |
482483

483484
### Examples
@@ -491,6 +492,9 @@ bun run src/workflow/run.ts examples/build-test-report.yaml --workspace /tmp/my-
491492
492493
# verbose output
493494
bun run src/workflow/run.ts examples/todo-loop.yaml --verbose
495+
496+
# supervised mode (Core spawns worker processes)
497+
bun run src/workflow/run.ts examples/agent-pr-loop.yaml --supervised --verbose
494498
```
495499

496500
### Reading results

‎examples/agent-pr-loop-demo/run-in-tmp.sh‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ fi
8888
RUNNER_ARGS=(
8989
"${AGENTCORE_ROOT}/src/workflow/run.ts"
9090
"${AGENTCORE_ROOT}/examples/agent-pr-loop.yaml"
91+
--supervised
9192
--workspace "${TARGET}"
9293
)
9394

‎examples/agent-pr-loop.yaml‎

Lines changed: 55 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
# AGENTCORE_ROOT=/path/to/agentcore
99
# TARGET=/path/to/your/repo
1010
# AGENTCORE_ROOT="$AGENTCORE_ROOT" bun run --cwd "$AGENTCORE_ROOT" ./src/workflow/run.ts \
11-
# "$AGENTCORE_ROOT/examples/agent-pr-loop.yaml" --workspace "$TARGET" --verbose
11+
# "$AGENTCORE_ROOT/examples/agent-pr-loop.yaml" --workspace "$TARGET" --supervised --verbose
1212

1313
name: agent-pr-loop
1414
version: "1"
@@ -140,21 +140,67 @@ steps:
140140

141141
review_fix_loop:
142142
description: "Review by OpenCode; if fixes needed, apply via Codex CLI; repeat until PASS"
143-
worker: CUSTOM
143+
worker: OPENCODE
144+
model: "openai/gpt-5.2"
144145
depends_on: [implement]
145146
instructions: |
146-
bun run "${AGENTCORE_ROOT:-.}/scripts/agent-pr-loop/review-fix-once.ts"
147-
capabilities: [READ, EDIT, RUN_TESTS, RUN_COMMANDS]
148-
timeout: "30m"
147+
You are OpenCode.
148+
149+
Task:
150+
- Review the work against the request.
151+
- Write/update:
152+
- .agentcore-loop/review.md
153+
- .agentcore-loop/review.verdict (PASS or FAIL only)
154+
- If verdict is FAIL, also write/update:
155+
- .agentcore-loop/fix.md (non-empty; concrete, actionable steps; include file paths)
156+
157+
Before reviewing, generate these review inputs (workspace is a git repo):
158+
- mkdir -p .agentcore-loop
159+
- BASE_BRANCH=$(cat .agentcore-loop/base-branch.txt 2>/dev/null || echo main)
160+
- git fetch origin "$BASE_BRANCH" >/dev/null 2>&1 || true
161+
- if git show-ref --verify --quiet "refs/remotes/origin/$BASE_BRANCH"; then BASE_REF="origin/$BASE_BRANCH"; elif git show-ref --verify --quiet "refs/heads/$BASE_BRANCH"; then BASE_REF="$BASE_BRANCH"; else BASE_REF="HEAD"; fi
162+
- git diff --no-color "$BASE_REF" > .agentcore-loop/review.diff || true
163+
- git status --porcelain=v1 > .agentcore-loop/review.status || true
164+
- git ls-files --others --exclude-standard > .agentcore-loop/review.untracked || true
165+
166+
You must read at least:
167+
- .agentcore-loop/request.md
168+
- .agentcore-loop/design.md (if present)
169+
- .agentcore-loop/todo.md (if present)
170+
- .agentcore-loop/review.diff
171+
- .agentcore-loop/review.status
172+
- .agentcore-loop/review.untracked
173+
174+
Format for .agentcore-loop/review.md:
175+
- Sections: Summary, Strengths, Issues, Verification
176+
capabilities: [READ, EDIT, RUN_COMMANDS]
177+
timeout: "15m"
149178
on_failure: retry
150179
max_retries: 2
151180

152181
completion_check:
153-
worker: CUSTOM
182+
worker: CODEX_CLI
183+
model: "gpt-5.3-codex"
154184
instructions: |
155-
bash "${AGENTCORE_ROOT:-.}/scripts/agent-pr-loop/verdict-check.sh"
156-
capabilities: [READ, RUN_COMMANDS]
157-
timeout: "30s"
185+
You are Codex CLI.
186+
187+
Read:
188+
- .agentcore-loop/review.verdict
189+
- .agentcore-loop/fix.md (if present)
190+
- .agentcore-loop/todo.md (if present)
191+
192+
Task:
193+
- If .agentcore-loop/review.verdict is PASS:
194+
- Print EXACTLY "COMPLETE" on its own line as the final line and exit successfully.
195+
- If verdict is FAIL:
196+
- Apply the fixes described in .agentcore-loop/fix.md (minimal changes).
197+
- Run tests (bun test if present; otherwise choose the most appropriate command).
198+
- Print EXACTLY "INCOMPLETE" on its own line as the final line and exit successfully.
199+
200+
Output rules:
201+
- Always ensure the last non-empty line is either COMPLETE or INCOMPLETE.
202+
capabilities: [READ, EDIT, RUN_TESTS, RUN_COMMANDS]
203+
timeout: "20m"
158204

159205
max_iterations: 5
160206
on_iterations_exhausted: abort

‎examples/todo-loop.yaml‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,13 @@ steps:
2929
depends_on: [setup]
3030
instructions: |
3131
# Find and process the first incomplete task
32-
TASK=$(grep -m1 '^\- \[ \]' todo.txt || true)
33-
if [ -z "$TASK" ]; then
32+
MATCH=$(grep -n -m1 '^\- \[ \]' todo.txt || true)
33+
if [ -z "$MATCH" ]; then
3434
echo "All tasks complete!"
3535
exit 0
3636
fi
37+
LINE_NO=${MATCH%%:*}
38+
TASK=${MATCH#*:}
3739
echo "Processing: $TASK"
3840
3941
# Perform work based on the task
@@ -53,9 +55,7 @@ steps:
5355
esac
5456
5557
# Mark the task as completed
56-
ESCAPED=$(echo "$TASK" | sed 's/[[\]/\\&]/\\&/g')
57-
DONE=$(echo "$TASK" | sed 's/\- \[ \]/- [x]/')
58-
sed -i "s|${TASK}|${DONE}|" todo.txt
58+
sed -i "${LINE_NO}s/^- \\[ \\] /- [x] /" todo.txt
5959
echo "Updated todo.txt:"
6060
cat todo.txt
6161
capabilities: [READ, EDIT, RUN_COMMANDS]

‎scripts/agent-pr-loop/todo-check.sh‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ set -euo pipefail
44
TODO=.agentcore-loop/todo.md
55
test -s "${TODO}" || { echo "CHECK: missing todo"; exit 1; }
66

7-
COUNT=$(grep -c '^\- \[ \] ' "${TODO}" || true)
7+
COUNT=$(grep -c '^- \[ \] ' "${TODO}" || true)
88
if [ "${COUNT}" -lt 6 ]; then
99
echo "CHECK: too few tasks: ${COUNT}"
1010
exit 1

0 commit comments

Comments
 (0)