Skip to content

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

fix: retain budget exhaustion events in the thread inspector

Afloat5c300847c626
diff --git a/server/thread-events.test.ts b/server/thread-events.test.ts
index acd8dba746..2f94bdd99e 100644
--- a/server/thread-events.test.ts
+++ b/server/thread-events.test.ts
@@ -63,6 +63,24 @@ describe("readThreadEvents", () => {
expect(page.entries.map((entry) => (entry.data as { eventId: string }).eventId)).toEqual(["e1"]);
});
+ it("keeps budget exhaustion and its handoff while rejecting malformed cap events", () => {
+ const eventsDir = tmp();
+ const nativeDir = tmp();
+ const cap = runtime({ eventId: "cap", type: "cap.exhausted", createdAt: "2026-08-17T10:00:00.000Z", handoffPath: "/fixture/handoff.json", reason: "cap" });
+ writeFileSync(join(eventsDir, "t1.ndjson"), [
+ cap,
+ { ...cap, eventId: "missing-path", handoffPath: undefined },
+ { ...cap, eventId: "bad-path", handoffPath: 42 },
+ { ...cap, eventId: "missing-reason", reason: undefined },
+ { ...cap, eventId: "bad-reason", reason: "timeout" },
+ ].map(line).join(""));
+
+ const page = readThreadEvents({ eventsDir, nativeDir, threadId: "t1" });
+
+ expect(page.entries).toHaveLength(1);
+ expect(page.entries[0]).toMatchObject({ kind: "runtime", data: cap });
+ });
+
it("caps each log to its most recent `limit` lines and reports what it skipped", () => {
const eventsDir = tmp();
const nativeDir = tmp();
diff --git a/server/thread-events.ts b/server/thread-events.ts
index 5e82b4855c..b84cc200a2 100644
--- a/server/thread-events.ts
+++ b/server/thread-events.ts
@@ -177,6 +177,8 @@ export function isRuntimeEvent(value: unknown): value is RuntimeEvent {
);
case "turn.wait_started":
return typeof value.resource === "string" && computerHolderOrMissing(value.holder);
+ case "cap.exhausted":
+ return typeof value.handoffPath === "string" && value.reason === "cap";
case "turn.wait_ended":
return (
typeof value.resource === "string" &&