HTTP models ignore `includeSchemaInPrompt`, so structured output fails on servers that don't enforce schemas
Les mainteneurs répondent en général sous 1 jour
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Accessibilité débutants
- 25/100
- Type d'issue
- Bug
- Clarté
- Clairement spécifiée
- Activité
- Active
- Stack technique
- swift
- Domaine
- backend-api-design
Piste de recherche
Start by tracing how includeSchemaInPrompt is handled in the existing MLX, llama.cpp, and Core ML models, then compare that with the Ollama, OpenAI, Open Responses, Anthropic, and Gemini request paths. The issue describes adding schema instructions to the last transcript entry before provider message conversion, while retaining each server's schema field. Done means streaming, non-streaming, and post-tool-round tests cover every HTTP model; a proposed fix and tests are already available in a linked branch.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
Summary
The HTTP language models send a response schema only to the server (format, response_format, output_config, responseSchema), and ignore includeSchemaInPrompt. When the server doesn't enforce the schema, the model never sees it, answers in prose, and respond(generating:) throws typeMismatch.
Ollama's cloud models are one such server: they accept format and ignore it (ollama/ollama#12362). Some OpenAI-compatible servers do the same with response_format.
To reproduce
@Generable
struct Greeting {
let text: String
}
let session = LanguageModelSession(model: OllamaLanguageModel(model: "deepseek-v4.1-flash:cloud"))
let greeting = try await session.respond(to: "Say hello.", generating: Greeting.self)
// Throws DecodingError.typeMismatch: the model answered in plain text.
The same code works with a local model such as qwen3:8b, because the local Ollama server enforces format.
Cause
includeSchemaInPrompt is true by default. MLX, llama.cpp, Core ML and Foundation Models honor it by saying the schema in the prompt. Ollama, OpenAI, Open Responses, Anthropic and Gemini accept it but never use it.
Proposed fix
Make the HTTP models honor includeSchemaInPrompt the way the local ones do:
- When
includeSchemaInPromptistrueand the response type isn'tString, each HTTP model (Ollama, OpenAI, Open Responses, Anthropic, Gemini) appends the schema instructions as a text segment to the last prompt entry of the request's transcript, before converting it to the provider's messages. - The schema is still sent to the server as today (
format,response_format,output_config,responseSchema). - The private
schemaPrompt(for:)copies in MLX, llama.cpp and Core ML become one sharedGenerationSchema.schemaPrompt(), which states the inlined schema.
A branch with this and tests for every HTTP model (streaming, non-streaming, after a tool round) is ready as a PR: akbashev:fix/schema-in-prompt.
Still a problem after the fix
Servers that enforce a schema constrain decoding, so the model can only produce valid output. Servers that don't, like Ollama Cloud (ollama/ollama#12362), let it write anything: the schema in the prompt is only an instruction, and models sometimes ignore it, especially after tool calls. With beam:cloud, about half of the answers after several tool calls were still prose, so typeMismatch.
- Langage dominant
- Swift
- Étoiles
- 959
- Forks
- 99
- Merge moyen
- 1 j 10 h
- PR mergées (30 j)
- 70
Préparer son environnement
Ce projet ne fournit ni conteneur de développement, ni Dockerfile, ni guide de contribution : l'installation est à votre charge. Commencez par son README, et consultez notre guide de la première contribution pour les étapes générales.
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de huggingface/AnyLanguageModel
-
Difficulté 5/5 Plus d'une semaine Accessibilité débutants 35/100
huggingface/AnyLanguageModel#360 ·
Les mainteneurs répondent en général sous 1 jour
-
Run a round's tool calls at onceOuverte
Difficulté 5/5 Plus d'une semaine Accessibilité débutants 25/100
huggingface/AnyLanguageModel#359 ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 4/5 3-5 jours Accessibilité débutants 18/100
huggingface/AnyLanguageModel#328 · 2 commentaires ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 3/5 1-2 jours Accessibilité débutants 62/100
huggingface/AnyLanguageModel#327 ·
Les mainteneurs répondent en général sous 1 jour
-
Support the Gemini Interactions API in GeminiLanguageModelPeut-être à nouveau libre @rizwankce l’a pris il y a 18 jours, et aucune pull request n’est ouverte. Ouverte
Difficulté 5/5 Plus d'une semaine Accessibilité débutants 45/100
huggingface/AnyLanguageModel#302 · 2 commentaires ·
Les mainteneurs répondent en général sous 1 jour
Toutes les issues de huggingface/AnyLanguageModel
Issues similaires
-
a:bug
Difficulté 2/5 1-3 heures Accessibilité débutants 83/100
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 68/100
vorssaint/vorssaint-utils#3527 ·
Les mainteneurs répondent en général sous 1 jour
-
bug iOS UI
Difficulté 2/5 1-3 heures Accessibilité débutants 68/100
devsoc-unsw/freerooms-mobile#278 ·
-
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
rorkai/App-Store-Connect-CLI#3192 ·
Les mainteneurs répondent en général sous 1 jour
-
bug
Difficulté 2/5 1-3 heures Accessibilité débutants 65/100
jellyfin/Swiftfin#2388 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour