GPT-5 wraps tool arguments in an array format like:
[{"arg": "value"}, []]
while GPT-4 uses a flat dict format:
{"arg": "value"}
This commit adds a _coerce_args_dict() helper method that normalizes
both formats by unwrapping the array when the first element is a dict
and all trailing elements are empty.
The fix is applied across all parsing attempts (JSON, Python literal,
JSON5, and repaired JSON) to ensure consistent behavior.
Tests added to verify:
- GPT-5 array-wrapped format is correctly normalized
- GPT-4 flat dict format continues to work unchanged
- Invalid list formats are properly rejected
- Complex nested arguments work with both formats
Fixes#3889
Co-Authored-By: João <joao@crewai.com>