Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: ggml-org/llama.cpp
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: master
Choose a base ref
...
head repository: ochafik/llama.cpp
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: token-aware-grammars-impl
Choose a head ref
Checking mergeability… Don’t worry, you can still create the pull request.
  • 6 commits
  • 16 files changed
  • 2 contributors

Commits on Dec 19, 2025

  1. chat: add FunctionGemma tool call support

    Implements tool call handling for FunctionGemma models which use a
    unique format: <start_function_call>call:name{key:<escape>val<escape>}<end_function_call>
    
    Changes:
    - Add COMMON_CHAT_FORMAT_FUNCTION_GEMMA enum
    - Implement grammar builder for FunctionGemma format
    - Implement parser for FunctionGemma tool calls
    - Add template detection for <start_function_call> markers
    - Add google-functiongemma.jinja template
    - Add unit tests and e2e test entries
    
    🤖 Generated with [Claude Code](https://claude.com/claude-code)
    
    Co-Authored-By: Claude <noreply@anthropic.com>
    ochafik and claude committed Dec 19, 2025
    Configuration menu
    Copy the full SHA
    622acae View commit details
    Browse the repository at this point in the history
  2. fix(functiongemma): parser and template bug fixes

    Parser: Use state machine to find closing brace, properly handling `}`
    characters inside `<escape>` delimiters. Previously used [^}]* regex
    which would break on values like `{key:<escape>foo}bar<escape>}`.
    
    Template: Output tool calls in native FunctionGemma format
    `{key:<escape>value<escape>}` instead of JSON format `{"key":"value"}`.
    This ensures the model sees correct examples in conversation history.
    
    🤖 Generated with [Claude Code](https://claude.com/claude-code)
    
    Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
    ochafik and claude committed Dec 19, 2025
    Configuration menu
    Copy the full SHA
    a424920 View commit details
    Browse the repository at this point in the history
  3. peg-parser: add preserved() for token-aware matching

    Add common_peg_preserved_parser type that matches preserved tokens
    (like <tool_call>, <escape>) at the token level when token info is
    available, with graceful fallback to text matching.
    
    New features:
    - common_peg_token_span struct for token boundary info
    - common_peg_parse_context extended with optional token spans
    - preserved(literal, token_id) builder method
    - Token-aware matching: if token_id set and context has tokens,
      match by token ID; otherwise fall back to text
    
    This is the infrastructure for token-aware grammars as described in
    docs/development/token-aware-grammars.md.
    
    🤖 Generated with [Claude Code](https://claude.com/claude-code)
    
    Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
    ochafik and claude committed Dec 19, 2025
    Configuration menu
    Copy the full SHA
    e47e909 View commit details
    Browse the repository at this point in the history
  4. peg-parser: add tests for preserved() token-aware matching

    Add comprehensive tests for the preserved parser:
    - Text fallback (success, fail, partial)
    - Token-aware matching when token info available
    - Token mismatch detection
    - Sequence with preserved tokens
    - Qwen3-Coder-like parser demo (with and without token info)
    
    The tests demonstrate how preserved() enables parsers to match
    special tokens at the token level when token boundary info is
    available, falling back to text matching otherwise.
    
    🤖 Generated with [Claude Code](https://claude.com/claude-code)
    
    Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
    ochafik and claude committed Dec 19, 2025
    Configuration menu
    Copy the full SHA
    4bb89a0 View commit details
    Browse the repository at this point in the history
  5. peg-parser: rename preserved() to token(), resolve token IDs at runtime

    - Rename common_peg_preserved_parser to common_peg_token_parser
    - Rename preserved() method to token() for cleaner API
    - Token IDs are now resolved at parse time from context's token_ids map
      instead of being hardcoded in the parser definition
    - Add token_ids map to common_peg_parse_context for runtime resolution
    - Update FunctionGemma parser to use new token() API
    - Wire up FunctionGemma PEG parser (COMMON_CHAT_FORMAT_PEG_FUNCTION_GEMMA)
    - Update all tests to use new token() method and provide token_ids map
    
    🤖 Generated with [Claude Code](https://claude.com/claude-code)
    
    Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
    ochafik and claude committed Dec 19, 2025
    Configuration menu
    Copy the full SHA
    feab6dc View commit details
    Browse the repository at this point in the history

Commits on Dec 20, 2025

  1. grammar: add @"..." token-aware literal syntax

    Add LLAMA_GRETYPE_TOKEN_LITERAL for token-aware grammar matching:
    - Matches by token ID when literal resolves to single token
    - Falls back to character-by-character matching otherwise
    
    Also adds until_token() to PEG parser and updates to_gbnf() to emit
    @"..." syntax for token() primitives, enabling token-aware constrained
    decoding in generated grammars.
    
    🤖 Generated with [Claude Code](https://claude.com/claude-code)
    
    Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
    ochafik and claude committed Dec 20, 2025
    Configuration menu
    Copy the full SHA
    005780d View commit details
    Browse the repository at this point in the history
Loading