HTTP models ignore `includeSchemaInPrompt`, so structured output fails on servers that don't enforce schemas
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 25/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- swift
- Lĩnh vực
- backend-api-design
Hướng nghiên cứu
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.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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.
- Ngôn ngữ chính
- Swift
- Star
- 959
- Fork
- 99
- Merge trung bình
- 1 ngày 10 giờ
- Pull request đã merge (30 ngày)
- 70
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của huggingface/AnyLanguageModel
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
huggingface/AnyLanguageModel#360 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Run a round's tool calls at onceĐang mở
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
huggingface/AnyLanguageModel#359 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 18/100
huggingface/AnyLanguageModel#328 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 62/100
huggingface/AnyLanguageModel#327 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Support the Gemini Interactions API in GeminiLanguageModelCó thể làm lại được @rizwankce đã nhận 17 ngày trước và không có pull request nào đang mở. Đang mở
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 45/100
huggingface/AnyLanguageModel#302 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của huggingface/AnyLanguageModel
Issue tương tự
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 85/100
521xueweihan/HelloGitHub#4101 ·
-
bug mac-app
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
tw93/Mole#1845 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 85/100
element-hq/element-x-ios#6405 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
apple/coreai-models#380 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Bug 🐞
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100
mozilla-mobile/firefox-ios#36278 ·
Maintainer thường phản hồi trong vòng 1 ngày