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

Closed
opened 2025-10-06 09:32:34 +00:00 by aditya · 1 comment
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
aleenaumair added this to the (deleted) milestone 2025-10-30 11:52:29 +00:00
Owner

Closing as completed (State/Completed).

Closing as completed (State/Completed).
freemo modified the milestone from (deleted) to v3.0.0 2026-02-23 00:07:12 +00:00
Sign in to join this conversation.
No milestone
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Blocks
#28 Security Enhancements
cleveragents/cleveragents-core
Reference
cleveragents/cleveragents-core#11
No description provided.