Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion .github/data/agent-framework/run-challenge.sh
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ log "Trying to fix the kagent broken environment using Kagent..."
touch "${scenario_dir}/$NAME.thought.log"
mkdir -p "${scenario_dir}/results"

timeout --signal=INT 3m bash -c 'echo "$1" | kagent invoke --agent "k8s-agent" --task -' -- "$USER_PROMPT" > "${scenario_dir}/$NAME.thought.log" 2>&1
timeout --signal=INT 3m bash -c 'echo "$1" | kagent invoke -v --agent "k8s-agent" -S --task -' -- "$USER_PROMPT" > "${scenario_dir}/results/$NAME.thought.log" 2>&1

TIMEOUT_STATUS=$?
if [ $TIMEOUT_STATUS -eq 124 ]; then
Expand Down
67 changes: 41 additions & 26 deletions go/cli/internal/cli/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,16 +200,34 @@ func StreamEvents(ch <-chan *autogen_client.SseEvent, usage *autogen_client.Mode
if typed.Source == "user" || typed.Source == "system" {
continue
}
fmt.Fprintf(os.Stdout, "%s: %s\n", config.BoldYellow("Event Type"), "TextMessage")
fmt.Fprintf(os.Stdout, "%s: %s\n", config.BoldGreen("Source"), typed.Source)
fmt.Fprintln(os.Stdout)
fmt.Fprintln(os.Stdout, typed.Content)
fmt.Fprintln(os.Stdout, "----------------------------------")
fmt.Fprintln(os.Stdout)
if verbose {
enc := json.NewEncoder(os.Stdout)
enc.SetIndent("", " ")
if err := enc.Encode(typed); err != nil {
fmt.Fprintf(os.Stderr, "Error encoding event: %v\n", err)
continue
}
} else {
fmt.Fprintf(os.Stdout, "%s: %s\n", config.BoldYellow("Event Type"), "TextMessage")
fmt.Fprintf(os.Stdout, "%s: %s\n", config.BoldGreen("Source"), typed.Source)
fmt.Fprintln(os.Stdout)
fmt.Fprintln(os.Stdout, typed.Content)
fmt.Fprintln(os.Stdout, "----------------------------------")
fmt.Fprintln(os.Stdout)
}
case *ModelClientStreamingChunkEvent:
usage.Add(typed.ModelsUsage)
streaming[typed.Source] = true
fmt.Fprintf(os.Stdout, "%s", typed.Content)
if verbose {
enc := json.NewEncoder(os.Stdout)
enc.SetIndent("", " ")
if err := enc.Encode(typed); err != nil {
fmt.Fprintf(os.Stderr, "Error encoding event: %v\n", err)
continue
}
} else {
fmt.Fprintf(os.Stdout, "%s", typed.Content)
}
case *ToolCallRequestEvent:
bufferedToolCallRequest = typed
case *ToolCallExecutionEvent:
Expand All @@ -218,26 +236,20 @@ func StreamEvents(ch <-chan *autogen_client.SseEvent, usage *autogen_client.Mode
continue
}
usage.Add(typed.ModelsUsage)
fmt.Fprintf(os.Stdout, "%s: %s\n", config.BoldYellow("Event Type"), "ToolCall(s)")
fmt.Fprintf(os.Stdout, "%s: %s\n", config.BoldGreen("Source"), typed.Source)
if verbose {
// For each function execution, find the corresponding tool call request and print them together
for i, functionExecution := range typed.Content {
for _, functionRequest := range bufferedToolCallRequest.Content {
if functionExecution.CallID == functionRequest.ID {
fmt.Fprintln(os.Stdout)
fmt.Fprintln(os.Stdout, "++++++++")
fmt.Fprintf(os.Stdout, "Tool Call %d: (id: %s)\n", i, functionRequest.ID)
fmt.Fprintln(os.Stdout)
fmt.Fprintf(os.Stdout, "%s(%s)\n", functionRequest.Name, functionRequest.Arguments)
fmt.Fprintln(os.Stdout)
fmt.Fprintln(os.Stdout, functionExecution.Content)
fmt.Fprintln(os.Stdout, "++++++++")
fmt.Fprintln(os.Stdout)
}
}
enc := json.NewEncoder(os.Stdout)
out := map[string]interface{}{
"request": bufferedToolCallRequest,
"execution": typed,
}
enc.SetIndent("", " ")
if err := enc.Encode(out); err != nil {
fmt.Fprintf(os.Stderr, "Error encoding event: %v\n", err)
continue
}
} else {
fmt.Fprintf(os.Stdout, "%s: %s\n", config.BoldYellow("Event Type"), "ToolCall(s)")
fmt.Fprintf(os.Stdout, "%s: %s\n", config.BoldGreen("Source"), typed.Source)
tw := table.NewWriter()
tw.AppendHeader(table.Row{"#", "Name", "Arguments"})
for idx, functionRequest := range bufferedToolCallRequest.Content {
Expand All @@ -246,8 +258,11 @@ func StreamEvents(ch <-chan *autogen_client.SseEvent, usage *autogen_client.Mode
fmt.Fprintln(os.Stdout, tw.Render())
}

fmt.Fprintln(os.Stdout, "----------------------------------")
fmt.Fprintln(os.Stdout)
if !verbose {
fmt.Fprintln(os.Stdout, "----------------------------------")
fmt.Fprintln(os.Stdout)
}

bufferedToolCallRequest = nil
}
}
Expand Down
Loading