Skip to content

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

fix(claude): leave out four built-in tools no bot can use

milind-soni627f8c94c43a
diff --git a/server/drivers/claude-unusable-tools.ts b/server/drivers/claude-unusable-tools.ts
new file mode 100644
index 0000000000..f93e19b27b
--- /dev/null
+++ b/server/drivers/claude-unusable-tools.ts
@@ -0,0 +1,10 @@
+// Built-in Claude Code tools that work only in Claude Code's own terminal or app, yet ride every model call of a bot turn at
+// about 4,900 tokens: Workflow runs in the background, which a turn turns off, and needs a person opting in at /workflows;
+// ScheduleWakeup paces a /loop, where a bot has wait_until; ReportFindings draws in a host UI there is none of; ListAgents
+// lists this machine's other Claude sessions. An engine or a guest turn that lists its own tools has left them out already,
+// and a bot that inherits this machine's setup keeps them.
+export const BUILT_INS_NO_BOT_CAN_USE = ["Workflow", "ScheduleWakeup", "ReportFindings", "ListAgents"] as const;
+
+export function unusableBuiltIns(turn: { isolated: boolean; listsTools: boolean; guest: boolean }): readonly string[] {
+ return turn.isolated && !turn.listsTools && !turn.guest ? BUILT_INS_NO_BOT_CAN_USE : [];
+}
diff --git a/server/drivers/claude.test.ts b/server/drivers/claude.test.ts
index d33d86e712..9b03b811c2 100644
--- a/server/drivers/claude.test.ts
+++ b/server/drivers/claude.test.ts
@@ -2308,9 +2308,25 @@ describe("ClaudeDriver turns (fake CLI)", () => {
const seen = JSON.parse(readFileSync(dump, "utf8"));
expect(seen.argv[seen.argv.indexOf("--tools") + 1]).toBe("Read,WebFetch");
+ // Its own list leaves the rest out already.
expect(seen.argv[seen.argv.indexOf("--disallowedTools") + 1]).toBe("Bash(git *),Edit");
});
+ it("leaves out the built-ins no bot can use, unless the bot inherits the machine's own setup", async () => {
+ const dump = join(scratch, "built-ins.json");
+ await create(undefined, { FAKE_CLAUDE_DUMP: dump });
+ await instance.adapter.sendTurn({ threadId: "t-built-ins", text: "hi" });
+ await recorder.until((event) => event.type === "turn.completed");
+ const seen = JSON.parse(readFileSync(dump, "utf8"));
+ expect(seen.argv[seen.argv.indexOf("--disallowedTools") + 1].split(",")).toEqual(["Workflow", "ScheduleWakeup", "ReportFindings", "ListAgents"]);
+
+ const inherited = join(scratch, "built-ins-inherit.json");
+ await create(undefined, { FAKE_CLAUDE_DUMP: inherited, OMB_CLAUDE_INHERIT_USER_CONFIG: "1" });
+ await instance.adapter.sendTurn({ threadId: "t-built-ins-inherit", text: "hi" });
+ await recorder.until((event) => event.type === "turn.completed");
+ expect(JSON.parse(readFileSync(inherited, "utf8")).argv).not.toContain("--disallowedTools");
+ });
+
it("passes an explicit empty available set to disable every Claude built-in", async () => {
await create(undefined, {}, { tools: [], disallowedTools: [] });
const dump = join(scratch, "no-builtins.json");
diff --git a/server/drivers/claude.ts b/server/drivers/claude.ts
index 8c58a11eb7..adbf0bd7db 100644
--- a/server/drivers/claude.ts
+++ b/server/drivers/claude.ts
@@ -17,7 +17,7 @@ import { botSettingsFor, withBotSettings } from "./claude-bot-settings.ts";
import { claudeBilling, claudeCallUsage } from "./claude-billing.ts";
import { claudeAuthFailure, claudeAuthRecovery } from "./claude-auth-recovery.ts";
import { claudeModelExtras } from "./claude-model-extras.ts";
-import { claudeToolSearchSetting } from "./claude-tool-search.ts";
+import { claudeToolSearchSetting } from "./claude-tool-search.ts"; import { unusableBuiltIns } from "./claude-unusable-tools.ts";
import { claudeElicitations } from "./claude-elicitation.ts";
import { readCostHistory, recordCostState } from "./claude-cost-history.ts";
import { classifyResumeFailure, mayReplay, rebuiltSessionNotice, recoveryPromptFor } from "../resume-recovery.ts";
@@ -1023,9 +1023,6 @@ export const ClaudeDriver: ProviderDriver<ClaudeConfig> = {
}
if (turn.guestConfined) args.push("--restricted", "--tools", GUEST_CLAUDE_TOOLS.join(","));
else if (config.tools !== undefined) args.push("--tools", config.tools.join(","));
- if (config.disallowedTools?.length) {
- args.push("--disallowedTools", config.disallowedTools.join(","));
- }
const turnEnvironment = environment();
await ensureCliVersion(turnEnvironment);
if (turn.guestConfined && !claudeCliSupports(cliVersion, "--restricted")) {
@@ -1034,6 +1031,8 @@ export const ClaudeDriver: ProviderDriver<ClaudeConfig> = {
const replaysUserMessages = cliVersion === null || versionAtLeast(cliVersion, CLAUDE_REPLAY_FLOOR);
if (replaysUserMessages) args.push("--replay-user-messages");
const isolated = !inheritsUserConfig(turnEnvironment);
+ const disallowed = [...(config.disallowedTools ?? []), ...unusableBuiltIns({ isolated, listsTools: config.tools !== undefined, guest: Boolean(turn.guestConfined) })];
+ if (disallowed.length) args.push("--disallowedTools", disallowed.join(","));
if (turn.toolScope !== undefined && (!isolated || turn.mcpFromUserConfig || cliVersion === null || !claudeCliSupports(cliVersion, "--strict-mcp-config"))) {
throw new Error("Claude cannot confirm a restricted MCP configuration for this account. Disable inherited Claude MCP servers and use a current, identifiable Claude CLI before using tool selection.");
}