feat(ce-ideate): mode-aware v2 ideation (#588)
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -91,9 +91,16 @@ Delegate all units in one batch. If the plan exceeds 5 units, split into batches
|
||||
|
||||
## Prompt Template
|
||||
|
||||
At the start of delegated execution, generate a short unique run ID (e.g., 8 hex chars from a timestamp or random source). All scratch files for this invocation go under `.context/compound-engineering/codex-delegation/<run-id>/`. Create the directory if it does not exist.
|
||||
At the start of delegated execution, create a per-run OS-temp scratch directory via `mktemp -d` and capture its **absolute path** for all downstream use. All scratch files for this invocation live under that directory. Do not use `.context/` — these scratch files are per-run throwaway that get cleaned up when delegated execution ends (see Cleanup below), matching the repo Scratch Space convention for one-shot artifacts. Do not pass unresolved shell-variable strings to non-shell tools (Write, Read); use the absolute path returned by `mktemp -d`.
|
||||
|
||||
Before each batch, write a prompt file to `.context/compound-engineering/codex-delegation/<run-id>/prompt-batch-<batch-num>.md`.
|
||||
```bash
|
||||
SCRATCH_DIR="$(mktemp -d -t ce-work-codex-XXXXXX)"
|
||||
echo "$SCRATCH_DIR"
|
||||
```
|
||||
|
||||
Refer to the echoed absolute path as `<scratch-dir>` throughout the rest of this workflow.
|
||||
|
||||
Before each batch, write a prompt file to `<scratch-dir>/prompt-batch-<batch-num>.md`.
|
||||
|
||||
Build the prompt from the batch's implementation units using these XML-tagged sections:
|
||||
|
||||
@@ -169,7 +176,7 @@ Report your result via the --output-schema mechanism. Fill in every field:
|
||||
|
||||
## Result Schema
|
||||
|
||||
Write the result schema to `.context/compound-engineering/codex-delegation/<run-id>/result-schema.json` once at the start of delegated execution:
|
||||
Write the result schema to `<scratch-dir>/result-schema.json` (using the absolute path captured at the start) once at the start of delegated execution:
|
||||
|
||||
```json
|
||||
{
|
||||
@@ -186,7 +193,7 @@ Write the result schema to `.context/compound-engineering/codex-delegation/<run-
|
||||
}
|
||||
```
|
||||
|
||||
Each batch's result is written to `.context/compound-engineering/codex-delegation/<run-id>/result-batch-<batch-num>.json` via the `-o` flag. On plan failure, files are left in place for debugging.
|
||||
Each batch's result is written to `<scratch-dir>/result-batch-<batch-num>.json` via the `-o` flag. On plan failure, files are left in place for debugging.
|
||||
|
||||
If the result JSON is absent or malformed after a successful exit code, classify as task failure.
|
||||
|
||||
@@ -210,6 +217,8 @@ If tracked files are dirty, stop and present options: (1) commit current changes
|
||||
|
||||
Write the prompt file, then make a single Bash tool call with `run_in_background: true` set on the tool parameter. This call returns immediately and has no timeout ceiling.
|
||||
|
||||
Substitute the literal absolute path captured at setup for every `<scratch-dir>` below. Each Bash tool call starts a fresh shell, so the `$SCRATCH_DIR` variable from the setup snippet is not preserved — an unresolved `$SCRATCH_DIR` would expand empty and break result detection.
|
||||
|
||||
```bash
|
||||
# Substitute the resolved sandbox_mode value (yolo or full-auto) from the skill state
|
||||
SANDBOX_MODE="<sandbox_mode>"
|
||||
@@ -225,9 +234,9 @@ codex exec \
|
||||
-m "<delegate_model>" \
|
||||
-c 'model_reasoning_effort="<delegate_effort>"' \
|
||||
$SANDBOX_FLAG \
|
||||
--output-schema .context/compound-engineering/codex-delegation/<run-id>/result-schema.json \
|
||||
-o .context/compound-engineering/codex-delegation/<run-id>/result-batch-<batch-num>.json \
|
||||
- < .context/compound-engineering/codex-delegation/<run-id>/prompt-batch-<batch-num>.md
|
||||
--output-schema "<scratch-dir>/result-schema.json" \
|
||||
-o "<scratch-dir>/result-batch-<batch-num>.json" \
|
||||
- < "<scratch-dir>/prompt-batch-<batch-num>.md"
|
||||
```
|
||||
|
||||
Critical: `run_in_background: true` must be set as a **Bash tool parameter**, not as a shell `&` suffix. The tool parameter is what removes the timeout ceiling. A shell `&` inside a foreground Bash call still hits the 2-minute default timeout.
|
||||
@@ -240,8 +249,10 @@ Do not improvise CLI flags or modify this invocation template.
|
||||
|
||||
After the launch call returns, make a **new, separate** foreground Bash tool call that polls for the result file. This keeps the agent's turn active so the user cannot interfere with the working tree.
|
||||
|
||||
Substitute the literal absolute path captured at setup for `<scratch-dir>`. The shell variable from Step A does not survive across separate Bash tool calls.
|
||||
|
||||
```bash
|
||||
RESULT_FILE=".context/compound-engineering/codex-delegation/<run-id>/result-batch-<batch-num>.json"
|
||||
RESULT_FILE="<scratch-dir>/result-batch-<batch-num>.json"
|
||||
for i in $(seq 1 6); do
|
||||
test -s "$RESULT_FILE" && echo "DONE" && exit 0
|
||||
sleep 10
|
||||
@@ -301,11 +312,7 @@ git commit -m "feat(<scope>): <batch summary>"
|
||||
|
||||
**Circuit breaker:** After 3 consecutive failures, set `delegation_active` to false and emit: "Codex delegation disabled after 3 consecutive failures -- completing remaining units in standard mode."
|
||||
|
||||
**Scratch cleanup:** After the last batch completes:
|
||||
|
||||
```bash
|
||||
rm -rf .context/compound-engineering/codex-delegation/<run-id>/
|
||||
```
|
||||
**Scratch cleanup:** No explicit cleanup needed — OS temp handles eventual cleanup (macOS `$TMPDIR` periodic purge; Linux/WSL `/tmp` reboot or periodic cleanup). Leaving `<scratch-dir>` in place after the run also preserves intermediate artifacts for debugging if anything went wrong.
|
||||
|
||||
## Mixed-Model Attribution
|
||||
|
||||
|
||||
Reference in New Issue
Block a user