Tell every bot its own id, in every run

The bot's id never reached its prompt: `composeBotPrompt` only took its
instructions, the appendix, its memory and its workspace, and
`grabBotPrompt` never passed `bot.id` or `bot.name` on. A bot could only
learn its id by accident, from a tool description that named it, so
"which bot am I" was unanswerable in most contexts.

- Open the prompt with who the bot is (`composeIdentity`): its name,
  whether it's the coordinator or a worker, its role, and its id, said
  to be how tools and refs point back at it. `grabBotPrompt` now passes
  the bot, which covers chat replies, tasks, routines and delegated
  tasks, since both runners build their prompt there.
- Turn the notes' example refs into functions bound to the running bot:
  `chatReplyNote`, `botFilesNote` and `coordinatorReplyNote` take its id,
  so the folder-ref example no longer points at a hardcoded `owner_id: 5`
  (another bot's folder) nor `[bot:3]`. ComputerFilesNote keeps the
  computer it's given.
- Stop `create_task` from hiding the worker's own id in its own chat.

Tests: four new `composeBotPrompt` cases pin the identity block (worker,
coordinator, unnamed, no bot at all), and a new `harness-prompts.test.ts`
checks each note's own-folder and self refs point at exactly the running
bot, for three ids.
This commit is contained in:
2026-10-23 17:40:28 +01:00
parent 0166f31cfc
commit 4261535741
8 changed files with 187 additions and 23 deletions
+6 -6
View File
@@ -2,10 +2,10 @@ import type { BUN_SQLITE_COBBLE_BOTS } from "@/db/types/db";
import { AppData } from "@/src/data/app-data";
import {
ActionCheckNote,
BotFilesNote,
ChatReplyNote,
botFilesNote,
chatReplyNote,
ComputerFilesNote,
CoordinatorReplyNote,
coordinatorReplyNote,
CoordinatorSoloNote,
TasksNote,
TaskReminderNote,
@@ -138,7 +138,7 @@ export default async function runBotReply({
bot.kind != "coordinator"
? ""
: tools.some((tool) => tool.name == "delegate_task")
? CoordinatorReplyNote
? coordinatorReplyNote({ bot_id: bot.id })
: CoordinatorSoloNote;
try {
@@ -146,8 +146,8 @@ export default async function runBotReply({
system: [
prompt,
carry_over,
ChatReplyNote,
BotFilesNote,
chatReplyNote({ bot_id: bot.id }),
botFilesNote({ bot_id: bot.id }),
ComputerFilesNote({ computer_id: computers[0]?.id || 0, can_import: false }),
TasksNote,
TaskReminderNote,
+2 -2
View File
@@ -1,7 +1,7 @@
import type { BUN_SQLITE_COBBLE_BOTS } from "@/db/types/db";
import {
ActionCheckNote,
BotFilesNote,
botFilesNote,
ComputerFilesNote,
ScheduledRunNote,
TasksNote,
@@ -191,7 +191,7 @@ export default async function runBotTask({
carry_over,
TaskRunNote,
scheduled ? ScheduledRunNote : "",
BotFilesNote,
botFilesNote({ bot_id: bot.id }),
ComputerFilesNote({ computer_id: job.computer_id || 0 }),
TasksNote,
ActionCheckNote,