feat: implement StuckLoopHook for repeated dispatch termination - #30
Merged
Conversation
Adds `StuckLoopHook` to `rig-compose::reliability` to detect and terminate infinite tool-dispatch loops when the model requests the exact same tool invocation repeatedly.
There was a problem hiding this comment.
Pull request overview
Adds a StuckLoopHook to rig_compose::reliability that implements ToolDispatchHook and terminates dispatch when the same tool invocation (identified via ToolCallFingerprint) is requested more than max_identical_calls times. Re-exports the new type from the crate root, updates the changelog, and adjusts the roadmap to reflect that stuck-loop, retry, and result-size policies are now covered.
Changes:
- New
StuckLoopHookwithbefore_invocationreturningTerminate { reason }once the per-fingerprint count exceeds the threshold, plus two async unit tests covering threshold and multi-tool tracking. - Public re-export of
StuckLoopHookfromsrc/lib.rs. - Documentation updates in
CHANGELOG.mdandROADMAP.md.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/reliability.rs | Adds StuckLoopHook struct, ToolDispatchHook impl, module-level doc bullet, and tests. |
| src/lib.rs | Re-exports StuckLoopHook from the reliability module. |
| ROADMAP.md | Drops retry/result-size/stuck-loop from the list of unbuilt policies. |
| CHANGELOG.md | Adds an "Added" entry under Unreleased noting the new hook. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
What
Adds
StuckLoopHooktorig_compose::reliabilityto detect and terminate infinite tool-dispatch loops when the model requests the exact same tool invocation repeatedly.Why
This satisfies the final piece of the Govern tool/result reliability roadmap item: terminating repeated-loops around dispatch to prevent runway costs in cases where models are repeatedly failing to adapt to a tool outcome and re-issuing identical requests.