Skip to content
Draft
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
4 changes: 2 additions & 2 deletions e2e/cagent_exec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func TestExec_OpenAI(t *testing.T) {
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\"\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_OpenAI_HideToolCalls(t *testing.T) {
Expand Down Expand Up @@ -81,7 +81,7 @@ func TestExec_Mistral(t *testing.T) {
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\"\n1", out)
require.Equal(t, "\n--- Agent: root ---\n\nCalling list_directory(path: \"testdata/working_dir\")\n\nlist_directory response → \"FILE README.me\\n\"\n2", out)
}

func TestExec_ToolCallsNeedAcceptance(t *testing.T) {
Expand Down
128 changes: 88 additions & 40 deletions e2e/testdata/cassettes/TestExec_Anthropic_ToolCall.yaml

Large diffs are not rendered by default.

94 changes: 48 additions & 46 deletions e2e/testdata/cassettes/TestExec_Gemini_ToolCall.yaml

Large diffs are not rendered by default.

94 changes: 54 additions & 40 deletions e2e/testdata/cassettes/TestExec_Mistral_ToolCall.yaml

Large diffs are not rendered by default.

116 changes: 76 additions & 40 deletions e2e/testdata/cassettes/TestExec_OpenAI_HideToolCalls.yaml

Large diffs are not rendered by default.

116 changes: 76 additions & 40 deletions e2e/testdata/cassettes/TestExec_OpenAI_ToolCall.yaml

Large diffs are not rendered by default.

122 changes: 82 additions & 40 deletions e2e/testdata/cassettes/TestExec_ToolCallsNeedAcceptance.yaml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pkg/acp/filesystem.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ var _ tools.ToolSet = (*FilesystemToolset)(nil)
// NewFilesystemToolset creates a new ACP-specific filesystem toolset
func NewFilesystemToolset(agent *Agent, workingDir string, opts ...builtin.FileSystemOpt) *FilesystemToolset {
return &FilesystemToolset{
FilesystemTool: builtin.NewFilesystemTool([]string{workingDir}, opts...),
FilesystemTool: builtin.NewFilesystemTool(workingDir, opts...),
agent: agent,
workindgDir: workingDir,
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/creator/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ Can you explain to me what the agent will be used for?`,

// Custom tool registry to include fsToolset
fsToolset := fsToolset{
inner: builtin.NewFilesystemTool([]string{runConfig.WorkingDir}),
inner: builtin.NewFilesystemTool(runConfig.WorkingDir),
}

registry := teamloader.NewDefaultToolsetRegistry()
Expand Down
2 changes: 1 addition & 1 deletion pkg/fsx/collect.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func CollectFiles(paths []string, shouldIgnore func(path string) bool) ([]string

if info.IsDir() {
// Use DirectoryTree to collect files from directory
tree, err := DirectoryTree(normalized, func(string) error { return nil }, shouldIgnore, 0)
tree, err := DirectoryTree(normalized, shouldIgnore, 0)
if err != nil {
return nil, fmt.Errorf("failed to read directory %s: %w", normalized, err)
}
Expand Down
14 changes: 5 additions & 9 deletions pkg/fsx/fs.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ type TreeNode struct {
Children []*TreeNode `json:"children,omitempty"`
}

func DirectoryTree(path string, isPathAllowed func(string) error, shouldIgnore func(string) bool, maxItems int) (*TreeNode, error) {
func DirectoryTree(path string, shouldIgnore func(string) bool, maxItems int) (*TreeNode, error) {
itemCount := 0
return directoryTree(path, isPathAllowed, shouldIgnore, maxItems, &itemCount)
return directoryTree(path, shouldIgnore, maxItems, &itemCount)
}

func directoryTree(path string, isPathAllowed func(string) error, shouldIgnore func(string) bool, maxItems int, itemCount *int) (*TreeNode, error) {
func directoryTree(path string, shouldIgnore func(string) bool, maxItems int, itemCount *int) (*TreeNode, error) {
if maxItems > 0 && *itemCount >= maxItems {
return nil, nil
}
Expand Down Expand Up @@ -44,16 +44,12 @@ func directoryTree(path string, isPathAllowed func(string) error, shouldIgnore f

for _, entry := range entries {
childPath := filepath.Join(path, entry.Name())
if err := isPathAllowed(childPath); err != nil {
continue // Skip disallowed paths
}

// Skip if should be ignored (VCS, gitignore, etc.)
if shouldIgnore != nil && shouldIgnore(childPath) {
continue
}

childNode, err := directoryTree(childPath, isPathAllowed, shouldIgnore, maxItems, itemCount)
childNode, err := directoryTree(childPath, shouldIgnore, maxItems, itemCount)
if err != nil || childNode == nil {
continue
}
Expand All @@ -65,7 +61,7 @@ func directoryTree(path string, isPathAllowed func(string) error, shouldIgnore f
}

func ListDirectory(path string, shouldIgnore func(string) bool) ([]string, error) {
tree, err := DirectoryTree(path, func(string) error { return nil }, shouldIgnore, 0)
tree, err := DirectoryTree(path, shouldIgnore, 0)
if err != nil {
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/teamloader/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ func createFilesystemTool(_ context.Context, toolset latest.Toolset, _ string, r
opts = append(opts, builtin.WithPostEditCommands(postEditConfigs))
}

return builtin.NewFilesystemTool([]string{wd}, opts...), nil
return builtin.NewFilesystemTool(wd, opts...), nil
}

func createAPITool(ctx context.Context, toolset latest.Toolset, _ string, runConfig *config.RuntimeConfig) (tools.ToolSet, error) {
Expand Down
Loading