Retry structure step up to 3 times on failure#3
Open
ha1t wants to merge 1 commit into
Open
Conversation
The structure determination step can fail intermittently or return an empty page list. Retry up to 3 times, dumping each failed response to a debug file inside the wiki output dir for inspection. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Review Summary by QodoAdd retry logic to structure determination with debug output
WalkthroughsDescription• Implement retry mechanism for wiki structure determination step - Retries up to 3 times on claudeCall failures or empty page results - Displays retry progress indicator on subsequent attempts • Add debug file output for failed parsing attempts - Writes raw LLM response to _debug_structure_attemptN.txt for inspection - Helps diagnose LLM output format issues and prompt improvements • Update error message to indicate retry attempts exhausted Diagramflowchart LR
A["Structure Step<br/>Attempt 1-3"] --> B{claudeCall<br/>Success?}
B -->|No| C["Log Error<br/>Retry if < 3"]
B -->|Yes| D{Pages<br/>Found?}
D -->|No| E["Write Debug File<br/>Retry if < 3"]
D -->|Yes| F["Return Pages"]
C -->|Retry| A
E -->|Retry| A
C -->|Max Retries| G["Return Error"]
E -->|Max Retries| H["Return Error<br/>after 3 attempts"]
File Changes1. main.go
|
Code Review by Qodo
1. Misleading final retry log
|
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.
背景
Step 1 は LLM に XML 形式で wiki ページ一覧を返してもらうステップですが、運用中に以下のような単発失敗でプロジェクト全体の生成が落ちるケースがありました。
claudeCall自体がエラーparsePagesが 0 件特に ② は LLM の出力ゆらぎなので、再実行すれば成功することが多い割に、ログにも応答内容が残らず原因が掴みづらい状況でした。
変更内容
maxRetries = 3の for ループで包む⚠️ structure attempt N failed: ...を出してリトライ⚠️ structure attempt N: no pages found in response (X bytes)を出し、応答全文を<wikiDir>/_debug_structure_attemptN.txtに書き出してからリトライ📋 structure... (retry N/3)に変えるno pages found in structure after 3 attemptsを返す(既存メッセージから "after N attempts" に変更)デバッグファイルについて
_debug_structure_attemptN.txtはparsePagesで 0 件になった時のみ書き出します。成功時には書かないため、wikiディレクトリにファイルが残っていればその回が失敗していたことが分かります。LLM がどんな形で返してきたかをそのまま確認できるので、プロンプト改善や
cleanXMLResponse/parsePagesの調整に使えます。
動作確認
_debug_structure_attempt1.txt,_2.txt,_3.txtと書き出されることを確認no pages found in structure after 3 attemptsで終了することを確認