From bf91cab41c83a7383d51baa71e9c3b6d9591afd3 Mon Sep 17 00:00:00 2001 From: Levi Neely <141506390+lneely@users.noreply.github.com> Date: Sun, 17 May 2026 13:54:38 +0200 Subject: [PATCH] subagent_generate: accept JSON as arg; remove all escaping from prompt examples --- prompts/tools-subagent.md | 15 ++++++++++++--- tools/subagent_generate | 6 +++++- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/prompts/tools-subagent.md b/prompts/tools-subagent.md index b6979e7..e3254a1 100644 --- a/prompts/tools-subagent.md +++ b/prompts/tools-subagent.md @@ -6,13 +6,22 @@ Spawn independent subagent sessions with JIT-generated identities via `echo JSON **Calling convention**: ``` -pipe: stages=[{code: "echo '{\"role\": \"ROLE\", \"shared_task\": \"TASK_DESC\"}'"}, {tool: "subagent_generate"}, {tool: "subagent_spawn", args: ["-name", "NAME", "TASK"]}] +pipe: stages=[ + {tool: "subagent_generate", args: [{"role": "ROLE", "shared_task": "TASK_DESC"}]}, + {tool: "subagent_spawn", args: ["-name", "NAME", "TASK"]} +] ``` Parallel — issue separate pipe calls for each subagent (subagent_spawn returns immediately, so sequential dispatch is fine): ``` -pipe: stages=[{code: "echo '{\"role\": \"ROLE_A\", \"roster\": \"a (you), b\", \"shared_task\": \"X\"}'"}, {tool: "subagent_generate"}, {tool: "subagent_spawn", args: ["-name", "a", "TASK_A"]}] -pipe: stages=[{code: "echo '{\"role\": \"ROLE_B\", \"roster\": \"a, b (you)\", \"shared_task\": \"X\"}'"}, {tool: "subagent_generate"}, {tool: "subagent_spawn", args: ["-name", "b", "TASK_B"]}] +pipe: stages=[ + {tool: "subagent_generate", args: [{"role": "ROLE_A", "roster": "a (you), b", "shared_task": "X"}]}, + {tool: "subagent_spawn", args: ["-name", "a", "TASK_A"]} +] +pipe: stages=[ + {tool: "subagent_generate", args: [{"role": "ROLE_B", "roster": "a, b (you)", "shared_task": "X"}]}, + {tool: "subagent_spawn", args: ["-name", "b", "TASK_B"]} +] ``` **Returns**: `subagent_generate` returns the agent config name. `subagent_spawn` returns the session path (e.g. `s/my-session`). diff --git a/tools/subagent_generate b/tools/subagent_generate index 1b15886..ec9a3e2 100755 --- a/tools/subagent_generate +++ b/tools/subagent_generate @@ -14,7 +14,11 @@ if [ -t 0 ] && [ $# -eq 0 ]; then exit 0 fi -cfg=$(cat) || die "failed to read stdin" +if [ $# -gt 0 ]; then + cfg="$1" +else + cfg=$(cat) || die "failed to read stdin" +fi [ -z "$cfg" ] && die "empty input" name=$(printf '%s' "$cfg" | python3 -c "