# Issues with Messages in State when using AWS Bedrock and Open AI models

**URL:** <https://forum.langchain.com/t/issues-with-messages-in-state-when-using-aws-bedrock-and-open-ai-models/1731>\
**Category:** LangGraph\
**Tags:** python-help\
**Created:** [October 3, 2025, 1:42am UTC](https://forum.langchain.com/t/issues-with-messages-in-state-when-using-aws-bedrock-and-open-ai-models/1731 "2025-10-03T01:42:21Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![jriedel199715](https://avatars.discourse-cdn.com/v4/letter/j/91b2a8/32.png) [@jriedel199715](https://forum.langchain.com/u/jriedel199715)\
**Post date:** [October 3, 2025, 1:42am UTC](https://forum.langchain.com/t/issues-with-messages-in-state-when-using-aws-bedrock-and-open-ai-models/1731/1 "2025-10-03T01:42:21Z")

</div>

I keep getting Langgraph state validation issues with my messages key or I get API issues with AWS Bedrock with the way my messages are structured. Is there a way to properly standardize the messages (BaseMessage) so that it will work with most model provider apis AND langchain/langraph mesasge objects…

```bash

```

KeyError(‘tool\_call\_id’)Traceback (most recent call last):

File “/usr/local/lib/python3.11/site-packages/langgraph/utils/runnable.py”, line 678, in ainvoke  
input = await step.ainvoke(input, config)  
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File “/usr/local/lib/python3.11/site-packages/langgraph/utils/runnable.py”, line 440, in ainvoke  
ret = await self.afunc(\*args, \*\*kwargs)  
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File “/usr/local/lib/python3.11/site-packages/langgraph/graph/branch.py”, line 185, in \_aroute  
value = reader(config)  
^^^^^^^^^^^^^^

File “/usr/local/lib/python3.11/site-packages/langgraph/pregel/read.py”, line 110, in do\_read  
return mapper(read(select, fresh))  
^^^^^^^^^^^^^^^^^^^

File “/usr/local/lib/python3.11/site-packages/langgraph/pregel/algo.py”, line 201, in local\_read  
cc.update(updated[k])

File “/usr/local/lib/python3.11/site-packages/langgraph/channels/binop.py”, line 91, in update  
self.value = self.operator(self.value, value)  
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File “/usr/local/lib/python3.11/site-packages/langgraph/graph/message.py”, line 39, in \_add\_messages  
return func(left, right, \*\*kwargs)  
^^^^^^^^^^^^^^^^^^^^^^^^^^^

File “/usr/local/lib/python3.11/site-packages/langgraph/graph/message.py”, line 182, in add\_messages  
for m in convert\_to\_messages(right)  
^^^^^^^^^^^^^^^^^^^^^^^^^^

File “/usr/local/lib/python3.11/site-packages/langchain\_core/messages/utils.py”, line 373, in convert\_to\_messages  
return [\_convert\_to\_message(m) for m in messages]  
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File “/usr/local/lib/python3.11/site-packages/langchain\_core/messages/utils.py”, line 373, in  
return [\_convert\_to\_message(m) for m in messages]  
^^^^^^^^^^^^^^^^^^^^^^

File “/usr/local/lib/python3.11/site-packages/langchain\_core/messages/utils.py”, line 346, in _convert\_to\_message  
message_ = \_create\_message\_from\_message\_type(  
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File “/usr/local/lib/python3.11/site-packages/langchain\_core/messages/utils.py”, line 289, in \_create\_message\_from\_message\_type  
message = ToolMessage(content=content, artifact=artifact, \*\*kwargs)  
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File “/usr/local/lib/python3.11/site-packages/langchain\_core/messages/tool.py”, line 146, in **init**  
super(). **init** (content=content, \*\*kwargs)

File “/usr/local/lib/python3.11/site-packages/langchain\_core/messages/base.py”, line 72, in **init**  
super(). **init** (content=content, \*\*kwargs)

File “/usr/local/lib/python3.11/site-packages/langchain\_core/load/serializable.py”, line 115, in **init**  
super(). **init** (\*args, \*\*kwargs)

File “/usr/local/lib/python3.11/site-packages/pydantic/main.py”, line 253, in **init**  
validated\_self = self. **pydantic\_validator**.validate\_python(data, self\_instance=self)  
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File “/usr/local/lib/python3.11/site-packages/langchain\_core/messages/tool.py”, line 132, in coerce\_args  
tool\_call\_id = values[“tool\_call\_id”]  
~~~~~~ ^^^^^^^^^^^^^^^^

KeyError: ‘tool\_call\_id’

---

<div class="post-metadata">

**Author:** ![pawel-twardziak](https://yyz1.discourse-cdn.com/flex007/user_avatar/forum.langchain.com/pawel-twardziak/32/960_2.png) [@pawel-twardziak](https://forum.langchain.com/u/pawel-twardziak)\
**Post date:** [October 3, 2025, 4:33pm UTC](https://forum.langchain.com/t/issues-with-messages-in-state-when-using-aws-bedrock-and-open-ai-models/1731/2 "2025-10-03T16:33:01Z")

</div>

Hi @jriedel199715

how is your tool message created? Are you using `ToolMessage`? Can you share how it looks in your code?

---

<div class="post-metadata">

**Author:** ![jriedel199715](https://avatars.discourse-cdn.com/v4/letter/j/91b2a8/32.png) [@jriedel199715](https://forum.langchain.com/u/jriedel199715)\
**Post date:** [October 3, 2025, 7:19pm UTC](https://forum.langchain.com/t/issues-with-messages-in-state-when-using-aws-bedrock-and-open-ai-models/1731/3 "2025-10-03T19:19:26Z")

</div>

Long story short, return state.model\_dump() at the end of a langgraph node totally messes with the BaseMessages that exist in my state’s messages key. When I save the state it is fine but then the next time I run the messages through an LLM there is a Validation error and that is because the model\_dump was wiping some important pieces of the messages.

---

<div class="post-metadata">

**Author:** ![pawel-twardziak](https://yyz1.discourse-cdn.com/flex007/user_avatar/forum.langchain.com/pawel-twardziak/32/960_2.png) [@pawel-twardziak](https://forum.langchain.com/u/pawel-twardziak)\
**Post date:** [October 3, 2025, 7:41pm UTC](https://forum.langchain.com/t/issues-with-messages-in-state-when-using-aws-bedrock-and-open-ai-models/1731/4 "2025-10-03T19:41:41Z")

</div>

I have no idea how you handle the state (if you are using checkpointer or not), but it sounds like something custom. Hence sharing the code snippets would be helpful otherwise I’m not sure how to assist 😔

---

<div class="post-metadata">

**Author:** ![jriedel199715](https://avatars.discourse-cdn.com/v4/letter/j/91b2a8/32.png) [@jriedel199715](https://forum.langchain.com/u/jriedel199715)\
**Post date:** [October 3, 2025, 9:08pm UTC](https://forum.langchain.com/t/issues-with-messages-in-state-when-using-aws-bedrock-and-open-ai-models/1731/5 "2025-10-03T21:08:00Z")

</div>

Sorry, I am saying it is resolved. The resolution is do not use state.model\_dump() at the end of a node. Might not apply to everyone but for me that was the solution

---

<div class="post-metadata">

**Author:** ![alpha-xone](https://yyz1.discourse-cdn.com/flex007/user_avatar/forum.langchain.com/alpha-xone/32/1328_2.png) [@alpha-xone](https://forum.langchain.com/u/alpha-xone)\
**Post date:** [December 3, 2025, 10:19am UTC](https://forum.langchain.com/t/issues-with-messages-in-state-when-using-aws-bedrock-and-open-ai-models/1731/6 "2025-12-03T10:19:45Z")

</div>

@jriedel199715 hi, how do you solve this issue? My case is definitely different from your but just want to get some insight.

I have a custom graph having the same issue. For an agent that works normally - but when I create this agent on the fly using runtime context, it has this `tool_id`.
