Fix compatibility issues and improve error handling in Navie#2253
Fix compatibility issues and improve error handling in Navie#2253dividedmind wants to merge 8 commits intomainfrom
Conversation
Fixes Stack trace / error with Copilot + Sonnet related to counting tokens #2232
Unlimited number of subdirectory entries can easily blow up context length (eg. when one of the subdirectories is node_modules). Instead if the number of entries is high (currently hardcoded to a limit of 100) just pass the number of entries; the gatherer can request a directory listing explicitly when needed (the limit doesn't apply to toplevel entries).
kgilpin
left a comment
There was a problem hiding this comment.
Looks good. The main thing I couldn’t understand is why the token reducer was refactored. Unless there was a bug? But then it would have been a fix commit.
I noticed that the token reducer spins when the token count estimate is wrong, trying to send the exact same request repeatedly. Solving this needed cooperation between the reducer and the completion service, which was difficult to implement with the Java-ish design, so I refactored it to be simpler and more idiomatically JS — @dustinbyrne said he was ok with that. You're right I should have split that into two commits; anyway, the end result is that if after reducing we're still getting token exceeded, we're adding a 10% margin before trying again. The new estimated max token count is remembered so it doesn't have to spin next time. Also, the input is truncated up front if it's too large (according to the latest max token count estimate). |
Migrate from
better-sqlite3tonode-sqlite3-wasmfor better compatibility. Remove deprecated dependencies and reduce console error noise related to token counting with Copilot and Sonnet. Limit the number of subdirectory entries to prevent context overflow. Add performance measurements and code formatting tools to enhance development experience.Fixes #2232