MCPcopy Create free account
hub / github.com/astercloud/aster / DeactivateTool

Method DeactivateTool

pkg/agent/tool_manager.go:194–224  ·  view source on GitHub ↗

DeactivateTool 停用工具(移回延迟状态)

(name string)

Source from the content-addressed store, hash-verified

192
193// DeactivateTool 停用工具(移回延迟状态)
194func (tm *ToolManager) DeactivateTool(name string) error {
195 tm.mu.Lock()
196 defer tm.mu.Unlock()
197
198 ctx := context.Background() // 用于日志记录
199
200 // 不能停用核心工具
201 if tm.isCoreToolLocked(name) {
202 return fmt.Errorf("cannot deactivate core tool: %s", name)
203 }
204
205 // 检查是否在活跃工具列表中
206 tool, ok := tm.activeTools[name]
207 if !ok {
208 return nil // 已经不活跃
209 }
210
211 // 移动到延迟工具列表
212 entry := tm.index.GetTool(name)
213 if entry != nil {
214 entry.Deferred = true
215 tm.deferredTools[name] = *entry
216 if err := tm.index.IndexToolEntry(*entry); err != nil {
217 toolMgrLog.Warn(ctx, "failed to update tool index", map[string]any{"error": err})
218 }
219 }
220 delete(tm.activeTools, name)
221
222 toolMgrLog.Debug(ctx, "tool deactivated", map[string]any{"name": name, "tool_type": fmt.Sprintf("%T", tool)})
223 return nil
224}
225
226// AddTool 添加新工具
227func (tm *ToolManager) AddTool(tool tools.Tool, source string, deferred bool) error {

Callers

nothing calls this directly

Calls 6

isCoreToolLockedMethod · 0.95
deleteFunction · 0.85
IndexToolEntryMethod · 0.80
WarnMethod · 0.65
DebugMethod · 0.65
GetToolMethod · 0.45

Tested by

no test coverage detected