Support for Copilot-based grammar rule generation alongside the existing Claude-based approach - #3084
Merged
Merged
Conversation
Expand MCP JSON Schema conversion to support common nullable, composed, open-object, array, and local-reference forms while preserving existing catalog safety limits and runtime validation. Enable learned grammar generation for inline dynamic schemas and persist schema hashes plus stable provider/action fingerprints with generated rules. Reconcile these identities during startup and catalog refresh, suspending stale rules and falling back to normal translation when a tool changes or disappears. Rules are automatically reactivated when the original identity returns. Also expose suspended-rule status in grammar management, migrate existing grammar stores compatibly, and roll back rules that fail in-memory activation. Add focused coverage for schema conversion, tool fingerprints, manifest bindings, grammar-store migration, and stale-rule reconciliation.
…utes. Use GPT-5.6 Sol to generate grammar from confirmed request/action pairs, removing the runtime dependency on a separate Claude CLI login. Extract the shared grammar generation and parsing behavior into a provider-independent base class while retaining the Claude generator for existing CLI and API callers. Make Copilot the default generator for runtime cache population, add reliable session/client cleanup, and support injected clients for isolated tests. Document the new runtime generation strategy and add focused coverage for model selection, response handling, and resource cleanup. Validate the implementation end to end with a read-only MCP tool: the first request generates and persists a schema-aware, fingerprinted grammar rule, while repeated requests—including after a server restart—route through the NFA grammar cache with zero translation-model tokens and continue through the normal MCP validation, policy, audit, and execution path.
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.
This pull request introduces support for Copilot-based grammar rule generation alongside the existing Claude-based approach, and generalizes the grammar generation pipeline to support multiple LLM providers. It also updates the grammar rule metadata model to support additional status and identity tracking, and refines documentation to reflect these architectural changes.
Grammar Generation Pipeline Refactoring:
GrammarGeneratorclass, with provider-specific implementations forClaudeGrammarGeneratorand the newCopilotGrammarGenerator. This enables easy addition of new LLM providers. [1] [2] [3]grammarGenerator.tsto refer generically to "the model" or the provider name, rather than "Claude", to support multiple providers. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12]Copilot LLM Integration:
CopilotGrammarGeneratorclass that uses the Copilot SDK (@github/copilot-sdk) with thegpt-5.6-solmodel for grammar rule generation. [1] [2]API & Usage Changes:
populateCachefunction to accept either aGrammarGeneratorinstance or a Claude model string, defaulting to Copilot if not specified. This allows runtime selection of the LLM provider. [1] [2]actionGrammar.mdto describe the four available grammar generation strategies, including the new Copilot-based generator as the default.Grammar Rule Metadata Model Updates:
StoredGrammarRuletype with new fields:schemaHash,actionBinding,status, andinvalidationReasonto support rule status tracking and schema identity. Added related types for schema identity and reconciliation. [1] [2]Exports and Internal API:
These changes make the grammar generation system more flexible and future-proof, allowing for the integration of additional LLMs and improved tracking of grammar rule provenance and status.