@@ -135,6 +135,42 @@ func TestExecWithToolList(t *testing.T) {
135
135
}
136
136
}
137
137
138
+ func TestExecWithToolListAndSubTool (t * testing.T ) {
139
+ shebang := "#!/bin/bash"
140
+ if runtime .GOOS == "windows" {
141
+ shebang = "#!/usr/bin/env powershell.exe"
142
+ }
143
+ tools := []fmt.Stringer {
144
+ & Tool {
145
+ Tools : []string {"echo" },
146
+ Instructions : "echo hello there" ,
147
+ },
148
+ & Tool {
149
+ Name : "other" ,
150
+ Tools : []string {"echo" },
151
+ Instructions : "echo hello somewhere else" ,
152
+ },
153
+ & Tool {
154
+ Name : "echo" ,
155
+ Tools : []string {"sys.exec" },
156
+ Description : "Echoes the input" ,
157
+ Args : map [string ]string {
158
+ "input" : "The string input to echo" ,
159
+ },
160
+ Instructions : shebang + "\n echo ${input}" ,
161
+ },
162
+ }
163
+
164
+ out , err := ExecTool (context .Background (), Opts {SubTool : "other" }, tools ... )
165
+ if err != nil {
166
+ t .Errorf ("Error executing tool: %v" , err )
167
+ }
168
+
169
+ if ! strings .Contains (out , "hello somewhere else" ) {
170
+ t .Errorf ("Unexpected output: %s" , out )
171
+ }
172
+ }
173
+
138
174
func TestStreamExec (t * testing.T ) {
139
175
tool := & FreeForm {Content : "What is the capital of the united states?" }
140
176
0 commit comments