Skip to content

Fix: Correctly raised value error with descriptive error message in case of Invalid model instead of not a function calling model #285

Merged
wang-boyu merged 2 commits intomesa:mainfrom
DineshThumma9:fix/is-model-name-valid
Apr 13, 2026
Merged

Fix: Correctly raised value error with descriptive error message in case of Invalid model instead of not a function calling model #285
wang-boyu merged 2 commits intomesa:mainfrom
DineshThumma9:fix/is-model-name-valid

Conversation

@DineshThumma9
Copy link
Copy Markdown
Contributor

@DineshThumma9 DineshThumma9 commented Mar 31, 2026

Note

Use this template for bug fixes only. For enhancements/new features, use the feature template and get maintainer approval in an issue/discussion before opening a PR.

Pre-PR Checklist

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

Summary

When given an invalid model name it throws Error with message not a function calling model it might trick user in thinking their model is valid but not function calling and does'nt address actual model invalid issue

Bug / Issue

Fix : #284

Implementation

I added an model validity check right after api key check i used

litellm.get_model_info() 

wrapped in try and except block and raise ValueError when caught an error and show a descriptive message

Testing

Additional Notes

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 31, 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: 2fc9b54c-4bbc-40b4-923d-2d47d4f14aae

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.

@DineshThumma9 DineshThumma9 changed the title linted and formated Fix: Correctly raised value error with descriptive error message in case of Invalid model instead of not a function calling model Mar 31, 2026
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 12, 2026

Codecov Report

❌ Patch coverage is 71.42857% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 91.52%. Comparing base (2dfd129) to head (ae4484e).
⚠️ Report is 47 commits behind head on main.

Files with missing lines Patch % Lines
mesa_llm/module_llm.py 71.42% 6 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #285      +/-   ##
==========================================
+ Coverage   91.20%   91.52%   +0.32%     
==========================================
  Files          19       19              
  Lines        1592     1759     +167     
==========================================
+ Hits         1452     1610     +158     
- Misses        140      149       +9     

☔ 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.

@wang-boyu
Copy link
Copy Markdown
Member

Thanks for the fix @DineshThumma9 . I think litellm.get_model_info() is too strict to use in __init__, because it also raises for unmapped but valid models such as custom deployments.

I updated the logic so that initialization no longer mislabels invalid models as lacking function-calling support, and invalid-model errors are raised later at completion() time when LiteLLM actually fails to call the model.

Before I merge it, could you please verify that this works for you as expected? Thanks.

@DineshThumma9
Copy link
Copy Markdown
Contributor Author

DineshThumma9 commented Apr 13, 2026

Thanks @wang-boyu! I ran it locally too and it works as expected. No problems on my end. (Also, apologies—I closed this by mistake a moment ago!)

@wang-boyu
Copy link
Copy Markdown
Member

No worries at all, and thanks for the quick confirmation. Merging this now.

@wang-boyu wang-boyu added the bug Release notes label label Apr 13, 2026
@wang-boyu wang-boyu merged commit 550c27d into mesa:main Apr 13, 2026
24 of 25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Release notes label

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Incorrect Error Raised When Model Name is Invalid

2 participants