Skip to content

server: logprobs with tools, stop strings, reasoning and the Responses API - #3206

Closed
ashhart wants to merge 3 commits into
mainfrom
lead/logprobs-tools-stop-responses
Closed

ashhart wants to merge 3 commits into
mainfrom
lead/logprobs-tools-stop-responses

Conversation

@ashhart

@ashhart ashhart commented Nov 13, 2026

Copy link
Copy Markdown
Owner

Chat completions now serve logprobs together with tools, stop strings, structured output and a thinking budget, and the Responses API serves them too. Until now each of these was refused with HTTP 400.

What changed

  • Entries come from the target rows the engine already returns. The reply is decoded, stopped and parsed as before; only then are its tokens' bytes matched to what the reply shows. logprobs.content covers the prose, logprobs.reasoning_content the reasoning, and logprobs.tool_calls holds one {index, content} group a call with the entries of the markup the model wrote. A call dropped by parallel_tool_calls: false gets none and is not read as prose.
  • A stop string trims the entries with the text. A token the text shows only part of keeps its own logprob and alternatives, shows the kept bytes, and names itself in token_id.
  • A stream without tools still sends each entry with the chunk whose text completes its token, reasoning entries before the answer's first text. With tools, the entries come in one chunk before the finishing one, once the calls are parsed. Joined over a stream they equal the whole reply's.
  • Responses: top_logprobs or include: ["message.output_text.logprobs"] fill output_text.logprobs and the delta and done events, with extensions on reasoning parts and function-call items. include alone on an engine without logprobs answers as before, without them.

Why text and tokens are unchanged: the engine's request differs only in asking for rows, as a plain logprobs request already does; sampling, grammar masks, drafts, stops and the tool parser run unchanged, and the projection only reads the finished tokens and rows. With logprobs off nothing new runs per token. Host tests check, for each combination, that the message and token_ids are identical with logprobs on and off, and that every entry equals the same token's entry in a plain request.

Tests

  • zig build test-logprob-offers-host: 38 pass, including new tests for tools, stops inside a token and across rounds, thinking budgets, dropped calls, structured output and Responses, whole and streamed.
  • zig build test-server-cpu: 1352 pass, 7 skipped. test-tool-parse-host and test-cuda-host pass.
  • zig fmt --check, git diff --check, and the lean check with no new findings.

Still owed: a live check on a served model (chat and Responses, whole and streamed, with tools, stops and a thinking budget), comparing text, token ids and entries with logprobs on and off, and decode speed with logprobs off.

Fixes #3186

  • Synthena (Ash's Agent)

@ashhart
ashhart force-pushed the lead/logprobs-tools-stop-responses branch 2 times, most recently from 0644bf7 to aabf8ec Compare November 14, 2026 02:29
…s API

Chat completions serve logprobs with tools, stop strings, structured output
and a thinking budget, from the rows the engine already returns: prose,
reasoning and each tool call get their own entries, a stop string trims the
entries with the text, and a token the text shows only part of keeps its
row with the bytes it shows and its token_id. A stream without tools sends
each entry with the chunk that completes its token; with tools the entries
follow once the calls are parsed. The Responses API carries them in its
output items and delta events. Text and tokens are the same with logprobs
on or off.

Fixes #3186
After the rebase, a /v1/responses logprobs ask on an engine without rows was
refused by the chat plan's writer, which omits the param and code fields the
route's own refusals carry. Refuse in the turn before the chat runs, through
the route's writer, with main's message; include alone still serves without
rows, as before.
@ashhart
ashhart force-pushed the lead/logprobs-tools-stop-responses branch from aabf8ec to 566e933 Compare November 14, 2026 04:48
ashhart added a commit that referenced this pull request Nov 14, 2026
…elf, which its landing missed); #3206's changelog line
@ashhart

ashhart commented Nov 14, 2026

Copy link
Copy Markdown
Owner Author

This landed on main as 56166e8, 9144f4e and 3d83e77 (your head 566e933, rebased), but by a mistake on our side: it went in with #3298 instead of through the landing train. Its own CI was green (zig, zig-windows, pytest), and the changelog line is now on main through #3300. The device check it skipped (Qwen3.8-27B on an M5 and on a GB10, main before it against main with it) is running now. If it comes back red, we revert and land it again through the train.

  • Synthena (Ash's Agent)

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.

Logprobs with tools, stop strings, reasoning and the Responses API

1 participant