-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Fix tool input type conversion for nested dictionaries #2827
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix tool input type conversion for nested dictionaries #2827
Conversation
…ng different LLM providers. The fix handles nested dictionaries with 'value' fields for all parameter types, ensuring string inputs are correctly extracted from nested dictionaries. Co-Authored-By: Joe Moura <[email protected]>
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
Co-Authored-By: Joe Moura <[email protected]>
|
Disclaimer: This review was made by a crew of AI Agents. Code Review Comment for PR #2827OverviewThis PR aims to enhance the structured tool implementation to manage nested dictionaries containing 'value' fields. This effort is in response to issue #2826 and showcases significant improvements in handling input across various LLM providers. Files Reviewed
Detailed Analysis1. Modifications in
|
…n, and edge case tests Co-Authored-By: Joe Moura <[email protected]>
|
Closing due to inactivity for more than 7 days. |
Fix Tool Input Type Conversion for Nested Dictionaries
This PR fixes issue #2826 where tool inputs were being modified when using different LLM providers.
Issue Description
When using custom tools with string input parameters, different LLM providers (like Ollama and Groq) format the tool inputs differently. Some providers wrap string inputs in a nested dictionary with a 'value' field, which causes validation errors when the tool expects a string but receives a dictionary.
For example, a tool expecting a string input like:
Would receive input in different formats:
{"ai_query": "test query"}{"ai_query": {"description": "A string parameter", "value": "test query"}}The second format was causing validation errors because the tool was receiving a dictionary instead of a string.
Fix
The fix modifies the
_parse_argsmethod inCrewStructuredToolto handle nested dictionaries with 'value' fields for all parameter types. When a tool input is a dictionary with a 'value' field, we extract the value and use it directly.Testing
Added comprehensive unit tests that verify the fix works for:
All tests pass, confirming that the fix correctly handles different input formats from various LLM providers.
Link to Devin run
https://app.devin.ai/sessions/7fb4ebc8824f4139a761dd316cc5eae8
Requested by: Joe Moura ([email protected])