Skip to content

Fix compatibility issues and improve error handling in Navie #2253

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

dividedmind
Copy link
Collaborator

Migrate from better-sqlite3 to node-sqlite3-wasm for 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

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).
@dividedmind dividedmind self-assigned this Feb 24, 2025
Copy link
Contributor

@kgilpin kgilpin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@dividedmind
Copy link
Collaborator Author

dividedmind commented Feb 24, 2025

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Stack trace / error with Copilot + Sonnet related to counting tokens
2 participants