refactor: enhance event consumption logic and add graph tool completion test
This commit is contained in:
@@ -74,6 +74,8 @@ func consumeAgentEvents(events *adk.AsyncIterator[*adk.AgentEvent], summary *Run
|
||||
summary.Status = "interrupted"
|
||||
case strings.TrimSpace(summary.ReplyText) != "":
|
||||
summary.Status = "completed"
|
||||
case hasInvokedGraphTool(summary.InvokedToolCodes):
|
||||
summary.Status = "completed"
|
||||
default:
|
||||
summary.Status = "fallback"
|
||||
}
|
||||
@@ -81,6 +83,15 @@ func consumeAgentEvents(events *adk.AsyncIterator[*adk.AgentEvent], summary *Run
|
||||
summary.ToolCallCount = len(summary.InvokedToolCodes)
|
||||
}
|
||||
|
||||
func hasInvokedGraphTool(toolCodes []string) bool {
|
||||
for _, toolCode := range toolCodes {
|
||||
if toolx.ResolveToolSourceType(toolCode) == enums.ToolSourceTypeGraph {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func buildInterruptSummaries(event *adk.AgentEvent) []InterruptContextSummary {
|
||||
if event == nil || event.Action == nil || event.Action.Interrupted == nil {
|
||||
return nil
|
||||
|
||||
Reference in New Issue
Block a user