-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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 #620 #622
Fix #620 #622
Conversation
a670ccd
to
2cbb88d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While the original code replaces all double quotes inside the string with escaped double quotes, the updated code first removes any leading or trailing double quotes from the value string before applying the replacement. This ensures that any double quotes at the ends are not escaped unnecessarily. This can prevent double escaping in cases where the string might already be wrapped in double quotes.
I'm having the same issue and would love to see this merged. |
I am seeing something similar when using Ollama with various models llama3
mistral
would love to see it fixed. |
It fixes the issue for
|
Great catch! Should we also do the same for |
Oh, I didn't get the problem with |
Loved it! We are ready to merge this. Do you mind taking a look at the failing tasks? |
@italovieira |
This PR is stale because it has been open for 45 days with no activity. |
Disclaimer: This review was made by a crew of AI Agents. Code Review for PR #622OverviewThe changes focus on improving string handling in the Changes ReviewedThe PR contains two notable updates to the string formatting logic:
Positive Aspects
Recommendations for Improvement
Testing RecommendationsTo ensure the function performs as intended across various scenarios, please include additional test cases:
Example test cases: def test_validate_tool_input():
assert _validate_tool_input('test') == '"test"'
... Documentation SuggestionsAdding a detailed docstring would clarify the function's behavior: def _validate_tool_input(self, tool_input: str) -> str:
"""
Validates and formats tool input strings for proper JSON formatting.
Args:
tool_input (str): The input string to be validated and formatted
Returns:
str: Properly formatted string with escaped quotes
Raises:
ValueError: If the input is invalid or cannot be properly formatted
""" ConclusionOverall, the changes in this PR significantly improve the management of input strings in the Please consider these suggestions to further improve the quality of the code. Thank you for your work on this PR! |
No longer applicable. |
By investigating I noticed using crewAI with ollama + ollama3 that in some cases the
agent
parameter below comes with leading or trailing quote likeagent = '"pilot'
. There is a code to reproduce the bug in the description of #620.https://github.com/joaomdmoura/crewAI/blob/1e112fa50a27e13dd471feca5543932f46aa5176/src/crewai/tools/agent_tools.py#L52
This causes the comparison below to be false raising the error "Co-worker mentioned not found...". https://github.com/joaomdmoura/crewAI/blob/1e112fa50a27e13dd471feca5543932f46aa5176/src/crewai/tools/agent_tools.py#L58
I think this is the reason there was a
.strip(")
at https://github.com/joaomdmoura/crewAI/blob/bcb57ce5f9b359d933870f66634109ce269989c1/src/crewai/tools/tool_usage.py#L354So I've added back to fix #620.