Skip to content

[BUG] chat.messages.map(&:to_h) doesn't convert ToolCall values #610

@KieranP

Description

@KieranP

Basic checks

  • I searched existing issues - this hasn't been reported
  • I can reproduce this consistently
  • This is a RubyLLM bug, not my application code

What's broken?

RubyLLM::Message#to_h is shallow, not converting nested

How to reproduce

chat.ask(query)
chat.messages.map(&:to_h)

Expected behavior

When calling to_h on messages, the child records (like ToolCall) should also be converted to hashes

What actually happened

The message is a hash, but tool calls are still class records

Environment

Ruby 3.4.1
RubyLLM: 1.12.0
Provider: Bedrock

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions