mirror of
https://github.com/TencentCloud/TencentDB-Agent-Memory
synced 2026-07-10 12:34:27 +00:00
Do not expose tools for standalone text-only LLMRunner tasks (#59)
Removes tool exposure from the standalone `LLMRunner` when `enableTools=false`. Some standalone text-only tasks, such as L1 extraction, expect plain text output and do not need tool access. Passing even a read-only tool subset can still encourage tool-calling behavior on OpenAI-compatible backends, which makes this path less stable than necessary. With this change: - `enableTools=true` keeps the existing sandboxed tool behavior - `enableTools=false` sends no tools at all
This commit is contained in:
@@ -149,12 +149,6 @@ function createSandboxedTools(workspaceDir: string, logger?: Logger) {
|
||||
};
|
||||
}
|
||||
|
||||
/** Read-only tool subset — used when enableTools=false to avoid empty tools rejection. */
|
||||
function createReadOnlyTools(workspaceDir: string, logger?: Logger) {
|
||||
const all = createSandboxedTools(workspaceDir, logger);
|
||||
return { read_file: all.read_file };
|
||||
}
|
||||
|
||||
// ============================
|
||||
// StandaloneLLMRunner
|
||||
// ============================
|
||||
@@ -197,17 +191,17 @@ export class StandaloneLLMRunner implements LLMRunner {
|
||||
compatibility: "compatible",
|
||||
});
|
||||
|
||||
// Select tools based on mode
|
||||
// For pure text tasks like L1 extraction, avoid exposing any tools.
|
||||
const tools = this.enableTools
|
||||
? createSandboxedTools(workspaceDir, this.logger)
|
||||
: createReadOnlyTools(workspaceDir, this.logger);
|
||||
: undefined;
|
||||
|
||||
try {
|
||||
const result = await generateText({
|
||||
model: provider.chat(this.model),
|
||||
system: params.systemPrompt,
|
||||
prompt: params.prompt,
|
||||
tools,
|
||||
...(tools ? { tools } : {}),
|
||||
stopWhen: stepCountIs(this.enableTools ? MAX_TOOL_ITERATIONS : 1),
|
||||
maxOutputTokens: maxTokens,
|
||||
abortSignal: AbortSignal.timeout(timeoutMs),
|
||||
|
||||
Reference in New Issue
Block a user