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

Method handleToolIntermediate

pkg/agent/agent.go:1526–1564  ·  view source on GitHub ↗

handleToolIntermediate 处理中间结果事件

(callID, toolName, label string, data any)

Source from the content-addressed store, hash-verified

1524
1525// handleToolIntermediate 处理中间结果事件
1526func (a *Agent) handleToolIntermediate(callID, toolName, label string, data any) {
1527 now := time.Now()
1528 snapshot := types.ToolCallSnapshot{
1529 ID: callID,
1530 Name: toolName,
1531 State: types.ToolCallStateExecuting,
1532 Intermediate: make(map[string]any),
1533 UpdatedAt: now,
1534 }
1535
1536 a.mu.Lock()
1537 if rec, ok := a.toolRecords[callID]; ok {
1538 if rec.Intermediate == nil {
1539 rec.Intermediate = make(map[string]any)
1540 }
1541 if label == "" {
1542 label = "data"
1543 }
1544 rec.Intermediate[label] = data
1545 rec.State = types.ToolCallStateExecuting
1546 rec.UpdatedAt = now
1547 snapshot.Arguments = rec.Input
1548 snapshot.StartedAt = rec.StartTime
1549 snapshot.UpdatedAt = rec.UpdatedAt
1550 snapshot.Intermediate = rec.Intermediate
1551 } else {
1552 if label == "" {
1553 label = "data"
1554 }
1555 snapshot.Intermediate[label] = data
1556 }
1557 a.mu.Unlock()
1558
1559 a.eventBus.EmitProgress(&types.ProgressToolIntermediateEvent{
1560 Call: snapshot,
1561 Label: label,
1562 Data: data,
1563 })
1564}
1565
1566// toolReporter 将工具回调转换为事件
1567type toolReporter struct {

Callers 3

executeSingleToolMethod · 0.95
IntermediateMethod · 0.80
handleAgentEventFunction · 0.80

Calls 1

EmitProgressMethod · 0.80

Tested by

no test coverage detected