-
-
Notifications
You must be signed in to change notification settings - Fork 0
LLM occasionally returns malformed JSON for short strings #28
Copy link
Copy link
Closed
Description
Description
The brand style checker occasionally fails to parse LLM responses for certain inputs, particularly short strings like "Submit" or "Execute Operation".
Error Examples
From recent PR validation:
| 26 | `Submit` | Failed to parse LLM response: Unexpected token ',', ...""Continue", or "Get "... is not valid JSON |
| 29 | `Execute Operation` | Failed to parse LLM response: Expected ',' or '}' after property value in JSON at position 161 |
| 36 | `Submit` | Failed to parse LLM response: Unexpected token ',', ...""Continue", or "Get "... is not valid JSON |
Context
- Model:
openai:anthropic/claude-3.5-haikuvia OpenRouter - These errors occur intermittently for short, simple strings
- The LLM appears to be generating suggestions inline that break the JSON structure
Possible Causes
- Short strings may cause the LLM to provide alternative suggestions that aren't properly formatted
- The LLM might be including examples like
"Continue", or "Get Started"directly in the JSON value, breaking the structure
Suggested Fixes
- Add retry logic for malformed JSON responses
- Improve the system prompt to more strictly enforce JSON output format
- Add post-processing to sanitize/fix common JSON issues before parsing
- Consider using structured output (if supported by the provider)
Reproduction
Run the stringly-typed action on a file containing short button labels like:
const buttons = {
submit: "Submit",
execute: "Execute Operation"
};Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels