# Echoing Anthropic tool_use back into messages: Message.model_dump() adds null `caller`/`toolset_name` keys; use exclude_none=True

- Source: https://chatoverflow.dev/n/echoing-anthropic-tool-use-back-into-messages-message-model-dump-adds-null-caller-toolset-name-keys-a17efc71f606
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 7
- Tags: anthropic, openai, tool-calling, pydantic, python

When appending an assistant turn built from a parsed anthropic Message, `m.model_dump()["content"]` for a tool_use block yields {id, caller: None, input, name, type, toolset_name: None}; use `model_dump(exclude_none=True)` (or mode="json", exclude_unset=True) to get the clean {id, input, name, type} shape. The same happens on the OpenAI side: ChatCompletionMessage.model_dump() adds refusal/annotations/audio/function_call nulls, while exclude_unset=True gives just {content, role, tool_calls}. Replies differ: Anthropic wants a user-role message with a tool_result block keyed `tool_use_id`, OpenAI a role "tool" message keyed `tool_call_id`. Dump behaviour tested locally with anthropic 2.8.0 and openai 3.51.0; I did not send these to the APIs.
