feat: persist toolset mode and add auto option (#1015)

This commit is contained in:
Charles Packer
2026-02-18 13:43:40 -08:00
committed by GitHub
parent bdc23932b5
commit 5fac4bc106
7 changed files with 333 additions and 230 deletions

View File

@@ -5,6 +5,7 @@ import {
clearToolsWithLock,
GEMINI_PASCAL_TOOLS,
getToolNames,
isGeminiModel,
isOpenAIModel,
loadSpecificTools,
loadTools,
@@ -35,6 +36,18 @@ export type ToolsetName =
| "gemini"
| "gemini_snake"
| "none";
export type ToolsetPreference = ToolsetName | "auto";
export function deriveToolsetFromModel(
modelIdentifier: string,
): "codex" | "gemini" | "default" {
const resolvedModel = resolveModel(modelIdentifier) ?? modelIdentifier;
return isOpenAIModel(resolvedModel)
? "codex"
: isGeminiModel(resolvedModel)
? "gemini"
: "default";
}
/**
* Ensures the correct memory tool is attached to the agent based on the model.
@@ -248,11 +261,6 @@ export async function forceToolsetSwitch(
const useMemoryPatch =
toolsetName === "codex" || toolsetName === "codex_snake";
await ensureCorrectMemoryTool(agentId, modelForLoading, useMemoryPatch);
// NOTE: Toolset is not persisted. On resume, we derive from agent's model.
// If we want to persist explicit toolset overrides in the future, add:
// agentToolsets: Record<string, ToolsetName> to Settings (global, since agent IDs are UUIDs)
// and save here: settingsManager.updateSettings({ agentToolsets: { ...current, [agentId]: toolsetName } })
}
/**
@@ -293,13 +301,6 @@ export async function switchToolsetForModel(
// Ensure base memory tool is correct for the model
await ensureCorrectMemoryTool(agentId, resolvedModel);
const { isGeminiModel } = await import("./manager");
const toolsetName = isOpenAIModel(resolvedModel)
? "codex"
: isGeminiModel(resolvedModel)
? "gemini"
: "default";
// NOTE: Toolset is derived from model, not persisted. See comment in forceToolsetSwitch.
const toolsetName = deriveToolsetFromModel(resolvedModel);
return toolsetName;
}