Skip to content

Fix: coerce numeric arguments in ToolManager#277

Open
BhoomiAgrawal12 wants to merge 4 commits intomesa:mainfrom
BhoomiAgrawal12:fix/speak-to-list-compulsion
Open

Fix: coerce numeric arguments in ToolManager#277
BhoomiAgrawal12 wants to merge 4 commits intomesa:mainfrom
BhoomiAgrawal12:fix/speak-to-list-compulsion

Conversation

@BhoomiAgrawal12
Copy link
Copy Markdown
Contributor

Pre-PR Checklist

  • [T] This PR is a bug fix, not a new feature or enhancement.

Summary

Fixes a bug where ToolManager passed numeric arguments as strings, causing tools annotated with int/float to fail. This impacted tool execution for LLMs that return numbers as JSON strings (e.g., Ollama).

ToolManager promises automatic type coercion in its docstring, but _process_tool_call() only filtered args by name. When an LLM returned "35.0" (string) for a float parameter, the tool received a string and raised an error. Expected behavior is to coerce to numeric types before invocation.

Bug / Issue

Fixes #276

Implementation

  • Added coercion in _process_tool_call() for float and int parameters.
  • Added two regression tests in tests/test_tools/test_tool_manager.py:
    • string → float ("35.0" -> 35.0)
    • string → int ("5" -> 5)

Testing

  • pytest tests/test_tools/test_tool_manager.py -v

Additional Notes

  • Coercion is intentionally limited to int and float to avoid unintended conversions.
  • If coercion fails (invalid value), the original input is passed through so tools still surface meaningful errors.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 30, 2026

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 3a88ac8d-02b2-4626-953a-4fb4d6e89cdb

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@BhoomiAgrawal12 BhoomiAgrawal12 changed the title Fix/speak to list compulsion Fix: coerce numeric arguments in ToolManager Mar 30, 2026
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 30, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.31%. Comparing base (2dfd129) to head (43f035f).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #277      +/-   ##
==========================================
+ Coverage   91.20%   91.31%   +0.10%     
==========================================
  Files          19       19              
  Lines        1592     1612      +20     
==========================================
+ Hits         1452     1472      +20     
  Misses        140      140              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@BhoomiAgrawal12 BhoomiAgrawal12 force-pushed the fix/speak-to-list-compulsion branch from d288bd3 to da462f8 Compare March 30, 2026 13:55
@BhoomiAgrawal12 BhoomiAgrawal12 force-pushed the fix/speak-to-list-compulsion branch from 0f4616a to 0bb7e09 Compare March 30, 2026 14:09
@BhoomiAgrawal12 BhoomiAgrawal12 force-pushed the fix/speak-to-list-compulsion branch from 1048e10 to d337a8a Compare March 30, 2026 14:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: ToolManager promises type coercion but passes strings to tools

2 participants