fix: return best attempt on heal loop exhaustion (v1.14.4)#192
Merged
Conversation
When all heal-loop paths are exhausted, return the last attempted response instead of raising RuntimeError. Sets kalibr_heal_exhausted=True on the response so callers can detect the exhausted state. Only raises if no response was ever received (e.g. network failure before any bytes arrived). Prevents benchmarks from counting partial/low-quality results as hard failures with model='error'. Closes: heal-loop-exhaustion-raises
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.
Problem
When the heal loop exhausts all paths, it raises
RuntimeError, causing benchmarks to record a hard failure withmodel="error". A partial or low-quality response is better than an exception for most callers.Fix
In
kalibr/router.py, whenheal_result['success']isFalsebutheal_result['response']is notNone, return the last attempted response instead of raising.New response attributes set on exhausted return:
kalibr_healed = True— the heal loop was triggeredkalibr_heal_exhausted = True— all paths were tried without passing Gate 1/2kalibr_heal_count— number of repair attempts madekalibr_models_tried— list of models attemptedkalibr_model_used— final model triedRuntimeErroris still raised iflast_responseisNone(no bytes were ever received — e.g. pure network failure).Testing
Callers can detect exhaustion via:
Checklist
kalibr/router.py1.14.3→1.14.4inpyproject.tomlCHANGELOG.mdupdated