Skip to content

[BUG] acts_as_tool_call ignores message: option - hardcodes .message in cleanup_orphaned_tool_results #514

@saurabh-sikchi

Description

@saurabh-sikchi

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?

When using acts_as_tool_call message: :llm_message to configure a custom association name, the cleanup_orphaned_tool_results method in chat_methods.rb ignores this configuration and calls .message directly, causing NoMethodError.

How to reproduce

  1. Configure a custom message association name:
class LLMToolCall < ApplicationRecord
  acts_as_tool_call message: :llm_message
end
  1. Run a chat with tool calls that triggers cleanup_orphaned_tool_results
  2. Error occurs at line 221 in lib/ruby_llm/active_record/chat_methods.rb

Expected behavior

The gem should use the configured association name (:llm_message) instead of hardcoded .message

What actually happened

NoMethodError: undefined method 'message' for an instance of LLMToolCall

The offending code at lib/ruby_llm/active_record/chat_methods.rb:221:
tool_call_message = last.parent_tool_call.message

Environment

  • Ruby: 3.4.7
  • ruby_llm: 1.9.1

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