Skip to content

[responses] fix: preserve native chat template routing - #13126

Open
tzboy08 wants to merge 12 commits into
mudler:masterfrom
tzboy08:codex/fix-responses-chat-template
Open

tzboy08 wants to merge 12 commits into
mudler:masterfrom
tzboy08:codex/fix-responses-chat-template

Conversation

@tzboy08

@tzboy08 tzboy08 commented Nov 6, 2026 •

Copy link
Copy Markdown

Description

Fixes #13124.

With template.use_tokenizer_template: true, /v1/responses sends both structured messages and a non-empty flattened prompt. Backends such as vLLM interpret the prompt as a text-completion request and bypass the native chat template, so a greeting such as 你好 is continued as raw text instead of answered as a chat message.

In the shared ComputeChoices path, pass an empty backend prompt when tokenizer templates are enabled and messages are present. Keep the structured messages and tool parameters intact, preserve the original prompt for response postprocessing, and retain existing behavior for Go-side templates and text completions without messages.

Add endpoint regression coverage for string and message-array inputs, streaming and non-streaming requests, instructions, and the Go-side fallback. Document the Responses chat-template behavior under docs/content/.

Notes for Reviewers

Validation on commit 206692ce91efde6b5deb83e59c6cbc384c6fc358:

  • go test ./core/http/endpoints/openresponses ./core/http/endpoints/openai — both complete packages passed.
  • Running the new regression suite against the parent commit's inference.go via a temporary Go overlay produced the expected four native-template failures; the fallback control passed.
  • git diff --check — passed.

The automated tests stub the inference boundary; this review did not run a real Qwen/vLLM model. Deployment observations are recorded in #13124. The separate duplication issue in an older installed vLLM backend is outside this change.

golangci-lint is not installed locally, so lint has not been run. A full product build has not been run.

Signed commits

  • Yes, I signed my commits.
  • Documentation updated (docs/content/) for user-facing changes, or not applicable

The existing commit includes an Assisted-by: Codex:GPT-6 trailer.

Pass an empty prompt with structured messages when the tokenizer template is enabled so backends answer Responses input as chat instead of continuing raw text. Add routing regression tests and document the behavior.

Assisted-by: Codex:GPT-6
Signed-off-by: Tzboy <1106535856@qq.com>
@tzboy08
tzboy08 force-pushed the codex/fix-responses-chat-template branch from 58657e9 to 206692c Compare November 6, 2026 08:43
@tzboy08

tzboy08 commented Nov 19, 2026

Copy link
Copy Markdown
Author

Hi @mudler, could you take a look at this PR when you have a chance? I’ve synced it with master, resolved the merge conflict, and rerun the Responses and OpenAI endpoint tests. Both passed. Thanks!

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: Responses API bypasses native chat template with vLLM, causing text continuation instead of chat replies

1 participant