fix(llm): preserve string content for empty chat turns - #52820
Open
MattVevang wants to merge 1 commit into
Open
MattVevang wants to merge 1 commit into
MattVevang wants to merge 1 commit into
Conversation
Lower empty assistant text to an empty string while preserving reasoning and tool calls. Add regression coverage for empty and reasoning-only replay to strict Chat endpoints. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
|
The following comment was made by an LLM, it may be inaccurate: |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue for this PR
Closes #52819. Related: #51661; historical context: #41165 / #41210.
Type of change
What does this PR do?
Use the existing text-joining helper for native Chat assistant content, including empty content. It returns
""instead ofnull, preventing strict endpoints from rejecting reasoning-only replay. Reasoning, tool calls, and nonempty text joining are unchanged.Tool-only turns also get
"", matching the installed AI SDK compatible adapter. OpenAI allows null content with tool calls; this is a compatibility choice, not a schema violation claim. The nullable body schema is retained.Only the runtime line and relevant regression tests are included; local stress-test scripts, captures, and binaries are excluded.
How did you verify your code works?
On Windows with real local Ollama 0.34.4 and a Qwen reasoning model: generate a one-token reasoning-only turn through AI SDK, then resume and retry through native. A recorder forwarded request bodies unchanged; Ollama itself returned the errors.
This verifies the native replay scenario, not spontaneous default-runtime failure rates or every provider.
From
packages/llm,bun test --only-failures: 302 passed, 30 skipped;bun typecheckpassed. Regression tests cover empty/reasoning-only lowering, native reasoning metadata, and streamed response replay against a strict fixture endpoint. CLI adapter and V2 runner suites also passed (49 and 129 tests).The full-repository pre-push typecheck is blocked on this Windows checkout: the unchanged tracked symlink
packages/enterprise/src/custom-elements.d.tswas checked out as plain target-path text, causing TS1128. No unrelated files were changed; the hook was bypassed for this push with the contributor's approval.Screenshots / recordings
Not applicable: protocol-only change.
Checklist