From 74a4a2eebfb34673b57d5b23eb846034a4d99cef Mon Sep 17 00:00:00 2001 From: Eitan Yarmush Date: Fri, 23 May 2025 20:37:21 +0000 Subject: [PATCH 1/3] record thoughts --- .github/data/agent-framework/run-challenge.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/data/agent-framework/run-challenge.sh b/.github/data/agent-framework/run-challenge.sh index 197fdd36f..ea0f9c137 100755 --- a/.github/data/agent-framework/run-challenge.sh +++ b/.github/data/agent-framework/run-challenge.sh @@ -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 --agent "k8s-agent" -S --task -' -- "$USER_PROMPT" > "${scenario_dir}/results/$NAME.thought.log" 2>&1 TIMEOUT_STATUS=$? if [ $TIMEOUT_STATUS -eq 124 ]; then From 87bf7fe4fb8c385eb68629bbf2c282e07dfdf255 Mon Sep 17 00:00:00 2001 From: Eitan Yarmush Date: Wed, 28 May 2025 17:34:56 +0000 Subject: [PATCH 2/3] added json outputs for testing --- go/cli/internal/cli/utils.go | 67 ++++++++++++++++++++++-------------- 1 file changed, 41 insertions(+), 26 deletions(-) diff --git a/go/cli/internal/cli/utils.go b/go/cli/internal/cli/utils.go index 61fd140be..634ada730 100644 --- a/go/cli/internal/cli/utils.go +++ b/go/cli/internal/cli/utils.go @@ -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: @@ -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 { @@ -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 } } From 366d64e5f973a4d02d4541b4116dab1dcbcbcae2 Mon Sep 17 00:00:00 2001 From: Eitan Yarmush Date: Wed, 28 May 2025 17:37:07 +0000 Subject: [PATCH 3/3] verbose --- .github/data/agent-framework/run-challenge.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/data/agent-framework/run-challenge.sh b/.github/data/agent-framework/run-challenge.sh index ea0f9c137..50a376402 100755 --- a/.github/data/agent-framework/run-challenge.sh +++ b/.github/data/agent-framework/run-challenge.sh @@ -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" -S --task -' -- "$USER_PROMPT" > "${scenario_dir}/results/$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