Skip to content

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

Goal runs: re-ask a malformed control envelope a fixed three times, with no new environment switch

milind-soni05d5978b41ea
diff --git a/server/bot-box/env.test.ts b/server/bot-box/env.test.ts
index 10bb945888..9cbf497ae3 100644
--- a/server/bot-box/env.test.ts
+++ b/server/bot-box/env.test.ts
@@ -37,7 +37,7 @@ const SERVER_ONLY_OMB: ReadonlySet<string> = new Set([
"OMB_DEV_TRUST_LOCAL_BROWSER", "OMB_DISABLE_ANNOUNCEMENTS", "OMB_DISABLE_MODEL_CATALOG_FETCH", "OMB_DISABLE_MODEL_MANIFEST_FETCH", "OMB_DUCKDB_DIR", "OMB_DUCKDB_MAX_TEMP_SIZE",
"OMB_DUCKDB_MEMORY_LIMIT", "OMB_ELEVENLABS_API", "OMB_ENGINE_SESSION_SWEEP", "OMB_ENGINE_TAG", "OMB_ENTERPRISE_DIR", "OMB_ENVIRONMENT_LABEL", "OMB_EOF",
"OMB_FIRST_REPLY_NOTICE_MS", "OMB_FISH_AUDIO_API", "OMB_FISH_AUDIO_API_KEY", "OMB_FISH_LIVE_AGENT_ID", "OMB_FISH_LIVE_URL", "OMB_FLEET_SOCKET", "OMB_GATE_",
- "OMB_GEMINI_API_KEY", "OMB_GEMINI_IMAGE_KEY", "OMB_GEMINI_LIVE_MODEL", "OMB_GEMINI_LIVE_URL", "OMB_GEMINI_TTS_API", "OMB_GOAL_CONTROL_MISSES", "OMB_GOAL_WAIT_MAX_MS",
+ "OMB_GEMINI_API_KEY", "OMB_GEMINI_IMAGE_KEY", "OMB_GEMINI_LIVE_MODEL", "OMB_GEMINI_LIVE_URL", "OMB_GEMINI_TTS_API", "OMB_GOAL_WAIT_MAX_MS",
"OMB_GREENFERENCE_API_KEY", "OMB_GROQ_API_KEY", "OMB_HANDOFF_MAX_FAILURES", "OMB_HANDOFF_MAX_TURNS", "OMB_HELPER_INSTANCE", "OMB_HELPER_MODEL", "OMB_HOOKS", "OMB_HOOK_",
"OMB_HOSTED_", "OMB_HOSTED_MODELS", "OMB_HOSTED_MODEL_TOKEN", "OMB_HOSTED_MODEL_URL", "OMB_IDLE_ENGINES_MAX", "OMB_IMAGE_ENGINES", "OMB_INSTALLATION_CREDENTIAL",
"OMB_JEV_API_KEY", "OMB_LAN", "OMB_LICENSE_KEY", "OMB_LINUX_GPU", "OMB_LIVE_PROVIDER", "OMB_LOCAL_VM_UPDATE_WAIT_MS",
diff --git a/server/group-goal-run-one-on-one.e2e.test.ts b/server/group-goal-run-one-on-one.e2e.test.ts
index ce1e531dd4..97727181ea 100644
--- a/server/group-goal-run-one-on-one.e2e.test.ts
+++ b/server/group-goal-run-one-on-one.e2e.test.ts
@@ -115,7 +115,6 @@ ${envelope({ status: "completed", detail: "Done." })}`]),
USERPROFILE: home,
OMB_PORT: String(port),
OMB_WEBHOOK_PORT: String(port + 1),
- OMB_GOAL_CONTROL_MISSES: "3",
},
stdio: ["ignore", "pipe", "pipe"],
});
diff --git a/server/group-goal-run.test.ts b/server/group-goal-run.test.ts
index bce99aae9d..ddab1eca34 100644
--- a/server/group-goal-run.test.ts
+++ b/server/group-goal-run.test.ts
@@ -1,9 +1,9 @@
-import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
+import { describe, expect, it } from "vitest";
import {
GROUP_GOAL_CONTROL_CLOSE,
GROUP_GOAL_CONTROL_OPEN,
+ GROUP_GOAL_CONTROL_MISSES,
GROUP_GOAL_MAX_TURNS,
- goalControlMissLimit,
groupGoalAssignmentKey,
groupGoalCompletionTurnId,
groupGoalCoordinatorInstructions,
@@ -15,9 +15,6 @@ import {
type GoalStepResult,
} from "./group-goal-run.ts";
-beforeEach(() => { delete process.env.OMB_GOAL_CONTROL_MISSES; });
-afterEach(() => vi.unstubAllEnvs());
-
const members = [
{ id: "scout-id", name: "Scout" },
{ id: "chief-id", name: "Miso", chiefOfStaff: true },
@@ -97,13 +94,8 @@ describe("group goal runs", () => {
expect(GROUP_GOAL_MAX_TURNS % 2).toBe(1);
});
- it("bounds how many malformed control envelopes are re-asked", () => {
- expect(goalControlMissLimit(undefined)).toBe(3);
- expect(goalControlMissLimit("")).toBe(3);
- expect(goalControlMissLimit("0")).toBe(3);
- expect(goalControlMissLimit("not-a-number")).toBe(3);
- expect(goalControlMissLimit("2")).toBe(2);
- expect(goalControlMissLimit("9")).toBe(5);
+ it("re-asks a malformed control envelope a bounded number of times", () => {
+ expect(GROUP_GOAL_CONTROL_MISSES).toBe(3);
});
});
@@ -260,14 +252,6 @@ describe("one goal-run loop for a room and a one-on-one chat", () => {
expect(goal.finished).toEqual([{ status: "completed", detail: "Done." }]);
});
- it("blocks at a configured miss limit", async () => {
- vi.stubEnv("OMB_GOAL_CONTROL_MISSES", "2");
- const goal = goalRun({ solo: true, steps: [settled("All done, trust me.")] });
- await goal.done;
- expect(goal.calls).toHaveLength(2);
- expect(goal.finished).toEqual([{ status: "blocked", detail: "Solo did not provide a valid next-step decision after 2 replies." }]);
- });
-
it("blocks a room of one that repeats the same next step", async () => {
const goal = goalRun({ solo: true, steps: [settled(envelope({ status: "continue", next: "solo-id", instruction: "Same thing", detail: "Again" }))] });
await goal.done;
diff --git a/server/group-goal-run.ts b/server/group-goal-run.ts
index 3e02aeef31..4cb017c62f 100644
--- a/server/group-goal-run.ts
+++ b/server/group-goal-run.ts
@@ -7,13 +7,8 @@ import type { GroupDefaultResponder } from "./store.ts";
export const GROUP_GOAL_MAX_TURNS = 13;
export const GROUP_GOAL_WAIT_MAX_MS = Math.max(1_000, Number(process.env.OMB_GOAL_WAIT_MAX_MS) || 30 * 60_000);
const GROUP_GOAL_MAX_WAIT_EXHAUSTIONS = 3;
-const GROUP_GOAL_CONTROL_MISSES = 3;
-const GROUP_GOAL_CONTROL_MISSES_MAX = 5;
-/** How many replies in a row may miss the control envelope before the run is blocked (OMB_GOAL_CONTROL_MISSES, 1-5). */
-export function goalControlMissLimit(raw = process.env.OMB_GOAL_CONTROL_MISSES): number {
- const parsed = Number(raw);
- return Number.isInteger(parsed) && parsed >= 1 ? Math.min(parsed, GROUP_GOAL_CONTROL_MISSES_MAX) : GROUP_GOAL_CONTROL_MISSES;
-}
+/** How many replies in a row may miss the control envelope before the run is blocked. */
+export const GROUP_GOAL_CONTROL_MISSES = 3;
export const GROUP_GOAL_CONTROL_OPEN = "<openmaus-goal>";
export const GROUP_GOAL_CONTROL_CLOSE = "</openmaus-goal>";
/** A close tag the model sometimes escapes; it ends an envelope exactly like the plain one. */
@@ -368,7 +363,7 @@ export async function runGoalRun<Bot extends GoalRunMember>(deps: GoalRunDeps<Bo
const decision = parseGroupGoalDecision(coordinatorResult.replyText).decision;
if (!decision) {
controlMisses += 1;
- const limit = goalControlMissLimit();
+ const limit = GROUP_GOAL_CONTROL_MISSES;
if (controlMisses >= limit || run.turnCount >= run.maxTurns) {
deps.finish("blocked", `${coordinator.name} did not provide a valid next-step decision after ${controlMisses} ${controlMisses === 1 ? "reply" : "replies"}.`);
return;