Skip to content
← Back to activity

Immutable solution version

Role 'tool' must be a response to a preceding message with 'tool_calls'

Version 1Sign in to save

Complete solution

LlamaIndex: Collaborator logan-markewich: this was a known bug in the chat-store memory handling - the memory buffer dropped the assistant/tool message pairs, so a 'tool' role message was sent to OpenAI without a preceding 'tool_calls' assistant message. Fix: upgrade the chat-store package (pip install -U llama-index-chat-store-redis) and core (pip install -U llama-index-core); he noted 'I'm like 86% sure this is fixed'.

The problem

Issue run-llama/llamaindex#13715 (closed, 23 comments): ### Bug Description getting `openai.BadRequestError: Error code: 400 - {'error': {'message': "Invalid parameter: messages with role 'tool' must be a response to a preceeding message with 'toolcalls'` error when using json chat store with persistent paths, but when i checked the stored json toolcalls is saved before role tool and the chats are also saved by chatstore. I am receiving this error in long chats but only when i am loading the chat store again for specific key, when i tested separately in wh

The verified fix

Collaborator logan-markewich: this was a known bug in the chat-store memory handling - the memory buffer dropped the assistant/tool message pairs, so a 'tool' role message was sent to OpenAI without a preceding 'toolcalls' assistant message. Fix: upgrade the chat-store package (pip install -U llama-index-chat-store-redis) and core (pip install -U llama-index-core); he noted 'I'm like 86% sure this is fixed'. Related reporter tip: removing/trimming chat history can also restore working pairs since truncation can split toolcall pairs.

Evidence

In gh:run-llama/llamaindex#13715 (https://github.com/run-llama/llamaindex/issues/13715), someone reported: Issue run-llama/llamaindex#13715 (closed, 23 comments): ### Bug Description getting `openai.BadRequestError: Error code: 400 - {'error': {'message': "Invalid parameter: messages with role 'tool' must be a response to a preceeding message with 'toolcalls'` error when using json chat store with persistent paths, but when i checked the stored json toolcalls is saved before role tool and the chats are also saved by chatstore. I am receiving this error in long chats but only when i am loading the chat store again for specific key, when i tested separately in wh The verified resolution from the thread: Collaborator logan-markewich: this was a known bug in the chat-store memory handling - the memory buffer dropped the assistant/tool message pairs, so a 'tool' role message was sent to OpenAI without a preceding 'toolcalls' assistant message. Fix: upgrade the chat-store package (pip install -U llama-index-chat-store-redis) and core (pip install -U llama-index-core); he noted 'I'm like 86% sure this is fixed'. Related reporter tip: removing/trimming chat history can also restore working pairs since truncation can split toolcall pairs.

By @issueatlas · Version 1 · Exact version

Reported outcomes

No reported outcomes for this version yet.

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_VPr9FQikUDPuk3kId0QRFw" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Role &#39;tool&#39; must be a response to a preceding message with &#39;tool_calls&#39; <span>— Vectle</span></a>