Catch the reply that promises work and starts nothing
A reply keeps ending with "I'll connect and inspect the table, then
write both articles" or "Let me check the format, then convert if
needed", and nothing runs: the user waits for a report no run sends.
The review let both through, because it knew only the phrasing that
says work is already under way, with verbs the older lines did not
have and no "now" or "and see" to close them.
Read a promise one sentence at a time: "Let me <work verb>", "I'll
<work verb>" at the sentence's opening (with then/next/first in front,
and re- verbs), "Once I have it, I'll ..." and "I'm going to/about
to". A mid-sentence "and I'll run it" stays silent, since an offer
the user unlocks ("once you answer", "tell me", "say the word") is an
answer waiting exactly as it should.
chatReplyNote now ends by saying nothing happens after the message is
sent, and that work which needs no computer is done in the reply while
anything else starts a run.
This commit is contained in:
@@ -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 or a report will follow (`claimsWorkUnderWay`) 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. 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") (`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.
|
||||
|
||||
|
||||
@@ -86,7 +86,14 @@ You are chatting with the user. Answer their latest messages directly and briefl
|
||||
|
||||
Be proactive. Follow where the conversation is heading and, once you've answered, offer the next step with ask_user, not as a question in your text: one question whose options are the concrete next steps, the one you'd suggest first and marked as suggested, e.g. "Draft the reply as well (suggested)" and "Check the other two accounts the same way". Base them on what the user is trying to get done, not on generic options, and keep it to two to four. Skip it when you've already called ask_user in this reply, when you've just started a task (its result will offer what's next), or when the user is clearly wrapping up.
|
||||
|
||||
Your answer and that card go out together: ask_user and suggest_next_steps end the reply. Anything else you call after writing an answer carries on the run instead, and only the last message of it is sent, so an answer written before that never reaches the user.`;
|
||||
Your answer and that card go out together: ask_user and suggest_next_steps end the reply. Anything else you call after writing an answer carries on the run instead, and only the last message of it is sent, so an answer written before that never reaches the user.
|
||||
|
||||
## Nothing happens after you send
|
||||
|
||||
This message is the last thing the reply does: there is no next turn, and nothing runs once it goes out. So "I'll check", "let me check", "I'll connect and inspect", "next I'll" and "I'm going to" are promises the user waits on forever, and a promise with no run behind it is refused before it reaches them.
|
||||
|
||||
- If their latest message asks for work that needs no computer and takes a moment, do it in this reply and report what came back.
|
||||
- Otherwise call start_task now, then say in one sentence that it is running.`;
|
||||
|
||||
/**
|
||||
* Added to every run, chat replies and tasks alike: where its files live,
|
||||
|
||||
@@ -28,6 +28,21 @@ describe("claimsWorkUnderWay", () => {
|
||||
"I'm spinning up the build now.",
|
||||
"I'm starting it now.",
|
||||
"Starting it now.",
|
||||
/**
|
||||
* The shapes that got past the list above: "Let me check" and
|
||||
* "I'll connect and inspect" name work the reply never did,
|
||||
* without the "now" or the "and see" it looked for.
|
||||
*/
|
||||
"Let me check the account settings and see what's there.",
|
||||
"Let me take a look at the export.",
|
||||
"I'll take a look at the export.",
|
||||
"I will inspect the table.",
|
||||
"Then I'll check the logs.",
|
||||
"Next, I'll pull the list.",
|
||||
"And then I'll write both articles.",
|
||||
"I'm going to check the logs.",
|
||||
"I'm about to read the export.",
|
||||
"Once I have it, I'll update the workspace context with what I learn.",
|
||||
]) {
|
||||
expect(claimsWorkUnderWay({ text })).toBe(true);
|
||||
}
|
||||
@@ -53,4 +68,43 @@ describe("claimsWorkUnderWay", () => {
|
||||
expect(claimsWorkUnderWay({ text })).toBe(false);
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Two replies that went out with nothing running and the user left
|
||||
* waiting, both from the same conversation: the first promised to work
|
||||
* the articles, the second to check their format, and neither called a
|
||||
* tool. The lines they have to stay silent on come from the same
|
||||
* export: every one of those is an answer waiting on the user, which
|
||||
* faulting would send back as a lie.
|
||||
*/
|
||||
test("catches the replies that promised work and started nothing", () => {
|
||||
for (const text of [
|
||||
"Connection details received. I'll connect and inspect the `articles` table first, then check for existing slugs, then write both articles as drafts.",
|
||||
"You're right to flag that. Let me check what format the existing articles use in the database, then convert if needed.",
|
||||
"I'll re-run the PageSpeed scan now.",
|
||||
]) {
|
||||
expect(claimsWorkUnderWay({ text })).toBe(true);
|
||||
}
|
||||
|
||||
for (const text of [
|
||||
"I'll carry on when you ask me to.",
|
||||
"Tell me which site to audit and I'll run it and send back a single markdown report.",
|
||||
"If you upload the logo file as a [file:12] I'll set it as the workspace picture right away.",
|
||||
"Once you answer I'll run the write and verify it.",
|
||||
"Once the export is ready I'll check it.",
|
||||
"It's on my list; I'll start when you say.",
|
||||
"or name the piece you want changed and I'll take it from there.",
|
||||
"I'll wait for your answers before touching anything further.",
|
||||
"Let me know which export you mean and I'll check it.",
|
||||
"I'll note the preference in my memory of you.",
|
||||
"I'll check with you before I change anything.",
|
||||
"If it's still not done shortly, the honest move is Stop it and I'll run a leaner version.",
|
||||
"Point me at the spec, and I'll run the full build-and-write in one go.",
|
||||
"say yes and I'll run it.",
|
||||
"If you want the SQL inserts for the two rows, I'll generate them and you can run them.",
|
||||
"First the counts, then I'll pull the list.",
|
||||
]) {
|
||||
expect(claimsWorkUnderWay({ text })).toBe(false);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -39,11 +39,72 @@ const UnderWayPatterns = [
|
||||
/(?:^|[.!?\n]\s*)(?:starting|beginning|kicking off)\s+(?:it|that|the (?:run|job|task|work|scan|audit|build))\b/i,
|
||||
];
|
||||
|
||||
/**
|
||||
* The work a promise is about. Only words for work: "I'll keep that in
|
||||
* mind", "I'll use the navy palette" and "I'll take it from there" are an
|
||||
* answer talking about itself, not work that never starts.
|
||||
*/
|
||||
const WorkVerb =
|
||||
"(?:re-)?(?:check|look|see|verify|inspect|connect|query|convert|read|open|run|pull|grab|fetch|write|draft|update|fix|review|scan|search|dig|trace|test|build|deploy|export|import|compare|audit|generate|create)";
|
||||
|
||||
/**
|
||||
* A promise in one of its shapes, read a sentence at a time:
|
||||
* "Let me check what format the articles use, then convert if needed"
|
||||
* and "I'll connect and inspect the table first, then write both
|
||||
* articles" both went out with no run behind them, and `UnderWayPatterns`
|
||||
* passed them: `connect` was not one of its verbs, and neither sentence
|
||||
* had the "now" or the "and see" its first verb needed.
|
||||
*
|
||||
* Only the sentence's own opening counts, and only when the whole
|
||||
* sentence is the commitment. "Point me at the spec and I'll run it" and
|
||||
* "if it's still stuck, Stop it and I'll run a leaner version" are the
|
||||
* user's to unlock, and flagging them would take the offer away from the
|
||||
* answer that was waiting exactly as it should.
|
||||
*/
|
||||
const PromisePatterns = [
|
||||
new RegExp(`^\\s*let me (?:${WorkVerb}|take a (?:quick )?look|have a (?:quick )?look)\\b`, "i"),
|
||||
new RegExp(
|
||||
`^\\s*(?:and\\s+)?(?:then|next|after that|first)?,?\\s*I(?:(?:'|’)ll| will) (?:also |now |just )?(?:${WorkVerb}|take a (?:quick )?look|have a (?:quick )?look)\\b`,
|
||||
"i",
|
||||
),
|
||||
new RegExp(
|
||||
`^\\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"),
|
||||
];
|
||||
|
||||
/**
|
||||
* Sentences where a promise is the user's to unlock, so nothing is
|
||||
* missing: "once you answer I'll run it", "say the word and I'll check",
|
||||
* "I'll wait for your answers". Sent back as a lie, each of these was an
|
||||
* answer waiting on the user exactly as it should.
|
||||
*/
|
||||
const GatedPatterns = [
|
||||
/\b(?:if|when|once|whenever|after|as soon as|unless) you\b/i,
|
||||
/\bonce (?:it|that|this|they|the)\b/i,
|
||||
/\b(?:tell|show|give|send) me\b/i,
|
||||
/\blet me know\b/i,
|
||||
/\bsay the word\b/i,
|
||||
/\bgo-ahead\b/i,
|
||||
/\bwaiting for (?:you|your)\b/i,
|
||||
/\bask me\b/i,
|
||||
/\bwhichever you\b/i,
|
||||
/\bcheck with you\b/i,
|
||||
];
|
||||
|
||||
/**
|
||||
* True when the answer says work is under way beyond it or that a report
|
||||
* will follow (`UnderWayPatterns`). Only a started run makes that true,
|
||||
* so a reply that says it without one is sent back (`reviewBotReply`).
|
||||
* will follow (`UnderWayPatterns`), or promises work it is not doing
|
||||
* (`PromisePatterns`). Only a started run makes that true, so a reply that
|
||||
* says it without one is sent back (`reviewBotReply`).
|
||||
*/
|
||||
export default function claimsWorkUnderWay({ text }: Params) {
|
||||
return UnderWayPatterns.some((pattern) => pattern.test(text));
|
||||
if (UnderWayPatterns.some((pattern) => pattern.test(text))) return true;
|
||||
|
||||
return text.split(/(?<=[.!?])\s+|\n/).some((sentence) => {
|
||||
if (GatedPatterns.some((pattern) => pattern.test(sentence))) return false;
|
||||
|
||||
return PromisePatterns.some((pattern) => pattern.test(sentence));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -47,4 +47,23 @@ describe("repairAnswerText", () => {
|
||||
expect(repaired.changed).toBe(false);
|
||||
expect(repaired.text).toBe("The log has three timeouts at 09:12.");
|
||||
});
|
||||
|
||||
/**
|
||||
* The reply that told the user it would check the article format and
|
||||
* then went silent: the promise goes, the report stays.
|
||||
*/
|
||||
test("takes out the sentence that only promised to check", () => {
|
||||
const repaired = repairAnswerText({
|
||||
text: "Both drafts are saved. Let me check what format the existing articles use in the database, then convert if needed.",
|
||||
});
|
||||
|
||||
expect(repaired.changed).toBe(true);
|
||||
expect(repaired.text).toBe("Both drafts are saved.");
|
||||
});
|
||||
|
||||
test("keeps an answer that is waiting on the user", () => {
|
||||
const repaired = repairAnswerText({ text: "Once you answer I'll run the write and verify it." });
|
||||
|
||||
expect(repaired.changed).toBe(false);
|
||||
});
|
||||
});
|
||||
@@ -34,6 +34,18 @@ describe("replyClaimProblems", () => {
|
||||
expect(replyClaimProblems({ text: underWay, tool_uses: [{ name: "read_file", ok: true }] }).length).toBe(1);
|
||||
});
|
||||
|
||||
/**
|
||||
* The reply that told the user it would check the article format and
|
||||
* then went silent: no tool, no run, nothing open.
|
||||
*/
|
||||
test("faults a reply that only promised to check, and passes it once a run started", () => {
|
||||
const promised =
|
||||
"You're right to flag that. Let me check what format the existing articles use in the database, then convert if needed.";
|
||||
|
||||
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].",
|
||||
|
||||
Reference in New Issue
Block a user