llamacpp: HTTP 400 on valid unanchored JSON Schema patterns in tool definitions

Ouverte
#1,100 1 commentaire 0 réactions 0 personnes assignées Voir sur GitHub

Les mainteneurs répondent en général sous 1 jour

Personne n'a encore pris cette issue.

Évaluation

Difficulté
3/5
Temps estimé
Une demi-journée
Accessibilité débutants
45/100
Type d'issue
Bug
Clarté
Plutôt claire
Activité
Active
Stack technique
docker, go
Domaine
backend

Piste de recherche

The fix is a version bump of the llama.cpp backend pin, LLAMA_SERVER_VERSION (currently b9879), so find where that variable is set in the repo. Confirm the upstream change in ggml-org/llama.cpp#26939 is included in the new build, then run the curl reproduction with the ^ses pattern and check for HTTP 200. Done means that request succeeds and the existing tool-call tests still pass.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

Summary

Docker Model Runner's llama.cpp backend rejects any chat completion request whose tool JSON Schema contains a valid pattern that is not fully anchored with ^/$. The whole request fails with HTTP 400 before inference starts.

Upstream llama.cpp fixed this class of failure in ggml-org/llama.cpp#26939 (merged 2026-08-20), but DMR still pins LLAMA_SERVER_VERSION=b9879, which predates the fix.

Real-world impact: OpenAI-compatible clients that emit prefix patterns such as ^ses cannot use grammar-constrained tool calling with DMR.

Environment

  • Docker Desktop 29.8.2 (client 29.9.1), Windows 11 10.0.26300
  • Docker Model Runner server v1.2.8
  • Model: docker.io/ai/gpt-oss:20b
  • Backend fingerprint reported by DMR: b1-72874f5 (LLAMA_SERVER_VERSION=b9879 in the repo)

Reproduction

Minimal, standalone request (no OpenCode or other client involved):

curl -sS http://localhost:12434/engines/v1/chat/completions \
  -H 'content-type: application/json' \
  -d '{
    "model": "docker.io/ai/gpt-oss:20b",
    "messages": [{"role": "user", "content": "hi"}],
    "max_tokens": 5,
    "tools": [{
      "type": "function",
      "function": {
        "name": "demo",
        "parameters": {
          "type": "object",
          "properties": {
            "sessionID": {"type": "string", "pattern": "^ses"}
          },
          "required": ["sessionID"]
        }
      }
    }]
  }'

Result: HTTP 400

{
  "error": {
    "code": 400,
    "message": "JSON schema conversion failed:\nPattern must start with '^' and end with '$'\nPattern must start with '^' and end with '$'",
    "type": "invalid_request_error"
  }
}

A/B test, changing only the pattern:

Pattern Result
^ses HTTP 400 (schema conversion failure)
^ses.*$ HTTP 200, completion succeeds

Expected behavior

A valid JSON Schema pattern should not fail the entire request. Unsupported regex constructs should degrade gracefully (for example, fall back to an unconstrained string) as upstream llama.cpp now does, rather than returning HTTP 400.

Suggested fix

Bump LLAMA_SERVER_VERSION from b9879 to a llama.cpp build that contains ggml-org/llama.cpp#26939, or cherry-pick that change.

Additional context

  • Concrete trigger: OpenCode v2 declares the built-in subagent tool parameter sessionID as {"type":"string","pattern":"^ses"} (session IDs start with ses). The same request works against Ollama, which tolerates unanchored patterns.
  • Client-side workaround: rewrite patterns to be fully anchored (^ses → ^ses.*$) before dispatch.
  • Related: docker/model-runner#534 ("Failed to parse grammar - opencode", closed).
  • Upstream PR: https://github.com/ggml-org/llama.cpp/pull/26939
Langage dominant
Go
Étoiles
662
Forks
156
Merge moyen
15 h 26 min
PR mergées (30 j)
17

Préparer son environnement

  • Fournit un Dockerfile ou un fichier Docker Compose
  • Aucun modèle de pull request
  • Aucun guide de contribution

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de docker/model-runner

Toutes les issues de docker/model-runner

Issues similaires

Plus d'issues Go

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.