mirror of
https://github.com/TencentCloud/TencentDB-Agent-Memory
synced 2026-07-10 12:34:27 +00:00
Merge pull request #128 from withRiver/fix/remove-tools-clean-context-runner
fix: pass disableTools:true when enableTools=false in CleanContextRunner
This commit is contained in:
@@ -5,7 +5,7 @@
|
|||||||
* Guarantees:
|
* Guarantees:
|
||||||
* 1. Blank conversation history (temporary session file)
|
* 1. Blank conversation history (temporary session file)
|
||||||
* 2. Independent system prompt (only the task prompt)
|
* 2. Independent system prompt (only the task prompt)
|
||||||
* 3. No tool calls (tools restricted to minimal read-only set to avoid empty tools[] rejection by some providers)
|
* 3. No tool calls when enableTools=false (disableTools:true — no tool definitions sent to API)
|
||||||
* 4. No contamination from the main agent's context
|
* 4. No contamination from the main agent's context
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -390,10 +390,11 @@ export class CleanContextRunner {
|
|||||||
},
|
},
|
||||||
tools: {
|
tools: {
|
||||||
...((this.options.config as Record<string, unknown>)?.tools as Record<string, unknown> | undefined),
|
...((this.options.config as Record<string, unknown>)?.tools as Record<string, unknown> | undefined),
|
||||||
// When enableTools=false we still keep one lightweight read-only tool
|
// When enableTools=true, restrict to the minimal set needed for
|
||||||
// so that the tools array sent to the API is non-empty.
|
// scene extraction (read/write/edit).
|
||||||
// Some providers (e.g. qwencode) reject tools:[] with minItems:1 validation.
|
// When enableTools=false, pass an empty allow list — disableTools:true
|
||||||
allow: this.options.enableTools ? ["read", "write", "edit"] : ["read"],
|
// will prevent tools from being sent to the API entirely.
|
||||||
|
allow: this.options.enableTools ? ["read", "write", "edit"] : [],
|
||||||
},
|
},
|
||||||
// Override the full agent system prompt with the caller's extraction-specific
|
// Override the full agent system prompt with the caller's extraction-specific
|
||||||
// system prompt. This replaces OpenClaw's default system prompt (identity,
|
// system prompt. This replaces OpenClaw's default system prompt (identity,
|
||||||
@@ -451,11 +452,13 @@ export class CleanContextRunner {
|
|||||||
runId,
|
runId,
|
||||||
provider: this.resolvedProvider,
|
provider: this.resolvedProvider,
|
||||||
model: this.resolvedModel,
|
model: this.resolvedModel,
|
||||||
// Do NOT pass disableTools:true — that produces tools:[] which some
|
// When enableTools=false, pass disableTools:true so that no tool
|
||||||
// providers (qwencode) reject with "[] is too short - 'tools'".
|
// definitions are sent to the API. This avoids polluting the LLM
|
||||||
// Instead rely on cleanConfig.tools.allow to restrict the tool set
|
// context with tool schemas and prevents the model from attempting
|
||||||
// to a minimal read-only tool (when enableTools=false).
|
// tool calls during pure text extraction tasks.
|
||||||
disableTools: false,
|
// If a provider (e.g. qwencode) rejects empty tools[], users should
|
||||||
|
// switch to StandaloneLLMRunner via LLM configuration instead.
|
||||||
|
disableTools: !this.options.enableTools,
|
||||||
extraSystemPrompt: effectiveSystemPrompt,
|
extraSystemPrompt: effectiveSystemPrompt,
|
||||||
streamParams: {
|
streamParams: {
|
||||||
maxTokens: params.maxTokens,
|
maxTokens: params.maxTokens,
|
||||||
|
|||||||
Reference in New Issue
Block a user