feat(tools): integrate Profile tools config with runner
Add mergeToolsConfig function to combine Profile tools config with CLI options. Profile config serves as base, CLI options override. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
9467ac9fff
commit
3c0f132ff8
2 changed files with 104 additions and 12 deletions
|
|
@ -11,6 +11,7 @@ import {
|
|||
DEFAULT_CONTEXT_TOKENS,
|
||||
type ContextWindowGuardResult,
|
||||
} from "./context-window/index.js";
|
||||
import { mergeToolsConfig, type ToolsConfig } from "./tools/policy.js";
|
||||
|
||||
/**
|
||||
* Get API Key based on provider.
|
||||
|
|
@ -249,7 +250,21 @@ export class Agent {
|
|||
}
|
||||
|
||||
this.agent.setModel(model);
|
||||
this.agent.setTools(resolveTools(options));
|
||||
|
||||
// Merge Profile tools config with options.tools (options takes precedence)
|
||||
const profileToolsConfig = this.profile?.getToolsConfig();
|
||||
const mergedToolsConfig = mergeToolsConfig(profileToolsConfig, options.tools);
|
||||
const toolsOptions = mergedToolsConfig ? { ...options, tools: mergedToolsConfig } : options;
|
||||
|
||||
const tools = resolveTools(toolsOptions);
|
||||
if (this.debug) {
|
||||
if (profileToolsConfig) {
|
||||
console.error(`[debug] Profile tools config: ${JSON.stringify(profileToolsConfig)}`);
|
||||
}
|
||||
console.error(`[debug] Merged tools config: ${JSON.stringify(mergedToolsConfig)}`);
|
||||
console.error(`[debug] Resolved ${tools.length} tools: ${tools.map(t => t.name).join(", ") || "(none)"}`);
|
||||
}
|
||||
this.agent.setTools(tools);
|
||||
|
||||
const restoredMessages = this.session.loadMessages();
|
||||
if (restoredMessages.length > 0) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue