Skip to content

[BUG] Qwen3 Thinking on OpenRouter + Tool without argument breaks #384

@elthariel

Description

@elthariel

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?

Using Qwen3 Thinking variants, triggering a tool usage without parameters triggers the following stacktrace:

ruby_llm (1.6.4) lib/ruby_llm/providers/openai/tools.rb:57:in `block in parse_tool_calls'
ruby_llm (1.6.4) lib/ruby_llm/providers/openai/tools.rb:50:in `to_h'
ruby_llm (1.6.4) lib/ruby_llm/providers/openai/tools.rb:50:in `parse_tool_calls'
ruby_llm (1.6.4) lib/ruby_llm/providers/openai/chat.rb:53:in `parse_completion_response'
ruby_llm (1.6.4) lib/ruby_llm/provider.rb:212:in `sync_response'
ruby_llm (1.6.4) lib/ruby_llm/provider.rb:58:in `complete'
ruby_llm (1.6.4) lib/ruby_llm/chat.rb:125:in `complete'
ruby_llm (1.6.4) lib/ruby_llm/active_record/acts_as.rb:196:in `complete' 

This is likely due to function.arguments being not present or just empty, as checked in parse_tool_call

I'll submit a PR shortly

How to reproduce

  • Configure an OpenRouter key
  • Create a Tool without arguments
  • Trigger that chat in a tool with qwen/qwen3-30b-a3b-thinking-2507

Expected behavior

The tool is called

What actually happened

undefined method `empty?' for nil

Environment

ruby 3.3.6
ruby_llm 1.6.4

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