MCPcopy Create free account
hub / github.com/ScaleML/AgentSPEX / _invoke_submodule_tool

Method _invoke_submodule_tool

src/harness/execution/llm_executor.py:259–375  ·  view source on GitHub ↗

Invoke a submodule as a tool call. Looks up the submodule specification, resolves parameters from context and tool arguments, then executes the submodule workflow. Args: tool_name: Name of the submodule to invoke. tool_args: Arguments passed by the L

(
        self,
        tool_name: str,
        tool_args: Dict[str, Any],
        context: Dict[str, Any],
        args: EffectiveArgs,
        logger: Logger,
        step_id: Union[int, str],
        parent_step_id: Optional[Union[int, str]] = None,
        parent_iteration: Optional[int] = None,
    )

Source from the content-addressed store, hash-verified

257 )
258
259 def _invoke_submodule_tool(
260 self,
261 tool_name: str,
262 tool_args: Dict[str, Any],
263 context: Dict[str, Any],
264 args: EffectiveArgs,
265 logger: Logger,
266 step_id: Union[int, str],
267 parent_step_id: Optional[Union[int, str]] = None,
268 parent_iteration: Optional[int] = None,
269 ) -> Dict[str, Any]:
270 """Invoke a submodule as a tool call.
271
272 Looks up the submodule specification, resolves parameters from context
273 and tool arguments, then executes the submodule workflow.
274
275 Args:
276 tool_name: Name of the submodule to invoke.
277 tool_args: Arguments passed by the LLM.
278 context: Current workflow context.
279 args: Effective arguments for LLM configuration.
280 logger: Logger instance for output.
281 step_id: Identifier for this invocation.
282 parent_step_id: ID of the calling step (for logging).
283 parent_iteration: Iteration number in parent loop (for logging).
284
285 Returns:
286 Dict with 'result' and 'tokens' keys.
287
288 Raises:
289 ValueError: If submodule not found or required parameters missing.
290 """
291 registry = context.get("submodule_registry", {})
292 spec = registry.get(tool_name)
293 if not spec:
294 raise ValueError(f"Unknown submodule tool: {tool_name}")
295
296 params: Dict[str, Any] = {}
297 missing = []
298
299 for p in spec.context_params:
300 if p.name in context:
301 params[p.name] = context[p.name]
302 elif p.default is not None:
303 params[p.name] = p.default
304 elif p.required:
305 missing.append(p.name)
306
307 for p in spec.model_params:
308 if p.name in tool_args:
309 params[p.name] = tool_args[p.name]
310 elif p.default is not None:
311 params[p.name] = p.default
312 elif p.required:
313 missing.append(p.name)
314
315 if missing:
316 raise ValueError(

Callers 1

Calls 4

get_step_depthFunction · 0.85
getMethod · 0.80
log_eventMethod · 0.80
execute_call_stepMethod · 0.80

Tested by

no test coverage detected