AgentActorCallTool 向 Agent Actor 发送工具调用请求并等待响应
(pid *actor.PID, toolName string, input map[string]any, timeout time.Duration)
| 553 | |
| 554 | // AgentActorCallTool 向 Agent Actor 发送工具调用请求并等待响应 |
| 555 | func AgentActorCallTool(pid *actor.PID, toolName string, input map[string]any, timeout time.Duration) (*DirectToolResultMsg, error) { |
| 556 | replyCh := make(chan *DirectToolResultMsg, 1) |
| 557 | |
| 558 | pid.Tell(&DirectToolCallMsg{ |
| 559 | ToolName: toolName, |
| 560 | Input: input, |
| 561 | Ctx: context.Background(), |
| 562 | ReplyTo: replyCh, |
| 563 | }) |
| 564 | |
| 565 | select { |
| 566 | case result := <-replyCh: |
| 567 | return result, nil |
| 568 | case <-time.After(timeout): |
| 569 | return nil, fmt.Errorf("tool call timed out after %v", timeout) |
| 570 | } |
| 571 | } |
| 572 | |
| 573 | // AgentActorGetStatus 获取 Agent 状态 |
| 574 | func AgentActorGetStatus(pid *actor.PID, timeout time.Duration) (*types.AgentStatus, error) { |