fix(messages): use step_id to pair tool calls with returns
Problem: Tool return messages don't have tool_call_id field, so
previous pairing strategy failed.
Root cause discovered: Letta stores tool_call_id inside the tool_call
object for tool call messages, but tool return messages have NO
tool_call object at all. However, both message types share the same
step_id field.
Solution: Extract step_id instead of tool_call_id and use it for
pairing. Both tool_call_message and tool_return_message have the same
step_id when they belong to the same tool execution.
Changes:
- Replaced extractToolCallId() with extractStepId()
- Updated pairing maps to use step_id as the linking key
- Added debug logging in useMessages to show raw tool message JSON
- Updated all pairing logs to reference step_id
This should now correctly merge "(co updated memory)" into a single
unified message group.
Generated with Claude Code
Co-Authored-By: Claude <noreply@anthropic.com>