Skip to content

Parallel tool calls causing errors in human-in-the-loop breakpoint example #874

@hannah-schiebener

Description

@hannah-schiebener

Checked other resources

  • I added a very descriptive title to this issue.
  • I searched the LangGraph/LangChain documentation with the integrated search.
  • I used the GitHub search to find a similar question and didn't find it.
  • I am sure that this is a bug in LangGraph/LangChain rather than my code.
  • I am sure this is better as an issue rather than a GitHub discussion, since this is a LangGraph bug and not a design question.

Example Code

inputs = [HumanMessage(content="search for the weather in sf and in nyc now")]

Error Message and Stack Trace (if applicable)

BadRequestError
Cell In[96], line 1
----> 1 for event in app.stream(None, thread, stream_mode="values"):
      2     event["messages"][-1].pretty_print()

File /workspaces/waiv/backend/.venv/lib/python3.12/site-packages/langgraph/pregel/__init__.py:1073, in Pregel.stream(self, input, config, stream_mode, output_keys, input_keys, interrupt_before, interrupt_after, debug)
   1070         del fut, task
   1072 # panic on failure or timeout
-> 1073 _panic_or_proceed(done, inflight, step)
   1074 # don't keep futures around in memory longer than needed
   1075 del done, inflight, futures

File /workspaces/waiv/backend/.venv/lib/python3.12/site-packages/langgraph/pregel/__init__.py:1639, in _panic_or_proceed(done, inflight, step)
   1637             inflight.pop().cancel()
   1638         # raise the exception
-> 1639         raise exc
   1641 if inflight:
   1642     # if we got here means we timed out
   1643     while inflight:
   1644         # cancel all pending tasks

File /usr/local/lib/python3.12/concurrent/futures/thread.py:58, in _WorkItem.run(self)
     55     return
     57 try:
...
   (...)
   1036     stream_cls=stream_cls,
   1037 )

BadRequestError: Error code: 400 - {'type': 'error', 'error': {'type': 'invalid_request_error', 'message': "messages.2: the following `tool_use` ids were not found in `tool_result` blocks: {'toolu_01CWAWQdMDnYjrNBSneJfr3Z'}"}}

Description

I am running the breakpoints.ipynb notebook from the Human-in-the-Loop documentation and have modified the inputs variable (see above). This is the output when interacting with the agent with the modified input where it stops before calling the tool:

================================ Human Message =================================

search for the weather in sf and in nyc now
================================== Ai Message ==================================

[{'text': "Certainly! I'll search for the current weather in both San Francisco (SF) and New York City (NYC) for you. To do this, I'll need to make two separate search queries using the available search function. Let me do that for you now.", 'type': 'text'}, {'id': 'toolu_0134753sWzLXRGrbERPw7h8A', 'input': {'query': 'current weather in San Francisco'}, 'name': 'search', 'type': 'tool_use'}, {'id': 'toolu_01CWAWQdMDnYjrNBSneJfr3Z', 'input': {'query': 'current weather in New York City'}, 'name': 'search', 'type': 'tool_use'}]
Tool Calls:
  search (toolu_0134753sWzLXRGrbERPw7h8A)
 Call ID: toolu_0134753sWzLXRGrbERPw7h8A
  Args:
    query: current weather in San Francisco
  search (toolu_01CWAWQdMDnYjrNBSneJfr3Z)
 Call ID: toolu_01CWAWQdMDnYjrNBSneJfr3Z
  Args:
    query: current weather in New York City

This throws the above error after the first tool is run.
Sometimes the tools are called one after the other, which seems to work fine.

System Info

System Information

OS: Linux
OS Version: #1 SMP Thu May 23 08:36:57 UTC 2024
Python Version: 3.12.1 (main, Feb 1 2024, 03:58:05) [GCC 12.2.0]

Package Information

langchain_core: 0.2.10
langchain: 0.2.1
langchain_community: 0.2.1
langsmith: 0.1.82
langchain_anthropic: 0.1.16
langchain_mistralai: 0.1.7
langchain_openai: 0.1.7
langchain_text_splitters: 0.2.0
langgraph: 0.1.3

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions