Skip to content

Open-source Grok Bot alternative with a virtual machine that bots can use

fix(triggers): a trigger id that is not this bot's is an answer, not a failed call

David Neyra7db8316abe15
diff --git a/server/drivers/agents-call-triggers.test.ts b/server/drivers/agents-call-triggers.test.ts
index afc18d4b20..6bea2672a1 100644
--- a/server/drivers/agents-call-triggers.test.ts
+++ b/server/drivers/agents-call-triggers.test.ts
@@ -116,6 +116,17 @@ describe("the trigger tool's actions", () => {
await callTool("trigger_info", { action: "events", app: "Gmail" }, events.context);
expect(events.calls[0]!.path).toBe("/api/internal/trigger-events?fromBotId=scout&fromThreadId=thread-1&app=gmail");
});
+
+ it("answers a trigger id that is not this bot's, and keeps a real failure a failure", async () => {
+ const missing = context({ api: { now: "2026-10-29T09:00:00Z", timeZone: "UTC",
+ error: "No trigger with that id belongs to this bot. Call trigger_info without trigger_id to see its ids.", missing: true } });
+ const answer = await callTool("trigger_info", { action: "list", trigger_id: "old-1" }, missing.context);
+ expect(answer.isError).toBeUndefined();
+ expect(answer.text).toContain("No trigger with that id belongs to this bot");
+ const refused = context({ api: { now: "2026-10-29T09:00:00Z", timeZone: "UTC",
+ error: "that bot's automations are set up by bots in its own department or by its Chief, or it is unavailable." } });
+ expect((await callTool("trigger_info", { action: "list", for_bot_id: "helper" }, refused.context)).isError).toBe(true);
+ });
});
describe("delete_trigger", () => {
diff --git a/server/drivers/agents-call-triggers.ts b/server/drivers/agents-call-triggers.ts
index e75f8ddd6b..301127bbeb 100644
--- a/server/drivers/agents-call-triggers.ts
+++ b/server/drivers/agents-call-triggers.ts
@@ -421,7 +421,11 @@ async function listTriggers(args: Json, forBotId: string | undefined, context: T
const now = typeof r.now === "string" ? r.now : new Date().toISOString();
const timeZone = typeof r.timeZone === "string" && r.timeZone ? r.timeZone : "local computer timezone";
const clock = `current time: ${now}; timezone: ${timeZone}`;
- if (typeof r.error === "string") return { text: `${r.error} (${clock})`, isError: true };
+ if (typeof r.error === "string") {
+ // A trigger id that is not this bot's is an answer the bot can pass on; a failed call ends the turn.
+ if (r.missing === true) return { text: `${r.error} (${clock})` };
+ return { text: `${r.error} (${clock})`, isError: true };
+ }
if (r.trigger) return { text: `Trigger (${clock}):\n${JSON.stringify(r.trigger, null, 2)}` };
const triggers = Array.isArray(r.triggers) ? r.triggers : [];
if (!triggers.length) return { text: `This bot has no triggers. Current time: ${now}. Timezone: ${timeZone}.` };
diff --git a/server/host/team-routines.ts b/server/host/team-routines.ts
index 12cdf248b3..c446274493 100644
--- a/server/host/team-routines.ts
+++ b/server/host/team-routines.ts
@@ -13,9 +13,10 @@ import type { RequestAuth } from "../request-auth.ts";
import { routineHome, type RoutineHomeDeps, type RoutinePlace } from "../routine-home.ts";
import type { Routine, RoutineManager } from "../routines.ts";
import type { TaskRecord } from "../store.ts";
+import { NO_SUCH_TRIGGER } from "../trigger-tools.ts";
import type { TeamMemberLeftDeps } from "./team-member-left.ts";
-export const NO_SUCH_TRIGGER = "No trigger with that id belongs to this bot. Call trigger_info without trigger_id to see its ids.";
+export { NO_SUCH_TRIGGER };
export interface TeamRoutinesDeps extends RoutineHomeDeps {
team: boolean;
diff --git a/server/trigger-tools.ts b/server/trigger-tools.ts
index b4812b1b64..ecf80576fa 100644
--- a/server/trigger-tools.ts
+++ b/server/trigger-tools.ts
@@ -9,6 +9,8 @@ import { redactSecretsInText } from "./redact.ts";
import type { Routine, RoutineRun } from "./routines.ts";
import type { WebhookTrigger } from "./webhooks.ts";
+export const NO_SUCH_TRIGGER = "No trigger with that id belongs to this bot. Call trigger_info without trigger_id to see its ids.";
+
const WEEKDAY_NAMES = ["sunday", "monday", "tuesday", "wednesday", "thursday", "friday", "saturday"] as const;
const INSTRUCTIONS_SHOWN = 2_000;
const FIRES_SHOWN = 10;
@@ -134,6 +136,8 @@ export interface TriggerListing {
triggers?: AgentTrigger[];
trigger?: AgentTrigger & { recentFires: Array<ReturnType<typeof agentRun>> };
error?: string;
+ /** The id asked for is not this bot's: a plain answer, not a failed call. */
+ missing?: boolean;
}
/** One bot's triggers of every kind, or one trigger with its recent fires. Runs are listed newest first. */
@@ -159,7 +163,7 @@ export function listTriggers(input: {
const routine = routines.find((candidate) => candidate.id === input.triggerId);
const webhook = webhooks.find((candidate) => candidate.id === input.triggerId);
const app = apps.find((candidate) => candidate.id === input.triggerId);
- if (!routine && !webhook && !app) return { ...header, error: "No trigger with that id belongs to this bot. Call trigger_info without trigger_id to see its ids." };
+ if (!routine && !webhook && !app) return { ...header, error: NO_SUCH_TRIGGER, missing: true };
const fires = input.runs.filter((run) => run.routineId === input.triggerId).slice(0, FIRES_SHOWN).map(agentRun);
const shown = routine ? agentRoutine(routine, latest.get(routine.id)) : webhook ? agentWebhook(webhook, latest.get(webhook.id)) : agentAppTrigger(app!, latest.get(app!.id));
const prompt = (routine ?? webhook ?? app)!.prompt;