@@ -119,3 +119,51 @@ func TestWithToolsFilter_CaseSensitive(t *testing.T) {
119119 require .Len (t , result , 1 )
120120 assert .Equal (t , "tool1" , result [0 ].Name )
121121}
122+
123+ type instructableToolSet struct {
124+ mockToolSet
125+ instructions string
126+ }
127+
128+ func (i * instructableToolSet ) Instructions () string {
129+ return i .instructions
130+ }
131+
132+ func TestWithToolsFilter_InstructablePassthrough (t * testing.T ) {
133+ // Test that filtering preserves instructions from inner toolset
134+ inner := & instructableToolSet {
135+ mockToolSet : mockToolSet {
136+ toolsFunc : func (context.Context ) ([]tools.Tool , error ) {
137+ return []tools.Tool {{Name : "tool1" }, {Name : "tool2" }}, nil
138+ },
139+ },
140+ instructions : "Test instructions for the toolset" ,
141+ }
142+
143+ wrapped := WithToolsFilter (inner , "tool1" )
144+
145+ // Verify instructions are preserved through the filter wrapper
146+ instructions := tools .GetInstructions (wrapped )
147+ assert .Equal (t , "Test instructions for the toolset" , instructions )
148+
149+ // Verify filtering still works
150+ result , err := wrapped .Tools (t .Context ())
151+ require .NoError (t , err )
152+ require .Len (t , result , 1 )
153+ assert .Equal (t , "tool1" , result [0 ].Name )
154+ }
155+
156+ func TestWithToolsFilter_NonInstructableInner (t * testing.T ) {
157+ // Test that filter works with toolsets that don't implement Instructable
158+ inner := & mockToolSet {
159+ toolsFunc : func (context.Context ) ([]tools.Tool , error ) {
160+ return []tools.Tool {{Name : "tool1" }}, nil
161+ },
162+ }
163+
164+ wrapped := WithToolsFilter (inner , "tool1" )
165+
166+ // Verify instructions are empty for non-instructable inner toolset
167+ instructions := tools .GetInstructions (wrapped )
168+ assert .Empty (t , instructions )
169+ }
0 commit comments