Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Tool name validation based on open ai Schema for tool names
Note: In case of Agent as Tool. This doesnt work if it tool is a Tool for Agent as tool. Only check when the agent as tool is invoked.
This pull request introduces changes to the agent validation and creation process in the
src/backend/base/langflow/base/agents/agent.py
file. The most important changes include the addition of a tool name validation method and its integration into the agent-building process.Agent Validation and Creation Improvements:
src/backend/base/langflow/base/agents/agent.py
: Added a new methodvalidate_tool_names
to ensure tool names match a specific pattern using regular expressions. This method checks that tool names contain only letters, numbers, underscores, and dashes, and do not contain spaces.src/backend/base/langflow/base/agents/agent.py
: Integrated thevalidate_tool_names
method into thebuild_agent
method of theLCToolsAgentComponent
class to validate tool names during agent construction.src/backend/base/langflow/components/langchain_utilities/tool_calling.py
: Added a call tovalidate_tool_names
in thecreate_agent_runnable
method to ensure tool names are validated before creating the tool-calling agent.Miscellaneous:
src/backend/base/langflow/base/agents/agent.py
: Imported there
module to support regular expression operations for tool name validation.