[BUG] Agent initialization with native langchain tools produce pydantic validation error
Description
Using native langchain tools produce pydantic validation error when initializing an Agent.
Tested on versions 0.80.0 and 0.83.0 both reproduced the bug. Tested on version 0.64.0 and I was able to use native langchain tools to initialize an Agent.
Steps to Reproduce
Run the following code:
from crewai import Agent, Crew, Task
from langchain_community.agent_toolkits.load_tools import load_tools
tools = load_tools(["human"])
# Alternatively I tried this also
# from langchain_community.tools.human.tool import HumanInputRun
# tools = [HumanInputRun()]
def main():
agent = Agent(
role="Learn Person Agent",
goal="Answer questions about a person",
backstory="You answer questions about a person using the human tool.",
tools=tools,
verbose=True,
llm="gpt-4o-mini",
)
task = Task(
name="Learn about person",
description="What's my friend Eric's surname?",
expected_output="my friend's surname",
agent=agent,
)
Crew(
tasks=[task],
agents=[agent],
verbose=True,
).kickoff()
if __name__ == "__main__":
main()
Expected behavior
Crew should run normally using the langchain tool
Screenshots/Code snippets
added above
Operating System
Other (specify in additional context)
Python Version
3.12
crewAI Version
0.83.0 (also tested on 0.80.0)
crewAI Tools Version
N/A
Virtual Environment
Venv
Evidence
The error I get:
...
File ".../test.py", line 38, in <module>
main()
File ".../test.py", line 12, in main
agent = Agent(
^^^^^^
File ".../.venv/lib/python3.12/site-packages/pydantic/main.py", line 214, in __init__
validated_self = self.__pydantic_validator__.validate_python(data, self_instance=self)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pydantic_core._pydantic_core.ValidationError: 1 validation error for Agent
tools.0
Input should be a valid dictionary or instance of BaseTool [type=model_type, input_value=HumanInputRun(prompt_func...uilt-in function input>), input_type=HumanInputRun]
For further information visit https://errors.pydantic.dev/2.10/v/model_type
Possible Solution
None
Additional context
MAC Sequia
I too had a similar issue issue 1649 with multiple arguments.
Nobody even responded to it .At last i had to stop my project and move to langgraph
Thanks @Harshal292004 ! I just realized it's a different issue than the one you raised, I am having a problem initializing an Agent, in your issue it seems like your agent and crew are kicking off as expected and you have some other error in using the tool by the agent.
It might be related but it's a different bug.
@MahlerTom I just solved this issue on the official forum. Feel free to take a look.
@rokbenko Thanks thats a great solution!
I do wonder why crewai stopped supporting langchain tools natively, and if this could change anytime soon. On the official crewai documentation (and example) it sais:
CrewAI seamlessly integrates with LangChain’s comprehensive list of tools, all of which can be used with CrewAI.
This issue is stale because it has been open for 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.
This issue was closed because it has been stalled for 5 days with no activity.