feat(agent): enhance streaming diagnostics and event tracking
- Added diagnostics for streaming events in the AgentEngine, including chunk counts and response type distributions. - Implemented logging for emitted event types during the thinking process to aid in debugging and performance analysis. - Updated the session handler to provide more informative warnings when fallback answers are emitted due to non-streaming behavior. - Introduced a dedicated HTTP client for Ollama to improve connection handling and timeout management during streaming calls.
This commit is contained in:
@@ -227,7 +227,17 @@ func (c *OllamaChat) ChatStream(
|
||||
Done: false,
|
||||
}
|
||||
|
||||
// Extract and stream content from special tools (complete, not incremental)
|
||||
// Ollama returns tool calls as complete objects (not incremental deltas).
|
||||
// Log this so we can trace non-streaming answer delivery.
|
||||
for _, tc := range resp.Message.ToolCalls {
|
||||
if tc.Function.Name == "final_answer" || tc.Function.Name == "thinking" {
|
||||
argsBytes, _ := json.Marshal(tc.Function.Arguments)
|
||||
logger.Warnf(ctx, "[Ollama Stream] Tool %q arrived non-incrementally (%d bytes args), "+
|
||||
"answer will not be token-streamed to frontend",
|
||||
tc.Function.Name, len(argsBytes))
|
||||
}
|
||||
}
|
||||
|
||||
for _, tc := range resp.Message.ToolCalls {
|
||||
switch tc.Function.Name {
|
||||
case "final_answer":
|
||||
|
||||
Reference in New Issue
Block a user