Skip to content

fix: recover truncated JSON responses and retry LLM generation#5

Merged
machado144 merged 1 commit intomainfrom
fix/truncated-json-recovery
Mar 8, 2026
Merged

fix: recover truncated JSON responses and retry LLM generation#5
machado144 merged 1 commit intomainfrom
fix/truncated-json-recovery

Conversation

@machado144
Copy link
Contributor

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)

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.
@github-actions
Copy link

github-actions bot commented Mar 8, 2026

✅ StructLint Validation

Metric Count
Checks passed 49
Violations 0

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_notes and suggested_version fields 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 machado144 merged commit 5fc7ada into main Mar 8, 2026
5 checks passed
@machado144 machado144 deleted the fix/truncated-json-recovery branch March 8, 2026 15:42
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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant