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

Method handleToolCall

pkg/agent/actor.go:347–373  ·  view source on GitHub ↗

handleToolCall 处理工具调用

(ctx *actor.Context, msg *ToolCallMsg)

Source from the content-addressed store, hash-verified

345
346// handleToolCall 处理工具调用
347func (a *AgentActor) handleToolCall(ctx *actor.Context, msg *ToolCallMsg) {
348 execCtx, cancel := a.withCancellation(msg.Ctx)
349 defer cancel()
350
351 go func() {
352 result := a.agent.executeSingleTool(execCtx, msg.ToolUse)
353
354 var response *ToolResultMsg
355
356 if toolResult, ok := result.(*types.ToolResultBlock); ok {
357 response = &ToolResultMsg{
358 CallID: msg.ToolUse.ID,
359 Result: toolResult.Content,
360 IsError: toolResult.IsError,
361 }
362 } else {
363 response = &ToolResultMsg{
364 CallID: msg.ToolUse.ID,
365 Result: result,
366 }
367 }
368
369 if ctx.Sender != nil {
370 ctx.Reply(response)
371 }
372 }()
373}
374
375// handleDirectToolCall 处理直接工具调用
376func (a *AgentActor) handleDirectToolCall(ctx *actor.Context, msg *DirectToolCallMsg) {

Callers 1

ReceiveMethod · 0.95

Calls 4

withCancellationMethod · 0.95
cancelFunction · 0.85
executeSingleToolMethod · 0.80
ReplyMethod · 0.80

Tested by

no test coverage detected