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
1 change: 1 addition & 0 deletions cmd/root/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ func newExecCmd() *cobra.Command {

addRunOrExecFlags(cmd, &flags)
addRuntimeConfigFlags(cmd, &flags.runConfig)
cmd.PersistentFlags().BoolVar(&flags.hideToolCalls, "hide-tool-calls", false, "Hide the tool calls in the output")

return cmd
}
Expand Down
4 changes: 4 additions & 0 deletions cmd/root/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ type runExecFlags struct {
modelOverrides []string
dryRun bool
runConfig config.RuntimeConfig

// Exec only
hideToolCalls bool
}

func newRunCmd() *cobra.Command {
Expand Down Expand Up @@ -197,6 +200,7 @@ func (f *runExecFlags) handleExecMode(ctx context.Context, out *cli.Printer, rt
err := cli.Run(ctx, out, cli.Config{
AppName: AppName,
AttachmentPath: f.attachmentPath,
HideToolCalls: f.hideToolCalls,
}, rt, sess, execArgs)
if cliErr, ok := err.(cli.RuntimeError); ok {
return RuntimeError{Err: cliErr.Err}
Expand Down
28 changes: 17 additions & 11 deletions e2e/cagent_exec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,67 +15,73 @@ import (
func TestExec_OpenAI(t *testing.T) {
out := cagentExec(t, "testdata/basic.yaml", "What's 2+2?")

require.Equal(t, "\n--- Agent: root ---\n\n2 + 2 equals 4.", out)
require.Equal(t, "\n--- Agent: root ---\n2 + 2 equals 4.", out)
}

func TestExec_OpenAI_ToolCall(t *testing.T) {
out := cagentExec(t, "testdata/fs_tools.yaml", "How many files in testdata/working_dir? Only output the number.")

require.Equal(t, "\n--- Agent: root ---\n\nCalling search_files(\n path: \"testdata/working_dir\"\n pattern: \"*\"\n)\n\nsearch_files response → \"1 files found:\\ntestdata/working_dir/README.me\"\n\n1", out)
require.Equal(t, "\n--- Agent: root ---\n\nCalling search_files(\n path: \"testdata/working_dir\"\n pattern: \"*\"\n)\n\nsearch_files response → \"1 files found:\\ntestdata/working_dir/README.me\"\n1", out)
}

func TestExec_OpenAI_HideToolCalls(t *testing.T) {
out := cagentExec(t, "testdata/fs_tools.yaml", "--hide-tool-calls", "How many files in testdata/working_dir? Only output the number.")

require.Equal(t, "\n--- Agent: root ---\n1", out)
}

func TestExec_OpenAI_gpt5(t *testing.T) {
out := cagentExec(t, "testdata/basic.yaml", "--model=openai/gpt-5", "What's 2+2?")

require.Equal(t, "\n--- Agent: root ---\n\n4", out)
require.Equal(t, "\n--- Agent: root ---\n4", out)
}

func TestExec_OpenAI_gpt5_1(t *testing.T) {
out := cagentExec(t, "testdata/basic.yaml", "--model=openai/gpt-5.1", "What's 2+2?")

require.Equal(t, "\n--- Agent: root ---\n\n2 + 2 = 4.", out)
require.Equal(t, "\n--- Agent: root ---\n2 + 2 = 4.", out)
}

func TestExec_OpenAI_gpt5_codex(t *testing.T) {
out := cagentExec(t, "testdata/basic.yaml", "--model=openai/gpt-5-codex", "What's 2+2?")

require.Equal(t, "\n--- Agent: root ---\n\n2 + 2 equals 4.", out)
require.Equal(t, "\n--- Agent: root ---\n2 + 2 equals 4.", out)
}

func TestExec_Anthropic(t *testing.T) {
out := cagentExec(t, "testdata/basic.yaml", "--model=anthropic/claude-sonnet-4-0", "What's 2+2?")

require.Equal(t, "\n--- Agent: root ---\n\n2 + 2 = 4", out)
require.Equal(t, "\n--- Agent: root ---\n2 + 2 = 4", out)
}

func TestExec_Anthropic_ToolCall(t *testing.T) {
out := cagentExec(t, "testdata/fs_tools.yaml", "--model=anthropic/claude-sonnet-4-0", "How many files in testdata/working_dir? Only output the number.")

require.Equal(t, "\n--- Agent: root ---\n\nCalling list_directory(path: \"testdata/working_dir\")\n\nlist_directory response → \"FILE README.me\\n\"\n\n1", out)
require.Equal(t, "\n--- Agent: root ---\n\nCalling list_directory(path: \"testdata/working_dir\")\n\nlist_directory response → \"FILE README.me\\n\"\n1", out)
}

func TestExec_Gemini(t *testing.T) {
out := cagentExec(t, "testdata/basic.yaml", "--model=google/gemini-2.5-flash", "What's 2+2?")

require.Equal(t, "\n--- Agent: root ---\n\n2 + 2 = 4", out)
require.Equal(t, "\n--- Agent: root ---\n2 + 2 = 4", out)
}

func TestExec_Gemini_ToolCall(t *testing.T) {
out := cagentExec(t, "testdata/fs_tools.yaml", "--model=google/gemini-2.5-flash", "How many files in testdata/working_dir? Only output the number.")

require.Equal(t, "\n--- Agent: root ---\n\nCalling list_directory(path: \"testdata/working_dir\")\n\nlist_directory response → \"FILE README.me\\n\"\n\n1", out)
require.Equal(t, "\n--- Agent: root ---\n\nCalling list_directory(path: \"testdata/working_dir\")\n\nlist_directory response → \"FILE README.me\\n\"\n1", out)
}

func TestExec_Mistral(t *testing.T) {
out := cagentExec(t, "testdata/basic.yaml", "--model=mistral/mistral-small", "What's 2+2?")

require.Equal(t, "\n--- Agent: root ---\n\nThe sum of 2 + 2 is 4.", out)
require.Equal(t, "\n--- Agent: root ---\nThe sum of 2 + 2 is 4.", out)
}

func TestExec_Mistral_ToolCall(t *testing.T) {
out := cagentExec(t, "testdata/fs_tools.yaml", "--model=mistral/mistral-small", "How many files in testdata/working_dir? Only output the number.")

require.Equal(t, "\n--- Agent: root ---\n\nCalling list_directory(path: \"testdata/working_dir\")\n\nlist_directory response → \"FILE README.me\\n\"\n\n1", out)
require.Equal(t, "\n--- Agent: root ---\n\nCalling list_directory(path: \"testdata/working_dir\")\n\nlist_directory response → \"FILE README.me\\n\"\n1", out)
}

func TestExec_ToolCallsNeedAcceptance(t *testing.T) {
Expand Down
Loading