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

Method handleToolProgress

pkg/agent/agent.go:1493–1523  ·  view source on GitHub ↗

handleToolProgress 处理进度事件并推送到总线

(callID, toolName string, progress float64, message string, step, total int, metadata map[string]any, etaMs int64)

Source from the content-addressed store, hash-verified

1491
1492// handleToolProgress 处理进度事件并推送到总线
1493func (a *Agent) handleToolProgress(callID, toolName string, progress float64, message string, step, total int, metadata map[string]any, etaMs int64) {
1494 now := time.Now()
1495 snapshot := types.ToolCallSnapshot{
1496 ID: callID,
1497 Name: toolName,
1498 State: types.ToolCallStateExecuting,
1499 Progress: progress,
1500 UpdatedAt: now,
1501 }
1502
1503 a.mu.Lock()
1504 if rec, ok := a.toolRecords[callID]; ok {
1505 rec.Progress = progress
1506 rec.State = types.ToolCallStateExecuting
1507 rec.UpdatedAt = now
1508 snapshot.Arguments = rec.Input
1509 snapshot.StartedAt = rec.StartTime
1510 snapshot.UpdatedAt = rec.UpdatedAt
1511 }
1512 a.mu.Unlock()
1513
1514 a.eventBus.EmitProgress(&types.ProgressToolProgressEvent{
1515 Call: snapshot,
1516 Progress: progress,
1517 Message: message,
1518 Step: step,
1519 Total: total,
1520 Metadata: metadata,
1521 ETA: etaMs,
1522 })
1523}
1524
1525// handleToolIntermediate 处理中间结果事件
1526func (a *Agent) handleToolIntermediate(callID, toolName, label string, data any) {

Callers 4

executeSingleToolMethod · 0.95
ProgressMethod · 0.80
handleAgentEventFunction · 0.80
handleAgentEventFunction · 0.80

Calls 1

EmitProgressMethod · 0.80

Tested by

no test coverage detected