Fix Nested JSON Parsing and Add Sanitization for LLM Output #11

Open
opened 2025-10-06 09:32:34 +00:00 by aditya · 0 comments
Member

Description

Fix regex pattern preventing nested JSON in tool parameters and add JSON sanitization to handle malformed LLM responses with unescaped control characters.

Acceptance Criteria

  • Regex pattern changed from {[^}]+} to (.*?) for nested JSON support
  • _sanitize_json_string() handles newlines, tabs, carriage returns
  • Valid JSON passes through unchanged
  • Complex contract analysis JSON saves successfully
  • Works with long multi-section content from paper writer

Definition of Done

  • Regex pattern fixed in process_tool_commands() (line 746)
  • _sanitize_json_string() method implemented (150+ lines)
  • Integrated into tool command processing workflow
  • Contract analyzer saves complete nested JSON correctly
  • Code comments explain sanitization logic and pattern choice
### **Description** Fix regex pattern preventing nested JSON in tool parameters and add JSON sanitization to handle malformed LLM responses with unescaped control characters. ### **Acceptance Criteria** - Regex pattern changed from \{[^}]+\} to (.*?) for nested JSON support - _sanitize_json_string() handles newlines, tabs, carriage returns - Valid JSON passes through unchanged - Complex contract analysis JSON saves successfully - Works with long multi-section content from paper writer ### **Definition of Done** - Regex pattern fixed in process_tool_commands() (line 746) - _sanitize_json_string() method implemented (150+ lines) - Integrated into tool command processing workflow - Contract analyzer saves complete nested JSON correctly - Code comments explain sanitization logic and pattern choice
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: cleveragents/cleveragents-core#11
No description provided.