Skip to content

Commit b3645ed

Browse files
authored
fix(kimaki): strip agent override minion examples (#78)
1 parent 6c8cc37 commit b3645ed

7 files changed

Lines changed: 88 additions & 110 deletions

File tree

bridges/kimaki/plugins/dm-context-filter.ts

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@
2929
// examples that survive section stripping. These let the agent discover
3030
// other Discord channels and route minion sessions away from the current
3131
// thread. See Extra-Chill/data-machine-code#49.
32+
// 12. Agent override inlines — `--agent <current_agent>` examples from the
33+
// generic Kimaki prompt. On DM-managed sites the Discord channel owns the
34+
// personal-agent binding; passing the runtime agent (for example `opencode`)
35+
// bypasses that binding and starts the wrong kind of minion session.
3236
//
3337
// What it injects into the system prompt:
3438
// - `## Minion Session Routing` — positive instruction telling the agent that
@@ -71,13 +75,16 @@ const fleetContextFilter: Plugin = async () => {
7175
result = stripSection(result, "## cross-project commands");
7276
result = stripSection(result, "## reading other sessions");
7377
result = stripSection(result, "## waiting for a session to finish");
78+
result = stripSection(result, "## running opencode commands via kimaki send");
79+
result = stripSection(result, "## switching agents in the current session");
7480
result = stripSection(result, "## showing diffs");
7581
result = stripSection(result, "## about critique");
7682
result = stripSection(result, "### always show diff at end of session");
7783
result = stripSection(result, "### fetching user comments from critique diffs");
7884
result = stripSection(result, "### reviewing diffs with AI");
7985
result = stripWorktreeInlines(result);
8086
result = stripProjectDiscoveryInlines(result);
87+
result = stripAgentOverrideInlines(result);
8188
// Clean up leftover double/triple blank lines.
8289
result = result.replace(/\n{3,}/g, "\n\n");
8390
// Append positive routing instruction so the agent never tries to
@@ -299,6 +306,38 @@ function stripProjectDiscoveryInlines(block: string): string {
299306
return result;
300307
}
301308

309+
/**
310+
* Remove generic Kimaki agent override examples from surviving sections.
311+
*
312+
* On Data Machine-managed sites the Discord channel selects the personal
313+
* agent. Passing `--agent <current_agent>` teaches the runtime agent to turn
314+
* the synthetic reminder value (often `opencode`) into a real session routing
315+
* override, bypassing the channel-bound Franklin agent.
316+
*/
317+
function stripAgentOverrideInlines(block: string): string {
318+
let result = block;
319+
320+
// Delete the generic instruction that recommends passing the current runtime
321+
// agent to spawned sessions.
322+
result = result.replace(
323+
/\n+Prefer passing the current agent with `--agent <current_agent>`[^\n]*\n/g,
324+
"\n"
325+
);
326+
327+
// Remove the generic "pick an agent" example from the surviving start-new-
328+
// sessions section; normal minions should rely on the channel binding.
329+
result = result.replace(
330+
/\n+Use --agent to specify which agent to use for the session:[\s\S]*?\nkimaki send --channel [^\n]* --agent [^\n]*\n/g,
331+
"\n"
332+
);
333+
334+
// Surviving `kimaki send` examples should rely on channel routing. This
335+
// keeps examples usable while removing the footgun.
336+
result = result.replace(/ --agent <current_agent>/g, "");
337+
338+
return result;
339+
}
340+
302341
/**
303342
* Append a positive minion-session routing instruction.
304343
*
@@ -317,6 +356,8 @@ function appendMinionRoutingInstruction(block: string): string {
317356
318357
All minion sessions for this agent go in THIS Discord channel — the one this session is running in. NEVER send sessions to other channels, even if you happen to know another channel ID. Do not run \`kimaki project list\`, \`kimaki project add\`, \`kimaki project create\`, or \`kimaki send --project\` — those are cross-project discovery commands that route sessions to other agents' channels.
319358
359+
Do not pass \`--agent\` when spawning normal minion sessions. The channel selects the personal agent. Passing the runtime agent (for example \`--agent opencode\`) bypasses the channel binding and starts the wrong kind of session.
360+
320361
If a minion needs to work in a different repo directory, use \`kimaki send --cwd /path/to/repo\` so the session stays in this channel but operates on a different checkout. For code changes in external repos, prefer Data Machine Code's workspace worktrees (\`studio wp datamachine-code workspace worktree add <repo> <branch>\`) — the worktree becomes the \`--cwd\` target for any follow-up minion session.
321362
`;
322363
// Ensure exactly one blank line between existing content and the appendix.

tests/effective-prompt/__snapshots__/default.baseline.txt

Lines changed: 8 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -49,56 +49,34 @@ This returns user IDs you can use for Discord mentions.
4949

5050
To start a new thread/session in this channel pro-grammatically, run:
5151

52-
kimaki send --channel 1493345787894038649 --prompt "your prompt here" --agent <current_agent> --user "chubes"
52+
kimaki send --channel 1493345787894038649 --prompt "your prompt here" --user "chubes"
5353

5454
You can use this to "spawn" parallel helper sessions like teammates: start new threads with focused prompts, then come back and collect the results.
55-
Prefer passing the current agent with `--agent <current_agent>` so spawned or scheduled sessions keep the same agent unless you are intentionally switching. Replace `<current_agent>` with the value from the per-turn `Current agent` reminder.
5655

5756
To send a prompt to an existing thread instead of creating a new one:
5857

59-
kimaki send --thread <thread_id> --prompt "follow-up prompt" --agent <current_agent>
58+
kimaki send --thread <thread_id> --prompt "follow-up prompt"
6059

6160
Use this when you already have the Discord thread ID.
6261

6362
To send to the thread associated with a known session:
6463

65-
kimaki send --session <session_id> --prompt "follow-up prompt" --agent <current_agent>
64+
kimaki send --session <session_id> --prompt "follow-up prompt"
6665

6766
Use this when you have the OpenCode session ID.
6867

6968
Use --notify-only to create a notification thread without starting an AI session:
7069

71-
kimaki send --channel 1493345787894038649 --prompt "User cancelled subscription" --notify-only --agent <current_agent> --user "chubes"
70+
kimaki send --channel 1493345787894038649 --prompt "User cancelled subscription" --notify-only --user "chubes"
7271

7372
Use --user to add a specific Discord user to the new thread:
7473

75-
kimaki send --channel 1493345787894038649 --prompt "Review the latest CI failure" --agent <current_agent> --user "chubes"
76-
77-
Use --agent to specify which agent to use for the session:
78-
79-
kimaki send --channel 1493345787894038649 --prompt "Plan the refactor of the auth module" --agent plan --user "chubes"
74+
kimaki send --channel 1493345787894038649 --prompt "Review the latest CI failure" --user "chubes"
8075

8176
Available agents:
8277
- `build`: default coding agent
8378
- `plan`: planning agent
8479

85-
## running opencode commands via kimaki send
86-
87-
You can trigger registered opencode commands (slash commands, skills, MCP prompts) by starting the `--prompt` with `/commandname`:
88-
89-
kimaki send --thread <thread_id> --prompt "/review fix the auth module" --agent <current_agent>
90-
kimaki send --channel 1493345787894038649 --prompt "/build-cmd update dependencies" --agent <current_agent> --user "chubes"
91-
92-
The command name must match a registered opencode command. If the command is not recognized, the prompt is sent as plain text to the model. This works for both new threads (`--channel`) and existing threads (`--thread`/`--session`).
93-
94-
## switching agents in the current session
95-
96-
The user can switch the active agent mid-session using the Discord slash command `/<agentname>-agent`. For example if you are in plan mode and the user asks you to edit files, tell them to run `/build-agent` to switch to the build agent first.
97-
98-
You can also switch agents via `kimaki send`:
99-
100-
kimaki send --thread <thread_id> --prompt "/<agentname>-agent" --agent <current_agent>
101-
10280
# List all registered projects with their channel IDs
10381
kimaki project list --json # machine-readable output
10482

@@ -125,7 +103,7 @@ Use cases:
125103
# Start a session and wait for it to finish
126104

127105
# Send to an existing thread and wait
128-
kimaki send --thread <thread_id> --prompt "Run the tests" --wait --agent <current_agent>
106+
kimaki send --thread <thread_id> --prompt "Run the tests" --wait
129107
```
130108

131109
The command exits with the session markdown on stdout once the model finishes responding.
@@ -351,4 +329,6 @@ intelligence-chubes4 personal agent
351329

352330
All minion sessions for this agent go in THIS Discord channel — the one this session is running in. NEVER send sessions to other channels, even if you happen to know another channel ID. Do not run `kimaki project list`, `kimaki project add`, `kimaki project create`, or `kimaki send --project` — those are cross-project discovery commands that route sessions to other agents' channels.
353331

332+
Do not pass `--agent` when spawning normal minion sessions. The channel selects the personal agent. Passing the runtime agent (for example `--agent opencode`) bypasses the channel binding and starts the wrong kind of session.
333+
354334
If a minion needs to work in a different repo directory, use `kimaki send --cwd /path/to/repo` so the session stays in this channel but operates on a different checkout. For code changes in external repos, prefer Data Machine Code's workspace worktrees (`studio wp datamachine-code workspace worktree add <repo> <branch>`) — the worktree becomes the `--cwd` target for any follow-up minion session.

tests/effective-prompt/__snapshots__/default.filtered.txt

Lines changed: 7 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -49,56 +49,34 @@ This returns user IDs you can use for Discord mentions.
4949

5050
To start a new thread/session in this channel pro-grammatically, run:
5151

52-
kimaki send --channel 1493345787894038649 --prompt "your prompt here" --agent <current_agent> --user "chubes"
52+
kimaki send --channel 1493345787894038649 --prompt "your prompt here" --user "chubes"
5353

5454
You can use this to "spawn" parallel helper sessions like teammates: start new threads with focused prompts, then come back and collect the results.
55-
Prefer passing the current agent with `--agent <current_agent>` so spawned or scheduled sessions keep the same agent unless you are intentionally switching. Replace `<current_agent>` with the value from the per-turn `Current agent` reminder.
5655

5756
To send a prompt to an existing thread instead of creating a new one:
5857

59-
kimaki send --thread <thread_id> --prompt "follow-up prompt" --agent <current_agent>
58+
kimaki send --thread <thread_id> --prompt "follow-up prompt"
6059

6160
Use this when you already have the Discord thread ID.
6261

6362
To send to the thread associated with a known session:
6463

65-
kimaki send --session <session_id> --prompt "follow-up prompt" --agent <current_agent>
64+
kimaki send --session <session_id> --prompt "follow-up prompt"
6665

6766
Use this when you have the OpenCode session ID.
6867

6968
Use --notify-only to create a notification thread without starting an AI session:
7069

71-
kimaki send --channel 1493345787894038649 --prompt "User cancelled subscription" --notify-only --agent <current_agent> --user "chubes"
70+
kimaki send --channel 1493345787894038649 --prompt "User cancelled subscription" --notify-only --user "chubes"
7271

7372
Use --user to add a specific Discord user to the new thread:
7473

75-
kimaki send --channel 1493345787894038649 --prompt "Review the latest CI failure" --agent <current_agent> --user "chubes"
76-
77-
Use --agent to specify which agent to use for the session:
78-
79-
kimaki send --channel 1493345787894038649 --prompt "Plan the refactor of the auth module" --agent plan --user "chubes"
74+
kimaki send --channel 1493345787894038649 --prompt "Review the latest CI failure" --user "chubes"
8075

8176
Available agents:
8277
- `build`: default coding agent
8378
- `plan`: planning agent
8479

85-
## running opencode commands via kimaki send
86-
87-
You can trigger registered opencode commands (slash commands, skills, MCP prompts) by starting the `--prompt` with `/commandname`:
88-
89-
kimaki send --thread <thread_id> --prompt "/review fix the auth module" --agent <current_agent>
90-
kimaki send --channel 1493345787894038649 --prompt "/build-cmd update dependencies" --agent <current_agent> --user "chubes"
91-
92-
The command name must match a registered opencode command. If the command is not recognized, the prompt is sent as plain text to the model. This works for both new threads (`--channel`) and existing threads (`--thread`/`--session`).
93-
94-
## switching agents in the current session
95-
96-
The user can switch the active agent mid-session using the Discord slash command `/<agentname>-agent`. For example if you are in plan mode and the user asks you to edit files, tell them to run `/build-agent` to switch to the build agent first.
97-
98-
You can also switch agents via `kimaki send`:
99-
100-
kimaki send --thread <thread_id> --prompt "/<agentname>-agent" --agent <current_agent>
101-
10280
## submodules
10381

10482
When pulling submodules and they jump to a new commit, commit that submodule pointer update right away before doing other work. Otherwise critique diffs later will include the noisy submodule jump along with the real changes.
@@ -243,4 +221,6 @@ intelligence-chubes4 personal agent
243221

244222
All minion sessions for this agent go in THIS Discord channel — the one this session is running in. NEVER send sessions to other channels, even if you happen to know another channel ID. Do not run `kimaki project list`, `kimaki project add`, `kimaki project create`, or `kimaki send --project` — those are cross-project discovery commands that route sessions to other agents' channels.
245223

224+
Do not pass `--agent` when spawning normal minion sessions. The channel selects the personal agent. Passing the runtime agent (for example `--agent opencode`) bypasses the channel binding and starts the wrong kind of session.
225+
246226
If a minion needs to work in a different repo directory, use `kimaki send --cwd /path/to/repo` so the session stays in this channel but operates on a different checkout. For code changes in external repos, prefer Data Machine Code's workspace worktrees (`studio wp datamachine-code workspace worktree add <repo> <branch>`) — the worktree becomes the `--cwd` target for any follow-up minion session.

tests/effective-prompt/__snapshots__/no-agents-no-thread.baseline.txt

Lines changed: 8 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -47,51 +47,29 @@ This returns user IDs you can use for Discord mentions.
4747

4848
To start a new thread/session in this channel pro-grammatically, run:
4949

50-
kimaki send --channel 1493345787894038649 --prompt "your prompt here" --agent <current_agent> --user "chubes"
50+
kimaki send --channel 1493345787894038649 --prompt "your prompt here" --user "chubes"
5151

5252
You can use this to "spawn" parallel helper sessions like teammates: start new threads with focused prompts, then come back and collect the results.
53-
Prefer passing the current agent with `--agent <current_agent>` so spawned or scheduled sessions keep the same agent unless you are intentionally switching. Replace `<current_agent>` with the value from the per-turn `Current agent` reminder.
5453

5554
To send a prompt to an existing thread instead of creating a new one:
5655

57-
kimaki send --thread <thread_id> --prompt "follow-up prompt" --agent <current_agent>
56+
kimaki send --thread <thread_id> --prompt "follow-up prompt"
5857

5958
Use this when you already have the Discord thread ID.
6059

6160
To send to the thread associated with a known session:
6261

63-
kimaki send --session <session_id> --prompt "follow-up prompt" --agent <current_agent>
62+
kimaki send --session <session_id> --prompt "follow-up prompt"
6463

6564
Use this when you have the OpenCode session ID.
6665

6766
Use --notify-only to create a notification thread without starting an AI session:
6867

69-
kimaki send --channel 1493345787894038649 --prompt "User cancelled subscription" --notify-only --agent <current_agent> --user "chubes"
68+
kimaki send --channel 1493345787894038649 --prompt "User cancelled subscription" --notify-only --user "chubes"
7069

7170
Use --user to add a specific Discord user to the new thread:
7271

73-
kimaki send --channel 1493345787894038649 --prompt "Review the latest CI failure" --agent <current_agent> --user "chubes"
74-
75-
Use --agent to specify which agent to use for the session:
76-
77-
kimaki send --channel 1493345787894038649 --prompt "Plan the refactor of the auth module" --agent plan --user "chubes"
78-
79-
## running opencode commands via kimaki send
80-
81-
You can trigger registered opencode commands (slash commands, skills, MCP prompts) by starting the `--prompt` with `/commandname`:
82-
83-
kimaki send --thread <thread_id> --prompt "/review fix the auth module" --agent <current_agent>
84-
kimaki send --channel 1493345787894038649 --prompt "/build-cmd update dependencies" --agent <current_agent> --user "chubes"
85-
86-
The command name must match a registered opencode command. If the command is not recognized, the prompt is sent as plain text to the model. This works for both new threads (`--channel`) and existing threads (`--thread`/`--session`).
87-
88-
## switching agents in the current session
89-
90-
The user can switch the active agent mid-session using the Discord slash command `/<agentname>-agent`. For example if you are in plan mode and the user asks you to edit files, tell them to run `/build-agent` to switch to the build agent first.
91-
92-
You can also switch agents via `kimaki send`:
93-
94-
kimaki send --thread <thread_id> --prompt "/<agentname>-agent" --agent <current_agent>
72+
kimaki send --channel 1493345787894038649 --prompt "Review the latest CI failure" --user "chubes"
9573

9674
# List all registered projects with their channel IDs
9775
kimaki project list --json # machine-readable output
@@ -119,7 +97,7 @@ Use cases:
11997
# Start a session and wait for it to finish
12098

12199
# Send to an existing thread and wait
122-
kimaki send --thread <thread_id> --prompt "Run the tests" --wait --agent <current_agent>
100+
kimaki send --thread <thread_id> --prompt "Run the tests" --wait
123101
```
124102

125103
The command exits with the session markdown on stdout once the model finishes responding.
@@ -341,4 +319,6 @@ Examples:
341319

342320
All minion sessions for this agent go in THIS Discord channel — the one this session is running in. NEVER send sessions to other channels, even if you happen to know another channel ID. Do not run `kimaki project list`, `kimaki project add`, `kimaki project create`, or `kimaki send --project` — those are cross-project discovery commands that route sessions to other agents' channels.
343321

322+
Do not pass `--agent` when spawning normal minion sessions. The channel selects the personal agent. Passing the runtime agent (for example `--agent opencode`) bypasses the channel binding and starts the wrong kind of session.
323+
344324
If a minion needs to work in a different repo directory, use `kimaki send --cwd /path/to/repo` so the session stays in this channel but operates on a different checkout. For code changes in external repos, prefer Data Machine Code's workspace worktrees (`studio wp datamachine-code workspace worktree add <repo> <branch>`) — the worktree becomes the `--cwd` target for any follow-up minion session.

0 commit comments

Comments
 (0)