hibam1
add script to run dynamic tool agent
df07284
Raw History Blame Contribute Delete
838 Bytes
from .state import AgentState, tools_config
def validate_tool(state: AgentState):
selected_tool = state["selected_tool"]
# Find selected tool configuration
tool = next(
(t for t in tools_config
if t["name"] == selected_tool),
None
)
if tool is None:
return {
"tool_args": {},
"missing_params": []
}
global_params = state["global_params"]
tool_args = {}
missing = []
for param in tool["parameters"]:
name = param["name"]
required = param["required"]
value = global_params.get(name)
if value is None:
if required:
missing.append(name)
else:
tool_args[name] = value
return {
"tool_args": tool_args,
"missing_params": missing
}