From 19f43e30c8d5fb8ba98d6c3acac022eca2542695 Mon Sep 17 00:00:00 2001 From: justsisyphus Date: Tue, 27 Jan 2026 08:36:55 +0900 Subject: [PATCH] feat(librarian): conditionally enable thinking based on model type MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add isGeminiModel helper to detect Gemini models - Disable thinking config for Gemini models (not supported) - Enable thinking with 32000 token budget for other models - Add tests verifying both Gemini and Claude behavior 🤖 Generated with assistance of OhMyOpenCode --- src/agents/librarian.ts | 9 ++++++++- src/agents/types.ts | 4 ++++ src/agents/utils.test.ts | 28 ++++++++++++++++++++++++++++ 3 files changed, 40 insertions(+), 1 deletion(-) diff --git a/src/agents/librarian.ts b/src/agents/librarian.ts index b6ed33445..03ccaaf7b 100644 --- a/src/agents/librarian.ts +++ b/src/agents/librarian.ts @@ -1,5 +1,6 @@ import type { AgentConfig } from "@opencode-ai/sdk" import type { AgentPromptMetadata } from "./types" +import { isGeminiModel } from "./types" import { createAgentToolRestrictions } from "../shared/permission-compat" export const LIBRARIAN_PROMPT_METADATA: AgentPromptMetadata = { @@ -28,7 +29,7 @@ export function createLibrarianAgent(model: string): AgentConfig { "call_omo_agent", ]) - return { + const base = { description: "Specialized codebase understanding agent for multi-repository analysis, searching remote codebases, retrieving official documentation, and finding implementation examples using GitHub CLI, Context7, and Web Search. MUST BE USED when users ask to look up code in remote repositories, explain library internals, or find usage examples in open source.", mode: "subagent" as const, @@ -322,5 +323,11 @@ grep_app_searchGitHub(query: "useQuery") `, } + + if (isGeminiModel(model)) { + return base + } + + return { ...base, thinking: { type: "enabled", budgetTokens: 32000 } } } diff --git a/src/agents/types.ts b/src/agents/types.ts index 5c21c3320..49543677f 100644 --- a/src/agents/types.ts +++ b/src/agents/types.ts @@ -56,6 +56,10 @@ export function isGptModel(model: string): boolean { return model.startsWith("openai/") || model.startsWith("github-copilot/gpt-") } +export function isGeminiModel(model: string): boolean { + return model.includes("gemini") +} + export type BuiltinAgentName = | "sisyphus" | "oracle" diff --git a/src/agents/utils.test.ts b/src/agents/utils.test.ts index 66a37a185..c6290faf7 100644 --- a/src/agents/utils.test.ts +++ b/src/agents/utils.test.ts @@ -91,6 +91,34 @@ describe("createBuiltinAgents with model overrides", () => { expect(agents.oracle.textVerbosity).toBeUndefined() }) + test("Librarian with Gemini model has no thinking", async () => { + // #given + const overrides = { + librarian: { model: "google/gemini-3-flash-preview" }, + } + + // #when + const agents = await createBuiltinAgents([], overrides, undefined, TEST_DEFAULT_MODEL) + + // #then + expect(agents.librarian.model).toBe("google/gemini-3-flash-preview") + expect(agents.librarian.thinking).toBeUndefined() + }) + + test("Librarian with Claude model has thinking enabled", async () => { + // #given + const overrides = { + librarian: { model: "anthropic/claude-sonnet-4-5" }, + } + + // #when + const agents = await createBuiltinAgents([], overrides, undefined, TEST_DEFAULT_MODEL) + + // #then + expect(agents.librarian.model).toBe("anthropic/claude-sonnet-4-5") + expect(agents.librarian.thinking).toEqual({ type: "enabled", budgetTokens: 32000 }) + }) + test("non-model overrides are still applied after factory rebuild", async () => { // #given const overrides = {