Skip to content

[BUG] LLM is calling tools with undeclared parameters #508

@aniamisiorek

Description

@aniamisiorek

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?

Tool.call() does not perform any sort of parameter validation:
result = execute(**args.transform_keys(&:to_sym))
Our team has run into an issue where the LLM will call tools with unsupported parameters, resulting in unknown keyword error.

How to reproduce

  1. Define a tool with some set of parameters
  2. Add the tool to a chat, and prompt the LLM to use the tool with a parameter you did not define.
  3. Sometimes it will mention that the parameter is not accepted, but other times it will attempt to call the tool with fake parameters.

Expected behavior

Tool.call handles hallucinated parameters before a keyword error is triggered.

What actually happened

from tool_call table:

--clients--update_client

"{""last_name"": ""Brown"", ""first_name"": ""Goose"", ""new_advisor_code"": ""AWM-2000-106""}"

new_advisor_code is not a supported parameter for UpdateClient, so application throws an error, Failed to send message: unknown keyword: :new_advisor_code"

Environment

  • Ruby: 3.4.2
  • RubyLLM: 1.9.1
  • Provider: AWS Bedrock -- Anthropic Sonnet

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