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

Method ExecuteToolCall

pkg/middleware/stack.go:61–77  ·  view source on GitHub ↗

ExecuteToolCall 执行工具调用(通过中间件栈)

(
	ctx context.Context,
	req *ToolCallRequest,
	finalHandler ToolCallHandler,
)

Source from the content-addressed store, hash-verified

59
60// ExecuteToolCall 执行工具调用(通过中间件栈)
61func (s *Stack) ExecuteToolCall(
62 ctx context.Context,
63 req *ToolCallRequest,
64 finalHandler ToolCallHandler,
65) (*ToolCallResponse, error) {
66 // 构建中间件链
67 handler := finalHandler
68 for i := len(s.middlewares) - 1; i >= 0; i-- {
69 m := s.middlewares[i]
70 currentHandler := handler
71 handler = func(ctx context.Context, req *ToolCallRequest) (*ToolCallResponse, error) {
72 return m.WrapToolCall(ctx, req, currentHandler)
73 }
74 }
75
76 return handler(ctx, req)
77}
78
79// OnAgentStart 通知所有中间件 Agent 启动
80func (s *Stack) OnAgentStart(ctx context.Context, agentID string) error {

Callers 1

executeSingleToolMethod · 0.80

Calls 2

handlerFunction · 0.85
WrapToolCallMethod · 0.65

Tested by

no test coverage detected