Fix prompt formatting biases affecting JSON output #2824
Closed
+186
−13
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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])