mirror of
https://github.com/Xe138/AI-Trader.git
synced 2026-04-02 01:27:24 -04:00
Root cause identified: langchain_core's parse_tool_call() sometimes returns tool_calls with 'args' as a JSON string instead of parsed dict object. This violates AIMessage's Pydantic schema which expects args to be dict. Solution: Wrapper now detects when parse_tool_call returns string args and immediately converts them to dict using json.loads(). This is a workaround for what appears to be a LangChain bug where parse_tool_call's json.loads() call either: 1. Fails silently without raising exception, or 2. Succeeds but result is not being assigned to args field The fix ensures AIMessage always receives properly parsed dict args, resolving Pydantic validation errors for all DeepSeek tool calls.