File tree Expand file tree Collapse file tree 2 files changed +24
-3
lines changed
Expand file tree Collapse file tree 2 files changed +24
-3
lines changed Original file line number Diff line number Diff line change @@ -183,23 +183,26 @@ def get_inputs(self) -> dict[str, t.Any]:
183183 Get the input names for the agent with their default values if set.
184184 """
185185 input_names = set ()
186+ tools_names = [t .name if isinstance (t , Tool ) else t .__name__ for t in self .tools ]
186187
187188 # from the system prompt
188189 if self .agent :
189190 for input_name in self ._get_inputs_from_string (self .agent ):
190- input_names .add (input_name )
191+ if input_name not in tools_names :
192+ input_names .add (input_name )
191193
192194 # from the task prompt
193195 if self .task :
194196 for input_name in self ._get_inputs_from_string (self .task ):
195- input_names .add (input_name )
197+ if input_name not in tools_names :
198+ input_names .add (input_name )
196199
197200 # from the tools
198201 for tool in self .tools :
199202 if isinstance (tool , Tool ) and tool .tool :
200203 arg_names = [arg .name for arg in tool .arguments ]
201204 for input_name in self ._get_inputs_from_string (tool .tool ):
202- if input_name not in arg_names :
205+ if input_name not in arg_names and input_name not in tools_names :
203206 input_names .add (input_name )
204207
205208 if not self .task :
Original file line number Diff line number Diff line change @@ -119,3 +119,21 @@ def test_get_inputs_includes_task_when_task_not_set(self) -> None:
119119
120120 self .assertIn ("task" , inputs )
121121 self .assertIn ("input1" , inputs )
122+
123+ def test_get_inputs_ignores_interpolated_tool_calls (self ) -> None :
124+ """Test that get_inputs doesn't extract variables from interpolated tool calls"""
125+ config = Configuration (
126+ agent = "I am an agent" ,
127+ task = "Complete the task using {{tool_name(param='value')}} and {{input1}}" ,
128+ tools = [
129+ Tool (
130+ name = "tool_name" ,
131+ description = "A test tool" ,
132+ )
133+ ],
134+ )
135+ inputs = config .get_inputs ()
136+
137+ self .assertIn ("input1" , inputs )
138+ self .assertNotIn ("tool_name" , inputs ) # Should be excluded as it's a tool
139+ self .assertNotIn ("param" , inputs ) # Should be excluded as it's a parameter to a tool call
You can’t perform that action at this time.
0 commit comments