Pydantic 2 compatibility change has broken Playwright's NavigateBackTool, CurrentWebPageTool and ExtractTextTool #26758
Labels
🤖:bug
Related to a bug, vulnerability, unexpected error with an existing feature
investigate
Flagged for investigation.
Checked other resources
Example Code
The following code, with an OpenAI key specified at the TODO
Error Message and Stack Trace (if applicable)
Description
Note: The following is written for NavigateBackTool (where I first discovered the problem) but is the same for ExtractTextTool and CurrentWebPageTool.
The final line of the code above fails with the error message given. It fails in some sense because the
args_schema
of theNavigateBackTool
claims to support a field 'data' which it actually does not (briefly, the code seems to get a list of properties which can be queried and then query them and there's a mismatch here). My guess is that this is a version mismatch between v1 and v2 of pydantic but I could be wrong (I am not a pydantic expert). I believe this was introduced in PR [0].Looking at
navigate_back.py
I can see that the import of BaseModel has changed e.g. from [1] to [2], where [1] was explicitly including the v1 version of BaseModel (albeit from langchain_core) and 2 pulls from pydantic.BaseModel.Other tools e.g. ClickTool don't have this problem, because they override BaseModel to provide and explicit "Input" class. I have confirmed that creating such a class is a workaround for this issue. FWIW I think there's a strong argument that making this empty set of params explicit and not implicit is better anyway.
Apologies that this isn't the most complete explanation but I hope it's enough for someone in the know to understand what's going in detail much more quickly than it would take me to understand exactly why e.g. 'data' is listed as a field when not actually present :) I have found [3] to be a great place to set a breakpoint to understand this.
[0] #26443
[1] https://api.python.langchain.com/en/latest/_modules/langchain_community/tools/playwright/navigate_back.html#NavigateBackTool
[2] https://github.com/langchain-ai/langchain/blob/master/libs/community/langchain_community/tools/playwright/navigate_back.py
[3] Property method
tool_call_schema
in VENV_PATH/lib/python3.12/site-packages/langchain_core/tools/base.pySystem Info
The text was updated successfully, but these errors were encountered: