AstraDB + Tool Calling Agent + Retriever tool - does not work after upgrade to v1.1
Bug Description
I am using a tool calling agent to retrieve information from 3 tools based on logic.
If Q is about X got to tool X and so on...
This worked absolutely fine until I upgraded to v1.1
I have managed to get it tested it and working in Datastax environment before moving to my own environment. In Datastax environment still works fine, but in my environment I get the following error in the tool calling agent:
TypeError: AstraDBVectorStore.asimilarity_search() got multiple values for argument 'query'
- I have checked the workflows, they are identical.
- I have checked the endpoints/tokens/settings - all identical
- I had an error in Datastax environment where it would not accept the Azure OpenAI embeddings node on the DX Astra DB node, and had to use Astra vectorise option. I have tried both options on my environment, both build successfully, but still the same error.
- I have rebuild and created all the nodes, as I had problems before and this solved the problem.
- I have a separate instance with the old version in parallel that works with the database, so there is no problem there.
- I have checked the code on both instances, it is identical.
This is the fool error on the node:
Error building Component Context and Logic Agent:
Traceback (most recent call last): File "/home/azureuser/langflow/lib/python3.12/site-packages/langflow/base/agents/events.py", line 258, in process_agent_events async for event in agent_executor: File "/home/azureuser/langflow/lib/python3.12/site-packages/langchain_core/runnables/base.py", line 1388, in astream_events async for event in event_stream: File "/home/azureuser/langflow/lib/python3.12/site-packages/langchain_core/tracers/event_stream.py", line 1012, in _astream_events_implementation_v2 await task File "/home/azureuser/langflow/lib/python3.12/site-packages/langchain_core/tracers/event_stream.py", line 967, in consume_astream async for _ in event_streamer.tap_output_aiter(run_id, stream): File "/home/azureuser/langflow/lib/python3.12/site-packages/langchain_core/tracers/event_stream.py", line 203, in tap_output_aiter async for chunk in output: File "/home/azureuser/langflow/lib/python3.12/site-packages/langchain/agents/agent.py", line 1805, in astream async for step in iterator: File "/home/azureuser/langflow/lib/python3.12/site-packages/langchain/agents/agent_iterator.py", line 266, in aiter async for chunk in self.agent_executor._aiter_next_step( File "/home/azureuser/langflow/lib/python3.12/site-packages/langchain/agents/agent.py", line 1551, in _aiter_next_step result = await asyncio.gather( ^^^^^^^^^^^^^^^^^^^^^ File "/home/azureuser/langflow/lib/python3.12/site-packages/langchain/agents/agent.py", line 1584, in _aperform_agent_action observation = await tool.arun( ^^^^^^^^^^^^^^^^ File "/home/azureuser/langflow/lib/python3.12/site-packages/langchain_core/tools/base.py", line 839, in arun raise error_to_raise File "/home/azureuser/langflow/lib/python3.12/site-packages/langchain_core/tools/base.py", line 805, in arun response = await asyncio.create_task(coro, context=context) # type: ignore ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/azureuser/langflow/lib/python3.12/site-packages/langchain_core/tools/simple.py", line 111, in _arun return await self.coroutine(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/azureuser/langflow/lib/python3.12/site-packages/langchain_core/tools/retriever.py", line 45, in _aget_relevant_documents docs = await retriever.ainvoke(query, config={"callbacks": callbacks}) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/azureuser/langflow/lib/python3.12/site-packages/langchain_core/retrievers.py", line 329, in ainvoke raise e File "/home/azureuser/langflow/lib/python3.12/site-packages/langchain_core/retrievers.py", line 322, in ainvoke result = await self._aget_relevant_documents( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/azureuser/langflow/lib/python3.12/site-packages/langchain_core/vectorstores/base.py", line 1101, in _aget_relevant_documents docs = await self.vectorstore.asimilarity_search( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TypeError: AstraDBVectorStore.asimilarity_search() got multiple values for argument 'query'
The above exception was the direct cause of the following exception:
Traceback (most recent call last): File "/home/azureuser/langflow/lib/python3.12/site-packages/langflow/graph/vertex/base.py", line 709, in _build_results result = await initialize.loading.get_instance_results( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/azureuser/langflow/lib/python3.12/site-packages/langflow/interface/initialize/loading.py", line 68, in get_instance_results return await build_component(params=custom_params, custom_component=custom_component) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/azureuser/langflow/lib/python3.12/site-packages/langflow/interface/initialize/loading.py", line 145, in build_component build_results, artifacts = await custom_component.build_results() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/azureuser/langflow/lib/python3.12/site-packages/langflow/custom/custom_component/component.py", line 837, in build_results return await self._build_with_tracing() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/azureuser/langflow/lib/python3.12/site-packages/langflow/custom/custom_component/component.py", line 819, in _build_with_tracing _results, _artifacts = await self._build_results() ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/azureuser/langflow/lib/python3.12/site-packages/langflow/custom/custom_component/component.py", line 883, in _build_results result = await method() ^^^^^^^^^^^^^^ File "/home/azureuser/langflow/lib/python3.12/site-packages/langflow/base/agents/agent.py", line 82, in message_response message = await self.run_agent(agent=agent) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/azureuser/langflow/lib/python3.12/site-packages/langflow/base/agents/agent.py", line 158, in run_agent result = await process_agent_events( ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/azureuser/langflow/lib/python3.12/site-packages/langflow/base/agents/events.py", line 269, in process_agent_events raise ExceptionWithMessageError(agent_message) from e langflow.base.agents.events.ExceptionWithMessageError
Reproduction
- I upgraded the Lanflow version to 1.1.1
- Same setup as before
- Added my credentials
- Upgraded the nodes
- Errors in Retreival tools nodes => solved by deleting and readding the node and setting it up again
- All nodes tested and work imdividually
- Agent node spits out the error: Error building Component Context and Logic Agent
Expected behavior
Use logic to select the correct tools to perform a search and retrieve data to give an answer
Who can help?
No response
Operating System
Windows
Langflow Version
1.1.1
Python Version
None
Screenshot
No response
Flow File
No response
Hello @TOWaB! I'm here to help you solve bugs, answer questions, and become a contributor.
The error you're encountering, TypeError: AstraDBVectorStore.asimilarity_search() got multiple values for argument 'query', suggests that there might be an issue with how the arguments are being passed to the asimilarity_search() method in your environment. This could be due to changes in how arguments are handled in the Langflow v1.1.1 update.
In the updated version, argument passing to the asimilarity_search() method is managed by the _build_search_args() method, which constructs a dictionary of arguments. This includes the "query" key, among others, and these arguments are then passed to the search method [1][2].
Here are a few steps you can take to troubleshoot and resolve the issue:
-
Check Argument Construction: Ensure that the
_build_search_args()method is correctly constructing the arguments in your environment. There might be a duplication or misconfiguration causing thequeryargument to be passed multiple times. -
Review Code Changes: Compare the code related to argument handling in both environments. Even though you mentioned the code is identical, there might be subtle differences in how the environments handle the code execution.
-
Environment Differences: Since the issue does not occur in the Datastax environment, there might be differences in the Python environment or dependencies. Ensure that all dependencies are the same version in both environments.
-
Debugging: Add logging or print statements in the
_build_search_args()method to see what arguments are being constructed and passed to theasimilarity_search()method. This can help identify where the duplication is occurring.
By focusing on how the arguments are constructed and passed, you should be able to identify the source of the error and make the necessary adjustments.
To continue talking to Dosu, mention @dosu.
Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Other
Dear @erichare, I am sorry to chase, but did you have a chance to look at the above, I have exhausted all the avenues and ideas I have on how to fix it.
@TOWaB not yet, but would you be able to provide your flow file by exporting it in the Langflow UI? (if there's anything proprietary or sensitive please remove it first, minimal example of the error is ideal). I'll check it out today!
@erichare I have attached a basic version of the flow. If you need more details, happy to share on an email or similar. B2B Event Assistant V0.2 (PLAYGROUND).json
Really appreciate the help, thank you very much.
@TOWaB sorry, i might be missing something, but i loaded the flow, and im not actually seeing an Astra DB / similarity search component in the flow between the input and output? I see a couple that are isolated. could you highlight for me, maybe in a screenshot, where you're getting that error in the flow diagram you attached? Thank you!
@erichare sorry for the radio silence, I have been out for the past couple of days.
Please see attached
There are 4 elements with the same format that are linked to the Tool Calling agent
Hey @TOWaB
Sorry for the delay.
Do you still need help with this issue?
Hey guys. I work with @TOWaB and we fixed the issue, since the retriever tool wasn't needed anymore in v1.1.1. That said, now we've upgraded to v1.1.4 our Astra DB vector search TOOL doesn't work anymore, in terms of the connection with the Agent node is broken and refuses to reconnect. When I look at the tools available in the Components menu, the Astra DB Vector Search tool isn't there anymore, it's just a regular AstraDB search tool which doesn't have any parameters for vector similarity searching. Could you point us in the right direction to get AstraDB vector searching working again in terms of connecting to an agent tool?
Never mind, just discovered 'tools mode', think this issue can be closed