Changeset 0.22.4 (#146)
This commit is contained in:
@@ -7,6 +7,7 @@ import (
|
||||
"fmt"
|
||||
"log"
|
||||
"net/http"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
@@ -35,7 +36,11 @@ func recordHealthFn(hr HealthRecorder, configID string, start time.Time, err err
|
||||
latencyMs := int(time.Since(start).Milliseconds())
|
||||
if err != nil {
|
||||
errMsg := err.Error()
|
||||
hr.RecordError(configID, latencyMs, errMsg)
|
||||
if strings.Contains(errMsg, "HTTP 429") || strings.Contains(errMsg, "rate limit") || strings.Contains(errMsg, "Too Many Requests") {
|
||||
hr.RecordRateLimit(configID, latencyMs, errMsg)
|
||||
} else {
|
||||
hr.RecordError(configID, latencyMs, errMsg)
|
||||
}
|
||||
} else {
|
||||
hr.RecordSuccess(configID, latencyMs)
|
||||
}
|
||||
@@ -205,9 +210,19 @@ func streamWithToolLoop(
|
||||
var toolResult tools.ToolResult
|
||||
|
||||
// Check if tool is registered locally (server-side)
|
||||
toolStart := time.Now()
|
||||
if tools.Get(call.Name) != nil {
|
||||
log.Printf("🔧 Executing tool (server): %s (call %s)", call.Name, call.ID)
|
||||
toolResult = tools.ExecuteCall(c.Request.Context(), execCtx, call)
|
||||
// Record tool health (v0.22.4)
|
||||
if health != nil {
|
||||
toolLatency := int(time.Since(toolStart).Milliseconds())
|
||||
if toolResult.IsError {
|
||||
health.RecordToolError(call.Name, toolLatency, toolResult.Content)
|
||||
} else {
|
||||
health.RecordToolSuccess(call.Name, toolLatency)
|
||||
}
|
||||
}
|
||||
} else if hub != nil && hub.IsConnected(userID) {
|
||||
// Route to browser via WebSocket bridge
|
||||
log.Printf("🔧 Executing tool (browser): %s (call %s)", call.Name, call.ID)
|
||||
@@ -418,8 +433,18 @@ func streamModelResponse(
|
||||
}
|
||||
|
||||
var toolResult tools.ToolResult
|
||||
toolStart := time.Now()
|
||||
if tools.Get(call.Name) != nil {
|
||||
toolResult = tools.ExecuteCall(c.Request.Context(), execCtx, call)
|
||||
// Record tool health (v0.22.4)
|
||||
if health != nil {
|
||||
toolLatency := int(time.Since(toolStart).Milliseconds())
|
||||
if toolResult.IsError {
|
||||
health.RecordToolError(call.Name, toolLatency, toolResult.Content)
|
||||
} else {
|
||||
health.RecordToolSuccess(call.Name, toolLatency)
|
||||
}
|
||||
}
|
||||
} else if hub != nil && hub.IsConnected(userID) {
|
||||
toolResult = executeBrowserTool(hub, userID, call)
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user