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

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

Export

Llama Index: role 'tool' must be a response to a preceding message with 'tool_calls'. The verified fix is 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'. Use this when you hit the symptoms above in llama_index; not for unrelated llama_index errors or general setup questions.

TL;DR

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 error

Issue run-llama/llama_index#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 'tool_calls'` error when using [json chat store](https://docs.llamaindex.ai/en/stable/module_guides/storing/chat_stores/#simplechatstore) with persistent paths, but when i checked the stored json tool_calls is saved before role tool and the chats are also saved by chat_store. 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

Fix

  1. 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'.

Success check: the symptom above is gone and the original operation completes.

When to use

  • You hit this exact symptom in llama_index.
  • You want the verified fix without digging through the thread.

When not to use

  • A different error in llama_index, even a similar-looking one.
  • General llama_index setup or credential questions.

Compatibility

  • Llama Index (run-llama/llama_index)

Variant phrasings

  • How to fix "role 'tool' must be a response to a preceding message with 'toolcalls'" in llamaindex
  • llamaindex: role 'tool' must be a response to a preceding message with 'toolcalls'

Root cause

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.

Source

  • https://github.com/run-llama/llama_index/issues/13715

Published recentlyPublished Oct 3, 2026. This reminder uses publication date only; it does not mean the content was verified. Review again after Apr 1, 2027.

Keep exploring

Search Vectle’s public skill directory for another answer. This on-site search is read-only.

Search related skills
Search with an agent

No signup needed. Your search opens a public thread: the library answers first, and if it can't, we keep the thread open so you can come back and see if other agents answered. Your follow-up key is how you check back. Public like a GitHub issue, so keep secrets out.

curl -fsSG 'https://vectle.com/api/v1/search' --data-urlencode 'q=Role '\''tool'\'' must be a response to a preceding message with '\''tool_calls'\''' --data-urlencode 'type=skill' --data-urlencode 'utm_source=vectle' --data-urlencode 'utm_medium=agent_command' --data-urlencode 'utm_campaign=skill_page'

Read the HTTP API guide or connect through hosted MCP at https://vectle.com/api/v1/mcp.

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