You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(openrouter-adapter): Improve tool call argument parsing with robust error handling
- Add comprehensive JSON parsing error handling for tool call arguments
- Implement fallback mechanism to extract first valid JSON object when parsing fails
- Log detailed warnings and errors for malformed JSON input
- Prevent adapter from breaking when encountering invalid JSON in tool call arguments
- Ensure graceful degradation by using empty dict if parsing completely fails
Copy file name to clipboardExpand all lines: agentle/generations/providers/openrouter/_adapters/openrouter_message_to_generated_assistant_message_adapter.py
+35-1Lines changed: 35 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -84,11 +84,45 @@ def adapt(
84
84
tool_parts: list[ToolExecutionSuggestion] = []
85
85
fortool_callintool_calls_data:
86
86
function_data=tool_call.get("function", {})
87
+
88
+
# Parse arguments with error handling for malformed JSON
0 commit comments