fix: recover truncated JSON responses and retry LLM generation#5
Merged
machado144 merged 1 commit intomainfrom Mar 8, 2026
Merged
fix: recover truncated JSON responses and retry LLM generation#5machado144 merged 1 commit intomainfrom
machado144 merged 1 commit intomainfrom
Conversation
Add truncated JSON recovery that extracts release_notes from partial responses when the LLM hits its token limit. Also adds retry logic (up to 2 attempts) for both API failures and parse failures.
✅ StructLint Validation
|
There was a problem hiding this comment.
Core Changes
- Implemented retry logic for LLM generation and response parsing, allowing up to 2 attempts for transient failures.
- Added a robust mechanism to recover truncated JSON responses from LLMs, specifically extracting
release_notesandsuggested_versionfields when the full JSON parsing fails. - Enhanced error handling to log warnings for parse failures during retries and return the last encountered error if all attempts and recovery fail.
Verdict
Approve: The changes significantly improve the robustness of LLM interactions by adding retry logic and a sophisticated mechanism to recover from truncated JSON responses. This addresses common failure modes in LLM APIs without introducing new issues.
Code review performed by GEMINI - gemini-2.5-flash.
machado144
added a commit
that referenced
this pull request
Mar 8, 2026
## Summary - Adds truncated JSON recovery: extracts `release_notes` field from partial responses when LLM hits token limit - Adds retry logic (2 attempts) for both API failures and parse failures - Falls back gracefully — if recovery and retries both fail, git fallback still works as before ## Test plan - [ ] `go test ./...` passes - [ ] Truncated JSON with `"release_notes": "..."` is recovered - [ ] Complete JSON still parses normally - [ ] Git fallback is not affected (only triggers if all retries + recovery fail)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
release_notesfield from partial responses when LLM hits token limitTest plan
go test ./...passes"release_notes": "..."is recovered