Repository navigation
Preserve tool-reply prose in whole responses and warm histories - #650
Conversation
|
Thank you, @akol1. This landed in 1.0.8 as your own commit ( We served it with Nemotron 3.5 Lightning (MLX 4-bit) on an M5 Max, against the same tree without your three PRs. Nemotron only calls tools here with thinking on (on
The streamed chat sent those sentences before and after, so whole and streamed replies now agree. The four asks that called with no prose still answer The warm-history half acts on engines that prefill the next turn in the background, which today is Qwen3.8-27B with its prompt cache on. There (M5 Max, thinking off), a streamed reply wrote "I'll check the current weather in Copenhagen for you." and one call, and the next turn as a streaming client sends it back (the joined prose, the call, a tool result) resumed 346 of its 369 prompt tokens, against 341 before, with the same 16-token reply as a server with the prompt cache off. The gap is small because the 27B already keeps a finished reply's own state, which took the old build to the end of the reply. Its background prefill, though, rendered the turn without the prose, so it never matched a streaming client's history; now it does, and adds the turn's close and the tool turn's opening. One effect worth knowing: a stored Keeping it to the two conditions and reusing the parsed result made this a quick one to review. |
The change landed rebased onto the 1.0.8 candidate as 869a3f92b with its author kept; this keeps the PR's head in the history with no change to the tree.
Problem
Whole OpenAI chat-completion replies replace message content with null whenever tool calls are present, discarding accompanying prose. The background warm-history message does the same, including after an otherwise correct streamed reply.
Change
Keep nonempty parsed prose alongside tool calls in both message construction sites; retain null content for tool-only replies. Reuse the existing parsed result without another parse or allocation. Responses and Messages already consume the shared message content and need no production changes.
Regression coverage uses the existing socketpair route harness: prose before/after a legacy tool call, one call with unchanged arguments, returned call ID retained once in background prompts, whole chat/Messages/Responses, legacy SSE, and one-call policy/tool-only boundaries.
Verification
Base:
a6aa4782(upstream main). Zig 0.17.0, macOS arm64.zig build test test-golden native -Dcpu=apple_m1: passed after correcting a test comment annotation.content: null; candidate returnedI will look it up.alongside the same single lookup call and arguments. Candidate SSE retained the same prose and single call.Limits and publication scope
The HTTP driver is a deterministic engine, not a model-quality benchmark. Three files; production fix is two conditions. No parser/template/DSML/model change, checkpoint fixture, generated binary, or local runtime artifact. Public noreply commit identity; publication trees and outgoing metadata checked for private markers.