Conversation
| result2 = agent_executor.invoke({ | ||
| "input": "Calculate a 18% tip on a $45.50 bill" | ||
| }) | ||
| result2 = agent.invoke({"input": "Calculate a 18% tip on a $45.50 bill"}) |
There was a problem hiding this comment.
Bug: create_agent expects {"messages": ...} input, but test-langchain2/main_tool.py:51 and 57-59 use {"input": ...}, causing a KeyError.
Severity: CRITICAL | Confidence: 0.95
🔍 Detailed Analysis
The create_agent function in LangChain v1 expects input in a {"messages": [{"role": "user", "content": "..."}]} format. At test-langchain2/main_tool.py:51 and test-langchain2/main_tool.py:57-59, the agent is invoked with an outdated {"input": "..."} format. This mismatch will cause the agent to not find the expected messages key, leading to a KeyError or ValidationError during execution.
💡 Suggested Fix
Update the input format at test-langchain2/main_tool.py:51 and test-langchain2/main_tool.py:57-59 from {"input": "..."} to {"messages": [{"role": "user", "content": "..."}]} to match LangChain v1's create_agent expectations.
🤖 Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.
Location: test-langchain2/main_tool.py#L51
Potential issue: The `create_agent` function in LangChain v1 expects input in a
`{"messages": [{"role": "user", "content": "..."}]}` format. At
`test-langchain2/main_tool.py:51` and `test-langchain2/main_tool.py:57-59`, the agent is
invoked with an outdated `{"input": "..."}` format. This mismatch will cause the agent
to not find the expected `messages` key, leading to a `KeyError` or `ValidationError`
during execution.
Did we get this right? 👍 / 👎 to inform future reviews.
Closes https://linear.app/getsentry/issue/TET-1340/update-langchain-integration-for-v1