Skip to content

[FEATURE] Support function calling without automatically executing tools #256

@subelsky

Description

@subelsky

Scope check

  • This is core LLM communication (not application logic)
  • This benefits most users (not just my use case)
  • This can't be solved in application code with current RubyLLM
  • I read the Contributing Guide

Due diligence

  • I searched existing issues
  • I checked the documentation

What problem does this solve?

Right now the tool-calling feature cannot be used for pure function calling, because it automatically executes tools and returns the results to the model as part of the chat.

In many cases, such as multi-agent workflows, developers will want to pass the parameters returned by a function call to another agent, which can't be done without making an unnecessary chat request to the original model.

Proposed solution

I'd like to add a check to RubyLLM::Chat#handle_tool_calls that only sends a new message if the tool has defined an execute method. Any tools that do not implement execute can be treated as pure functions with no RubyLLM side effects.

Why this belongs in RubyLLM

This is core behavior for the RubyLLM::Chat class - it could theoretically be fixed by subclassing RubyLLM::Chat and overriding the private method, but that is not very maintainable.

I'm happy to fix this if there's an appetite for the change! thanks for making a great gem.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions