fix: make complex connectors compatible with llama.cpp grammar - #272
fix: make complex connectors compatible with llama.cpp grammar#272xDenside wants to merge 1 commit into
Conversation
|
Thanks for this, @xDenside — the diagnosis is exact and the fix is narrower than it had to be, which is the right instinct. Projecting the schema rather than dropping tools means a user with a large connector catalogue keeps every tool and only loses constraints the MCP server re-checks anyway; linking the specific Verified on your branch merged onto current
I also checked the projection independently rather than reading the diff, because a recursive schema walker is easy to get subtly wrong. I built a schema that hides expansion keywords at every nesting construct the walker knows about — One thing I want to record because it's the question a reviewer would ask next: this is the only path that needs it. Including Two questions and two nits. Nothing here blocks. 1. What are the numbers after?You give the before precisely — 168 KB, 596 rules, 25 tools. The description never says what it becomes. That's the measurement that shows the fix clears the threshold rather than merely moving toward it, and it's the number the next person will want when a bigger catalogue fails. Related: integer 2.
|
|
Thanks for chasing this down — the diagnosis here (Firecrawl's 25 tools expanding into a 168 KB / 596-rule grammar, and llama.cpp's Closing this as superseded: the same fix has since landed on
Net effect is identical for the Firecrawl case, so there is nothing left to port from this branch. Sorry for the duplicated effort — that is on our side for not flagging the overlap sooner. We truly appreciate your help in making Atomic Chat better! |
Summary
llamacppandllamacpp-upstreamchat requestsWhy
Firecrawl connects successfully, but its 25 tools expand into a 168 KB, 596-rule grammar containing bounds such as
char{0,10000}and arrays up to 100 items. The shipped llama.cpp parser rejects the grammar before generation when repeated-rule complexity reaches its safety threshold, producingFailed to initialize samplers: failed to parse grammar. The same class of failure appears with other large connector catalogs and under both llama.cpp providers.This projection avoids the grammar compiler limit without silently dropping tools. A model can produce an argument outside a removed validation constraint, but the MCP server still validates its original contract and returns the normal tool error.
Verification
DropdownModelProvider.connected.test.tsx)Upstream guard
The b10431 llama.cpp backend uses
MAX_REPETITION_THRESHOLD = 2000and rejects a bounded repetition whenprevious_rule_complexity * repetition_countreaches that limit: https://github.com/ggml-org/llama.cpp/blob/b10431/src/llama-grammar.cpp#L485-L496