HTTP models ignore `includeSchemaInPrompt`, so structured output fails on servers that don't enforce schemas
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 25/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- swift
- Ambito
- backend-api-design
Direzione di ricerca
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.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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.
- Lingua principale
- Swift
- Stelle
- 959
- Fork
- 99
- Merge medio
- 1g 10h
- PR unite (30g)
- 70
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di huggingface/AnyLanguageModel
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
huggingface/AnyLanguageModel#360 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 25/100
huggingface/AnyLanguageModel#359 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 18/100
huggingface/AnyLanguageModel#328 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 62/100
huggingface/AnyLanguageModel#327 ·
I maintainer di solito rispondono entro 1 giorno
-
Support the Gemini Interactions API in GeminiLanguageModelForse di nuovo libera @rizwankce l’ha presa 17 giorni fa e non c’è nessuna pull request aperta. Aperta
Difficoltà 5/5 Più di una settimana Idoneità per principianti 45/100
huggingface/AnyLanguageModel#302 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di huggingface/AnyLanguageModel
Issue simili
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 85/100
521xueweihan/HelloGitHub#4101 ·
-
bug mac-app
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 85/100
element-hq/element-x-ios#6405 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
apple/coreai-models#380 ·
I maintainer di solito rispondono entro 1 giorno
-
Bug 🐞
Difficoltà 2/5 1-3 ore Idoneità per principianti 66/100
mozilla-mobile/firefox-ios#36278 ·
I maintainer di solito rispondono entro 1 giorno