mirror of
https://github.com/earendil-works/pi.git
synced 2026-06-18 15:54:04 +08:00
@@ -6,7 +6,7 @@ import { AuthStorage } from "./auth-storage.js";
|
||||
import type { SessionStartEvent, ToolDefinition } from "./extensions/index.js";
|
||||
import { ModelRegistry } from "./model-registry.js";
|
||||
import { DefaultResourceLoader, type DefaultResourceLoaderOptions, type ResourceLoader } from "./resource-loader.js";
|
||||
import { type CreateAgentSessionResult, createAgentSession } from "./sdk.js";
|
||||
import { type CreateAgentSessionOptions, type CreateAgentSessionResult, createAgentSession } from "./sdk.js";
|
||||
import type { SessionManager } from "./session-manager.js";
|
||||
import { SettingsManager } from "./settings-manager.js";
|
||||
|
||||
@@ -53,6 +53,7 @@ export interface CreateAgentSessionFromServicesOptions {
|
||||
thinkingLevel?: ThinkingLevel;
|
||||
scopedModels?: Array<{ model: Model<any>; thinkingLevel?: ThinkingLevel }>;
|
||||
tools?: string[];
|
||||
noTools?: CreateAgentSessionOptions["noTools"];
|
||||
customTools?: ToolDefinition[];
|
||||
}
|
||||
|
||||
@@ -190,6 +191,7 @@ export async function createAgentSessionFromServices(
|
||||
thinkingLevel: options.thinkingLevel,
|
||||
scopedModels: options.scopedModels,
|
||||
tools: options.tools,
|
||||
noTools: options.noTools,
|
||||
customTools: options.customTools,
|
||||
sessionStartEvent: options.sessionStartEvent,
|
||||
});
|
||||
|
||||
@@ -585,6 +585,7 @@ export async function main(args: string[], options?: MainOptions) {
|
||||
thinkingLevel: sessionOptions.thinkingLevel,
|
||||
scopedModels: sessionOptions.scopedModels,
|
||||
tools: sessionOptions.tools,
|
||||
noTools: sessionOptions.noTools,
|
||||
customTools: sessionOptions.customTools,
|
||||
});
|
||||
const cliThinkingOverride = parsed.thinking !== undefined || cliThinkingFromModel;
|
||||
|
||||
+26
@@ -4,6 +4,10 @@ import { join } from "node:path";
|
||||
import { getModel } from "@mariozechner/pi-ai";
|
||||
import { Type } from "typebox";
|
||||
import { afterEach, beforeEach, describe, expect, it } from "vitest";
|
||||
import {
|
||||
createAgentSessionFromServices,
|
||||
createAgentSessionServices,
|
||||
} from "../../../src/core/agent-session-services.js";
|
||||
import { DefaultResourceLoader } from "../../../src/core/resource-loader.js";
|
||||
import { createAgentSession } from "../../../src/core/sdk.js";
|
||||
import { SessionManager } from "../../../src/core/session-manager.js";
|
||||
@@ -90,4 +94,26 @@ describe("regression #3592: no-builtin-tools keeps extension tools enabled", ()
|
||||
expect(session.systemPrompt).toContain("Available tools:\n(none)");
|
||||
session.dispose();
|
||||
});
|
||||
|
||||
it("propagates noTools through service-based session creation", async () => {
|
||||
const settingsManager = SettingsManager.create(tempDir, agentDir);
|
||||
const sessionManager = SessionManager.inMemory(tempDir);
|
||||
const services = await createAgentSessionServices({
|
||||
cwd: tempDir,
|
||||
agentDir,
|
||||
settingsManager,
|
||||
});
|
||||
|
||||
const { session } = await createAgentSessionFromServices({
|
||||
services,
|
||||
sessionManager,
|
||||
model: getModel("anthropic", "claude-sonnet-4-5")!,
|
||||
noTools: "builtin",
|
||||
});
|
||||
|
||||
expect(session.getActiveToolNames()).toEqual([]);
|
||||
expect(session.systemPrompt).toContain("Available tools:\n(none)");
|
||||
expect(session.systemPrompt).not.toContain("- read:");
|
||||
session.dispose();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user