diff --git a/doc/IDEAS.md b/doc/IDEAS.md index ec4412b..5378cd7 100644 --- a/doc/IDEAS.md +++ b/doc/IDEAS.md @@ -38,9 +38,9 @@ cd ~/mnt/ollie # Count existing sessions so we can identify the newly created ones by offset. n=$(ls s/ | wc -l) -echo "new agent=developer cwd=$cwd" > ctl -echo "new agent=reviewer cwd=$cwd" > ctl -echo "new agent=tester cwd=$cwd" > ctl +echo "agent=developer cwd=$cwd" > s/new +echo "agent=reviewer cwd=$cwd" > s/new +echo "agent=tester cwd=$cwd" > s/new dev=$(ls s/ | sort | sed -n "$((n+1))p") rev=$(ls s/ | sort | sed -n "$((n+2))p") @@ -89,7 +89,7 @@ Each agent only sees what the script explicitly sends it. Each can use a differe ### Sub-Agents -A session can spawn ephemeral child sessions to handle a focused task, then tear them down when done. The parent uses `execute_code` to write `new` to `ctl`, send an initial context and task to the child's `prompt`, poll until `reply` is ready, read the result, and write `kill ` to `ctl`. From the child's perspective it is just a normal session; it has no knowledge of its own ephemerality. +A session can spawn ephemeral child sessions to handle a focused task, then tear them down when done. The parent uses `execute_code` to write a key=value spec to `s/new`, send an initial context and task to the child's `prompt`, poll until `reply` is ready, read the result, and `rm -r s/{id}` to clean up. From the child's perspective it is just a normal session; it has no knowledge of its own ephemerality. **Sub-agents as function calls** — the parent primes the child with exactly the context it needs (excerpts from its own `chat`, relevant beads, local file contents) and receives a single focused reply. Failures are isolated; a child that errors or stalls can be killed and retried without affecting the parent. The pattern composes naturally: a sub-agent can itself spawn sub-agents, building a call tree bounded only by the number of sessions open at once. @@ -105,7 +105,7 @@ Output (stdout): JSON array of {"agent": str, "reply": str} Install in ~/.config/ollie/tools/ to make available as a {tool} step. """ -import json, os, sys, threading, time +import json, os, shutil, sys, threading, time from concurrent.futures import ThreadPoolExecutor, as_completed from pathlib import Path @@ -120,7 +120,7 @@ def session_ids(): def spawn_session(agent="default", cwd=""): with _spawn_lock: before = session_ids() - (BASE / "ctl").write_text(f"new agent={agent} cwd={cwd}\n") + (BASE / "s" / "new").write_text(f"agent={agent} cwd={cwd}\n") while True: new = session_ids() - before if new: @@ -128,7 +128,7 @@ def spawn_session(agent="default", cwd=""): time.sleep(0.1) def kill_session(sid): - (BASE / "ctl").write_text(f"kill {sid}\n") + shutil.rmtree(BASE / "s" / sid) def wait_reply(sid): path = BASE / "s" / sid / "reply" diff --git a/prompts/01_ollie.md b/prompts/01_ollie.md index 2ed7590..877ee8b 100644 --- a/prompts/01_ollie.md +++ b/prompts/01_ollie.md @@ -52,7 +52,7 @@ Use this to discover other sessions for cooperation. Sessions sharing your `cwd` **Session lifecycle:** - Create: write a key=value string to `{{.OllieMountPath}}/s/new` -- Kill: write `kill` to `{{.OllieMountPath}}/s/{id}/ctl` (do not use `rm -r`) +- Kill: `rm -r {{.OllieMountPath}}/s/{id}` - Rename: `mv {{.OllieMountPath}}/s/{id} {{.OllieMountPath}}/s/{newname}` — this also updates `$OLLIE_SESSION_ID` in the session environment **`ctl` commands** (write to `{{.OllieMountPath}}/s/{id}/ctl`):