Make routines act on their own and check every bot action

Scheduled runs are pre-approved: they carry out their brief instead of
drafting for confirmation. A run that can't do its brief calls
report_run_failed and is retried 5 and 10 minutes later; only then does
the user get one "failed after N tries" message, and the routine keeps
why in last_error.

Every reply and task now gets ActionCheckNote: look for an existing
record before creating one, and verify an action took effect before
saying it's done. Memory and instructions saves are read back, and
create_bot, create_schedule, start_task and delegate_task refuse
duplicates.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
2026-10-20 08:45:49 +01:00
co-authored by Claude Opus 5.5
parent 6c57fae444
commit 535adb6e16
25 changed files with 448 additions and 16 deletions
@@ -0,0 +1,34 @@
import { z } from "zod";
import type { HarnessTool } from "../../types";
type Params = {
/**
* Gets why the run failed. The task runner throws it after the run, so
* the queue retries the job.
*/
onFail: (params: { reason: string }) => void;
};
type Args = {
reason: string;
};
/**
* Lets a scheduled run say it couldn't do what its brief asks (a send
* that failed, a service that's down), so it's retried later instead of
* posting a report. Only given to scheduled runs.
*/
export default function reportRunFailedTool({ onFail }: Params): HarnessTool<Args> {
return {
name: "report_run_failed",
description: `Call this when this scheduled run couldn't do what its brief asks (a tool or service failed, something it needs is down). The run is tried again later, and the user is told only if every try fails. Say why in one or two sentences. Don't call it for something only the user can do; ask them to take over instead.`,
schema: z.object({
reason: z.string().trim().min(1).max(1000).describe("Why the run failed, for the user"),
}),
run: async ({ args }) => {
onFail({ reason: args.reason.trim() });
return `Recorded. Stop here: the run will be tried again later. Don't write a report.`;
},
};
}