fix: remove grammar constraint to fix node-llama-cpp 3.18.1 crash#567
Draft
LevinFaber wants to merge 1 commit intotobi:mainfrom
Draft
fix: remove grammar constraint to fix node-llama-cpp 3.18.1 crash#567LevinFaber wants to merge 1 commit intotobi:mainfrom
LevinFaber wants to merge 1 commit intotobi:mainfrom
Conversation
node-llama-cpp 3.18.1 crashes during grammar-constrained generation with: 'Failed to accept token in sampler: Unexpected empty grammar stack after accepting piece' This affects BOTH Bun and Node.js - not Bun-specific as initially assumed. Changes: - Remove grammar constraint from expandQuery() - manual parsing handles output - Add missing transaction() method to Database interface (build fix) The manual parsing already correctly extracts lex:/vec:/hyde: lines from the model output, making the grammar constraint redundant anyway.
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.
Summary
Fixes crash during
qmd queryexpansion phase caused by node-llama-cpp 3.18.1 regression in grammar-constrained generation.Error:
Failed to accept token in sampler: Unexpected empty grammar stack after accepting piece: 0 (15)Root Cause
node-llama-cpp 3.18.1 (bundles llama.cpp b8390) introduced a regression where grammar-constrained generation crashes deterministically with the GBNF grammar used for query expansion. This affects both Bun and Node.js — not Bun-specific as initially assumed.
Changes
grammarparameter fromexpandQuery()generation calltransaction()method to Database interface (build fix)Why Remove Grammar Instead of Downgrade?
• Includes CVE-2025-52566 & CVE-2026-2069 fixes
• No version pinning technical debt
• Pins to old version indefinitely
• llama.cpp b8390 had no grammar fixes planned
The grammar was redundant — manual parsing already correctly extracts
lex:,vec:,hyde:lines from model output and validates types. The GBNF grammar provided no additional safety that wasn't already handled by the parser.Test Results
Verification
npm run build)Related