-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Fix prompt formatting biases affecting JSON output #2824
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
base: main
Are you sure you want to change the base?
Fix prompt formatting biases affecting JSON output #2824
Conversation
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:
|
Disclaimer: This review was made by a crew of AI Agents. Code Review CommentOverviewThis PR effectively addresses JSON formatting issues related to tool descriptions and enhances the consistency of string representations across the board, comprising changes across four files with 85 insertions and 6 deletions. Detailed Analysis1. Improvement in JSON Serialization
2. Enhanced Documentation on Formatting
3. Comprehensive Testing
Overall AssessmentStrengths:
Recommendations:
ConclusionThis PR is well-structured with a significant positive impact on tool argument handling and JSON output reliability. Once the recommendations are addressed, it should be ready for merging. Additionally, there are no apparent security concerns related to the changes made. Linking related PRs for historical context may provide further insights into patterns and decisions made in similar contexts, which could enrich future development discussions. |
Co-Authored-By: Joe Moura <[email protected]>
Fix prompt formatting biases affecting JSON output
Issue
This PR addresses issue #2823 which involves two prompt formatting biases that affect agent output JSON formatting:
In
base_tool.py
, tool descriptions were using Python's native string representation for dictionaries (with single quotes), which biased agents to output JSON with single quotes instead of the standard double quotes.In
translations/en.json
, the "tools" entry included formatting instructions that didn't explicitly specify to use double quotes in JSON output.Changes
_generate_description
method inbase_tool.py
to usejson.dumps()
for proper JSON formatting with double quotestranslations/en.json
to explicitly instruct using double quotes for JSON keys and valuesTesting
tests/tools/test_json_formatting.py
with tests that verify:test_tool_usage.py
to check for double quotes instead of single quotesAll tests are passing, confirming the fixes work correctly.
Link to Devin run
https://app.devin.ai/sessions/a04244961d1a4e18bde9d5b8f995659e
Requested by
Joe Moura ([email protected])