Read the promise a bot makes as it starts the work

The reply review refused "Converting both articles ... I'll report back
with the conversion results" and the rewrite answered "You're right - I
didn't call start_task. Starting the conversion run now." with no tool
call at all. That rewrite passed, because the detector only read "I'll"
and "Let me" openers: the work named as starting, in the present tense
with a closer, matched nothing.

claimsWorkUnderWay now reads "Starting the conversion run now", "Kicking
off the build now", "I'm reading the digests, then I'll build one" and
"I am ..." as well as "I'm ...". The present-tense rule is anchored to
the sentence's opening, so a table cell quoting the user ("I am telling
you the same day") stays silent.

Over 1,732 bot messages in three production exports this flags 8 more,
every one a real claim with no run; the 3 that had called start_task stay
exempt.
This commit is contained in:
2026-11-18 15:22:13 +01:00
parent 1ae6be803c
commit eb35cce55f
4 changed files with 82 additions and 5 deletions
+1 -1
View File
@@ -128,7 +128,7 @@ Every run also gets `RequestScopeNote` (`src/data/harness-prompts.ts`): the user
- Handler `src/bots-queue/index.ts`: separate reply/task slots, heartbeat, a per-attempt deadline for replies (`AppData.BotJobAttemptTimeoutMs`; a task run has none, since its script may run for hours, and Stop ends it), one task per computer and one reply per session (`createKeyLock`). Work in `run-bot-job.ts` -> `run-bot-reply.ts` / `run-bot-task.ts`. Throw `BotJobFatalError` for failures retrying can't fix. A computer that's down (`isComputerDown`: failed, dead, exited) is one: `start_task` refuses it and a task run on it fails at once.
- Every model turn is a step in `bots_queue_updates` (tool names, never arguments; `describe-job-step.ts`, labels in `JobStepToolLabels`), pushed as `server:bot-job-update` by the live relay only. Steps feed the live working row alone: the `clear-job-steps` cron deletes them `AppData.BotJobStepsKeepMs` after the job ends, however it ended, keeping their count on `bots_queue.steps`. Never delete them the moment a job ends (the relay would miss the last ones).
- **A task run plans before it starts:** `planBotTask` (from `run-bot-task`) spends one turn, no tools, on the very system prompt the run then sends, so the provider's cache serves it and it costs little more than the plan. The answer is a bounded JSON plan (`BotTaskPlanSchema`, caps in `AppData.BotTaskPlan*`) that opens the run as `taskPlanNote` and shows as its first step line; `shouldPlanBotTask` keeps it off short runs (`AppData.BotTaskPlanMinSteps`). A plan that can't be written or read starts the run unplanned, never blocks it. **The wrap up is told what is on disk:** a task run passes `Params.wrap_up_note`, which runs `worktreeSummary` over the run's folders (`git status --porcelain` and `git diff --stat` per repository, nested ones included, at most 5) and puts the machine's own account in front of the wrap-up prompt, so the report is written from the tree and not from the run's memory of writing it. **The files the brief names are checked once, before the run starts** (`namedFilesNote`, over `namedFiles`): a path that isn't on the computer but is still in the bot's files is handed over as its `[file:ID]` with `export_file`, and one with no copy anywhere says plainly not to go looking through the machine or the user's accounts. It is the app's answer, not the run's guess: a source a rebuild took off the computer once cost a run thirty turns probing the container and then the user's own accounts for a copy the app was holding the whole time.
- **A bot can't vouch for itself:** a run's tool calls (`tool_uses`, names and ok, never arguments) go to the wrap-up turn when steps run out and onto the result message as `bot_messages.tool_log`; history follows each recorded bot message with an `[App record: ...]` line (`botMessagesToHarness`), and copies of that line in an answer are stripped (`stripAppRecords`, which shares the line shape with `appRecordLines`). Before a reply goes out, `reviewBotReply` (the loop's `review`) sends it back when it names a `[file:ID]`/`[task:ID]`/`[graphic:ID]` that doesn't exist for the user, a `[setting:...]` ref the app can't resolve (`unresolvedSettingRefs`), a `[suggestion:ID]`/`[question:ID]`/`[plan:ID]` ref it wrote itself (`AppCardRefTools`: the app adds those from the tool that made the card, so a written one is made up or copied from an earlier message and the user reads "not available"), or says work is under way, that a report will follow, or that it is about to do the work ("Let me check", "I'll connect and inspect", "next I'll") (`claimsWorkUnderWay`, which reads a promise only when its own sentence is the commitment, so an offer waiting on the user is left alone) with no `start_task`/`delegate_task`/`ask_bot` this reply and nothing open from the session: bots wrote "I'm scanning now" plus made-up results in one answer, and a reply promising to check the articles and then starting nothing left the user waiting for a report nobody would send. Review runs on every answer it writes, up to `AppData.HarnessReviewRewrites` rewrites (a repeat of the faulted message is told so, `repeatedAnswerNote`); past that the answer is never sent and the reply job fails instead (`review_note` -> `BotJobFatalError`), since a model that kept writing the same thing sends the claim anyway. **A fault must be something the bot can stop making:** only a whole line in the app's own record shape naming tools this reply didn't call is a forgery (`unsupportedAppRecordLines`) - the same text quoted inside a sentence is the bot naming its mistake, and job #468 faulted three rewrites in a row for that quote alone, so the lie stayed and the correction never reached the user. No fault note may itself contain the shape it faults or a `claimsWorkUnderWay` phrase. Tool names copied into a list (`WorkStartingTools`, `AppCardRefToolNames`, `WritingToolNames`, `WrapUp*ToolNames`) are pinned to the tools the harness declares by `src/harness/tools/tool-name-lists.test.ts` (`ask_crew` outlived its rename to `ask_bot`, so a reply that really had asked the crew was faulted for saying so). A long bot message whose run called no tools shows "No tools used" (`MessageNoToolsChip`).
- **A bot can't vouch for itself:** a run's tool calls (`tool_uses`, names and ok, never arguments) go to the wrap-up turn when steps run out and onto the result message as `bot_messages.tool_log`; history follows each recorded bot message with an `[App record: ...]` line (`botMessagesToHarness`), and copies of that line in an answer are stripped (`stripAppRecords`, which shares the line shape with `appRecordLines`). Before a reply goes out, `reviewBotReply` (the loop's `review`) sends it back when it names a `[file:ID]`/`[task:ID]`/`[graphic:ID]` that doesn't exist for the user, a `[setting:...]` ref the app can't resolve (`unresolvedSettingRefs`), a `[suggestion:ID]`/`[question:ID]`/`[plan:ID]` ref it wrote itself (`AppCardRefTools`: the app adds those from the tool that made the card, so a written one is made up or copied from an earlier message and the user reads "not available"), or says work is under way, that a report will follow, or that it is about to do the work ("Let me check", "I'll connect and inspect", "next I'll", "Starting the conversion run now") (`claimsWorkUnderWay`, which reads a promise only when its own sentence is the commitment, so an offer waiting on the user is left alone) with no `start_task`/`delegate_task`/`ask_bot` this reply and nothing open from the session: bots wrote "I'm scanning now" plus made-up results in one answer, and a reply promising to check the articles and then starting nothing left the user waiting for a report nobody would send. Review runs on every answer it writes, up to `AppData.HarnessReviewRewrites` rewrites (a repeat of the faulted message is told so, `repeatedAnswerNote`); past that the answer is never sent and the reply job fails instead (`review_note` -> `BotJobFatalError`), since a model that kept writing the same thing sends the claim anyway. **A fault must be something the bot can stop making:** only a whole line in the app's own record shape naming tools this reply didn't call is a forgery (`unsupportedAppRecordLines`) - the same text quoted inside a sentence is the bot naming its mistake, and job #468 faulted three rewrites in a row for that quote alone, so the lie stayed and the correction never reached the user. No fault note may itself contain the shape it faults or a `claimsWorkUnderWay` phrase. Tool names copied into a list (`WorkStartingTools`, `AppCardRefToolNames`, `WritingToolNames`, `WrapUp*ToolNames`) are pinned to the tools the harness declares by `src/harness/tools/tool-name-lists.test.ts` (`ask_crew` outlived its rename to `ask_bot`, so a reply that really had asked the crew was faulted for saying so). A long bot message whose run called no tools shows "No tools used" (`MessageNoToolsChip`).
- **`start_task`/`delegate_task` jobs are runs, not tasks:** their results say `Run #<job id>` and that `list_tasks` doesn't show them (bots sent users to the tracker for them). `start_task` refuses a second open run in its session on the same computer unless `separate` (it would only wait behind it) and says how many runs are ahead on that computer. Its `max_steps` (`params.max_steps`) caps the run below the install's limit; the brief alone never did. Nothing wakes a bot when a run ends, so different follow-up work is queued at once with `separate`, never promised for later (`start_task`, `chatReplyNote`).
- **Replies take in messages sent mid-run** (`incoming`, `IncomingMessagesNote`, redraft); separate requests are acknowledged with `send_message` (interim). A queued reply finishes silently only when a finished reply already read every user message (`hasUnansweredMessage`), never by who wrote last; a retry (`params.retry_of`) always runs. **Task runs take them in too** (`taskIncoming`, only runs the user follows: no routines, hook calls or rooms): everything the user wrote since the run was queued, at the start, between steps, past a report not yet out and by the wrap up (`incoming_notes`, `TaskIncomingNote`); a correction changes the work, anything else is left to the chat, and crew messages to the reply they wake. A reply is told which runs open in its session hear the user (`openRunsNote`), so a correction never starts a second run.
+31
View File
@@ -107,4 +107,35 @@ describe("claimsWorkUnderWay", () => {
expect(claimsWorkUnderWay({ text })).toBe(false);
}
});
/**
* The same promise one step later, from the two runs that went out
* with nothing started: sent back for promising a run, the bot
* apologised and named the run as starting anyway ("Starting the
* conversion run now."), and a task it meant to start came out as
* text around a written-out call ("I am starting a task to do that.").
* Wrote "I am" where every pattern read "I'm", or named the moment
* instead of the promise.
*/
test("catches work named as starting now", () => {
for (const text of [
"You're right - I didn't call `start_task`. Starting the conversion run now.",
"You asked me to search for Canva templates. I am starting a task to do that.",
"I'm reading the four existing digests to extract the exact format, then I'll build one sample for your approval.",
"Kicking off the build now.",
"Starting the audit right away.",
]) {
expect(claimsWorkUnderWay({ text })).toBe(true);
}
for (const text of [
"Starting a task on a busy computer waits behind the open run.",
"Starting the container takes about ten seconds.",
"I'm reading that as `bots/1/site`, so say so if you meant something else.",
"I am sorry, that contest isn't open any more.",
"The run starts in a moment, once you say go.",
]) {
expect(claimsWorkUnderWay({ text })).toBe(false);
}
});
});
+38 -4
View File
@@ -2,6 +2,13 @@ type Params = {
text: string;
};
/**
* "I'm" and "I am": a weaker model writes the long form, and "I am
* starting a task to do that." went out with no run behind it while every
* pattern here read the contraction alone.
*/
const IAm = "(?:i(?:'|’)?m|i am)";
/**
* How an answer says work is going on after it, or that a report will
* follow: the line a reply writes once it started a run ("I'm browsing
@@ -33,9 +40,12 @@ const UnderWayPatterns = [
* promised report the patterns above need. Only `start_task` starts
* one, so the app's record decides whether it's true.
*/
/\bI(?:'|’)?m\s+(?:now\s+|just\s+)?(?:starting|beginning|kicking off|launching|queueing|queuing|firing off|spinning up)\b[^.!?\n]{0,120}\b(?:run|task|job|work|scan|audit|recon|build|pass)\b/i,
/\bI(?:'|’)ve\s+(?:now\s+|just\s+)?(?:started|begun|kicked off|launched|queued|fired off|spun up)\b/i,
/\bI(?:'|’)?m\s+(?:now\s+|just\s+)?(?:starting|beginning|kicking off)\s+(?:it|this|that)\b/i,
new RegExp(
`\\b${IAm}\\s+(?:now\\s+|just\\s+)?(?:starting|beginning|kicking off|launching|queueing|queuing|firing off|spinning up)\\b[^.!?\\n]{0,120}\\b(?:run|task|job|work|scan|audit|recon|build|pass)\\b`,
"i",
),
new RegExp(`\\bI(?:'|’)ve\\s+(?:now\\s+|just\\s+)?(?:started|begun|kicked off|launched|queued|fired off|spun up)\\b`, "i"),
new RegExp(`\\b${IAm}\\s+(?:now\\s+|just\\s+)?(?:starting|beginning|kicking off)\\s+(?:it|this|that)\\b`, "i"),
/(?:^|[.!?\n]\s*)(?:starting|beginning|kicking off)\s+(?:it|that|the (?:run|job|task|work|scan|audit|build))\b/i,
];
@@ -71,7 +81,31 @@ const PromisePatterns = [
`^\\s*(?:once|when|after|as soon as)\\b[^,.]{0,80},\\s*(?:then\\s+)?I(?:(?:'|’)ll| will) (?:also |now |just )?${WorkVerb}\\b`,
"i",
),
new RegExp(`\\bI(?:'|’)?m (?:going|about) to ${WorkVerb}\\b`, "i"),
new RegExp(`\\b${IAm} (?:going|about) to ${WorkVerb}\\b`, "i"),
/**
* "I am checking the inbox now." The wide "I'm ... ing ... now" above
* reads the whole reply, so adding "I am" there faulted a table cell
* quoting a line ("I am telling you the same day", with "is now a
* follow-up" further along). Read a sentence at a time, only its own
* opening counts.
*/
new RegExp(`^\\s*${IAm}\\s+(?:now\\s+)?[a-z]+ing\\b[^.!?\\n]{0,160}\\bnow\\b`, "i"),
/**
* Work named as happening this moment rather than promised: "Starting
* the conversion run now.", written after the app sent the reply back
* for promising it, and "I'm reading the four digests, then I'll
* build one sample". The sentence has to say it is happening, with a
* closer, so "Starting a task on a busy computer waits behind the open
* run" explains the app instead of claiming a run.
*/
new RegExp(
`^\\s*(?:starting|beginning|kicking off|launching)\\s+(?:(?:the|a|an|this|that|my|both)\\s+)?(?:[\\w-]+\\s+){0,3}(?:run|job|task|work|scan|audit|build|conversion|review|pass)\\b[^.!?\\n]{0,40}\\b(?:now|right away|immediately|for you|as we speak)\\b`,
"i",
),
new RegExp(
`^\\s*${IAm}\\s+(?:now\\s+|just\\s+)?${WorkVerb}ing\\b[^.!?\\n]{0,200}\\b(?:then\\s+)?(?:i(?:'|’)ll|i will)\\b`,
"i",
),
];
/**
+12
View File
@@ -46,6 +46,18 @@ describe("replyClaimProblems", () => {
expect(replyClaimProblems({ text: promised, tool_uses: [{ name: "start_task", ok: true }] })).toEqual([]);
});
/**
* The rewrite the review bought: told its promise started nothing, the
* bot apologised and named the run as starting anyway, and called no
* tool. Nothing was running, and the user was left waiting again.
*/
test("faults a reply that apologised and named the run as starting anyway", () => {
const promised = "You're right - I didn't call `start_task`. Starting the conversion run now.";
expect(replyClaimProblems({ text: promised, tool_uses: [] }).length).toBe(1);
expect(replyClaimProblems({ text: promised, tool_uses: [{ name: "start_task", ok: true }] })).toEqual([]);
});
test("names files and tasks that don't exist", () => {
const problems = replyClaimProblems({
text: "Saved in [file:301]; see [task:20].",