Stop the tool-call repair recursing into itself - #63
Merged
Conversation
`repairUnansweredToolCalls` took an id source named `newId` defaulting to `newId()`. Inside the default, `newId` resolves to the parameter, not the import, so the default calls itself until the stack goes. It hangs exactly when the function does its job: the parameter is only invoked on the repair branch, and the one real caller omits the argument. Every test passed its own ids, which is why no test ran the default and why this survived. Renamed so it cannot shadow the import, and there is now a test that calls it the way the real caller does, with the argument left out. Found by Guido Vizoso. Biome had said so too, as an unused import on line 2, which I had waved through as a warning.
davidmckayv
requested review from
MikeRyanDev,
guidovizoso and
tylerslaton
as code owners
August 20, 2026 22:54
guidovizoso
approved these changes
Aug 20, 2026
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 this changes
repairUnansweredToolCallstakes an id source so tests can make ids predictable:Inside that default,
newIdresolves to the parameter, not the import on line 2. The defaultcalls itself until the stack goes. Introduced by #62.
It hangs exactly when the function does its job. The parameter is only invoked on the repair branch,
reached when there is an unanswered tool call, and the one real caller
(
channel-chat.tsxL228) omits the argument. Every existing test passes its own ids, so no test everran the default.
Renamed the parameter so it cannot shadow the import, and added a test that calls it the way the
real caller does.
Found by @guidovizoso. Biome had flagged it too, as
noUnusedImportson line 2, which I wavedthrough as a warning when I made the change.
Where it runs
Boundary and audit
Changelog
Proof
The new test fails on the old code by hanging rather than by asserting, which is the honest
reproduction. 745 tests pass,
biome checkclean on both files, typecheck clean.