Commit 812891d
committed
Fix JSON parsing to handle markdown-wrapped responses from Claude/Gemini
Some LLMs (especially Claude and Gemini) wrap JSON responses in markdown code blocks:
```json
{...}
```
Updated _parse_llm_response to:
- Strip markdown code block markers
- Handle both plain JSON and markdown-wrapped JSON
- Improved error logging with both original and cleaned content
This fixes the "LLM did not return valid JSON" error when using Anthropic or Gemini providers.1 parent 74200eb commit 812891d
1 file changed
+18
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
191 | 191 | | |
192 | 192 | | |
193 | 193 | | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
194 | 209 | | |
195 | | - | |
| 210 | + | |
196 | 211 | | |
197 | 212 | | |
198 | 213 | | |
| |||
208 | 223 | | |
209 | 224 | | |
210 | 225 | | |
211 | | - | |
| 226 | + | |
| 227 | + | |
212 | 228 | | |
213 | 229 | | |
214 | 230 | | |
| |||
0 commit comments