Skip to content

fix(llm): preserve string content for empty chat turns - #52820

Open
MattVevang wants to merge 1 commit into
anomalyco:devfrom
MattVevang:empty-chat-content
Open

MattVevang wants to merge 1 commit into
anomalyco:devfrom
MattVevang:empty-chat-content

Conversation

@MattVevang

Copy link
Copy Markdown

Issue for this PR

Closes #52819. Related: #51661; historical context: #41165 / #41210.

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Use the existing text-joining helper for native Chat assistant content, including empty content. It returns "" instead of null, 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.

Build Sessions Native replay requests Nil failures
Unpatched 10 20 20
Patched, same test sequence 30 60 0
Patched reopening previously failing sessions 10 20 0

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 typecheck passed. 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.ts was 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

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

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>
@github-actions

github-actions Bot commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

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.

Native Chat replay sends null content for reasoning-only turns

1 participant