@@ -2,12 +2,14 @@ package builtin
22
33import (
44 "encoding/json"
5+ "os"
56 "testing"
67
78 "github.com/stretchr/testify/assert"
89 "github.com/stretchr/testify/require"
910
1011 "github.com/docker/docker-agent/pkg/config/latest"
12+ "github.com/docker/docker-agent/pkg/tools"
1113)
1214
1315func TestNewScriptShellTool_Empty (t * testing.T ) {
@@ -116,6 +118,43 @@ func TestNewScriptShellTool_MissingRequired(t *testing.T) {
116118 require .ErrorContains (t , err , "tool 'docker_images' has required arg 'img' which is not defined in args" )
117119}
118120
121+ func TestNewScriptShellTool_NumberArg (t * testing.T ) {
122+ shellTools := map [string ]latest.ScriptShellToolConfig {
123+ "repeat" : {
124+ Description : "Repeat a message N times" ,
125+ Cmd : "for i in $(seq 1 $count); do echo $message; done" ,
126+ Args : map [string ]any {
127+ "message" : map [string ]any {
128+ "description" : "Message to repeat" ,
129+ "type" : "string" ,
130+ },
131+ "count" : map [string ]any {
132+ "description" : "Number of repetitions" ,
133+ "type" : "number" ,
134+ },
135+ },
136+ Required : []string {"message" , "count" },
137+ },
138+ }
139+
140+ tool , err := NewScriptShellTool (shellTools , os .Environ ())
141+ require .NoError (t , err )
142+
143+ allTools , err := tool .Tools (t .Context ())
144+ require .NoError (t , err )
145+ require .Len (t , allTools , 1 )
146+
147+ // Simulate LLM sending a number argument (JSON numbers are float64)
148+ result , err := allTools [0 ].Handler (t .Context (), tools.ToolCall {
149+ Function : tools.FunctionCall {
150+ Arguments : `{"message": "hello", "count": 3}` ,
151+ },
152+ })
153+ require .NoError (t , err )
154+ assert .False (t , result .IsError , "unexpected error: %s" , result .Output )
155+ assert .Equal (t , "hello\n hello\n hello\n " , result .Output )
156+ }
157+
119158func TestNewScriptShellTool_ArgWithoutType (t * testing.T ) {
120159 shellTools := map [string ]latest.ScriptShellToolConfig {
121160 "greet" : {
0 commit comments