langchain[patch]: Remove multiagent return_direct validation (#24419)

**Description:**

When you use Agents with multi-input tool and some of these tools have
`return_direct=True`, langchain thrown an error related to one
validator.
This change is implemented on [JS
community](https://github.com/langchain-ai/langchainjs/pull/4643) as
well

**Issue**:
This MR resolves #19843

**Dependencies:**

None

Co-authored-by: Jesus Martinez <jesusabraham.martinez@tyson.com>
Co-authored-by: Bagatur <22008038+baskaryan@users.noreply.github.com>
This commit is contained in:
Jesus Martinez 2024-07-19 21:27:43 -06:00 committed by GitHub
parent 74e3d796f1
commit c1d1fc13c2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1146,30 +1146,6 @@ class AgentExecutor(Chain):
)
return values
@root_validator(pre=False, skip_on_failure=True)
def validate_return_direct_tool(cls, values: Dict) -> Dict:
"""Validate that tools are compatible with agent.
Args:
values: Values to validate.
Returns:
Dict: Validated values.
Raises:
ValueError: If tools that have `return_direct=True` are not allowed.
"""
agent = values["agent"]
tools = values["tools"]
if isinstance(agent, BaseMultiActionAgent):
for tool in tools:
if tool.return_direct:
raise ValueError(
"Tools that have `return_direct=True` are not allowed "
"in multi-action agents"
)
return values
@root_validator(pre=True)
def validate_runnable_agent(cls, values: Dict) -> Dict:
"""Convert runnable to agent if passed in.