There was an error while loading. Please reload this page.
1 parent 3cc654c commit dcda92eCopy full SHA for dcda92e
1 file changed
deepfabric/formatters/builtin/trl_sft_tools.py
@@ -216,9 +216,15 @@ def _convert_agent_to_messages(
216
# Parse tool input
217
if isinstance(tool_input, str):
218
try:
219
- tool_args = json.loads(tool_input.replace("'", '"'))
220
- except (json.JSONDecodeError, AttributeError):
221
- tool_args = {"input": tool_input}
+ # First try parsing as standard JSON
+ tool_args = json.loads(tool_input)
+ except json.JSONDecodeError:
222
+ try:
223
+ # Fallback: try replacing single quotes with double quotes
224
+ tool_args = json.loads(tool_input.replace("'", '"'))
225
226
+ # Final fallback: wrap in a simple structure
227
+ tool_args = {"input": tool_input}
228
else:
229
tool_args = tool_input
230
0 commit comments