Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions pkg/agent/conversation.go
Original file line number Diff line number Diff line change
Expand Up @@ -519,22 +519,22 @@ func (c *Agent) Run(ctx context.Context, initialQuery string) error {
break
}

candidate := response.Candidates()[0]

for _, part := range candidate.Parts() {
// Check if it's a text response
if text, ok := part.AsText(); ok {
log.Info("text response", "text", text)
streamedText += text
}
// Aggregate across all candidates to avoid missing tool calls
for _, candidate := range response.Candidates() {
for _, part := range candidate.Parts() {
// Check if it's a text response
if text, ok := part.AsText(); ok {
log.Info("text response", "text", text)
streamedText += text
}

// Check if it's a function call
if calls, ok := part.AsFunctionCalls(); ok && len(calls) > 0 {
log.Info("function calls", "calls", calls)
functionCalls = append(functionCalls, calls...)
// Check if it's a function call
if calls, ok := part.AsFunctionCalls(); ok && len(calls) > 0 {
log.Info("function calls", "calls", calls)
functionCalls = append(functionCalls, calls...)
}
}
}
}
if llmError != nil {
log.Error(llmError, "error streaming LLM response")
c.setAgentState(api.AgentStateDone)
Expand Down