handleToolProgress 处理进度事件并推送到总线
(callID, toolName string, progress float64, message string, step, total int, metadata map[string]any, etaMs int64)
| 1491 | |
| 1492 | // handleToolProgress 处理进度事件并推送到总线 |
| 1493 | func (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 处理中间结果事件 |
| 1526 | func (a *Agent) handleToolIntermediate(callID, toolName, label string, data any) { |
no test coverage detected