Skip to content

Conversation

@isaacbmiller
Copy link
Collaborator

When LLMs output Python-style dicts with None values, json_repair.loads was converting None to the string "None" instead of null. This caused high tool call failure rates for Dict[str, Any] fields.

Changes:

  • Update ChatAdapter to instruct "valid JSON" instead of "valid Python dict"
  • Reorder parse_value to try ast.literal_eval before json_repair.loads
  • Preserve ast.literal_eval results as fallback when json_repair fails
  • Add comprehensive tests for None, True, False, and null handling

This maintains backward compatibility by accepting both Python and JSON syntax while correctly parsing None/True/False/null values.

Fixes #8820

When LLMs output Python-style dicts with None values, json_repair.loads
was converting None to the string "None" instead of null. This caused
high tool call failure rates for Dict[str, Any] fields.

Changes:
- Update ChatAdapter to instruct "valid JSON" instead of "valid Python dict"
- Reorder parse_value to try ast.literal_eval before json_repair.loads
- Preserve ast.literal_eval results as fallback when json_repair fails
- Add comprehensive tests for None, True, False, and null handling

This maintains backward compatibility by accepting both Python and JSON
syntax while correctly parsing None/True/False/null values.

Fixes #8820
@isaacbmiller isaacbmiller changed the title Fix None/True/False parsing in Dict[str, Any] fields (#8820) fix(ChatAdapter): None/True/False parsing in Dict[str, Any] fields (#8820) Nov 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Conflict between ChatAdapter.user_message_output_requirements and ChatAdapter.parse leads to high tool call failure rate

2 participants