fix(core): skip malformed send_message entries in message conversion (#9494)

Avoid failing message-list endpoints when historical send_message tool calls are missing the expected message argument by logging and skipping malformed entries during conversion.

👾 Generated with [Letta Code](https://letta.com)

Co-authored-by: Letta <noreply@letta.com>
This commit is contained in:
Sarah Wooders
2026-02-16 11:45:18 -08:00
committed by Caren Thomas
parent c32d53f8a3
commit 26cbdb7b7b

View File

@@ -767,7 +767,12 @@ class Message(BaseMessage):
func_args = parse_json(tool_call.function.arguments)
message_string = validate_function_response(func_args[assistant_message_tool_kwarg], 0, truncate=False)
except KeyError:
raise ValueError(f"Function call {tool_call.function.name} missing {assistant_message_tool_kwarg} argument")
logger.error(
"Function call %s missing %s argument; skipping assistant message conversion",
tool_call.function.name,
assistant_message_tool_kwarg,
)
continue
# Ensure content is a string (validate_function_response can return dict)
if isinstance(message_string, dict):