Skip to content

Inkling 2: one empty answer delta when a stream starts withholding its reasoning - #2720

Merged
jonathan308 merged 1 commit into
devfrom
fix/inkling-withheld-reasoning-heartbeat
Nov 24, 2026
Merged

jonathan308 merged 1 commit into
devfrom
fix/inkling-withheld-reasoning-heartbeat

Conversation

@jonathan308

@jonathan308 jonathan308 commented Nov 24, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

When a streamed Inkling 2 request turns reasoning off, the model still thinks before it answers and the provider withholds that thought, so the stream carries only its role preamble until the first answer token. With a long thought the first content can arrive many seconds in.

When withholding starts, the provider now sends exactly one chunk whose delta is {"content": ""}:

  • the standard chunk envelope (id, model, created, object) as on every other chunk;
  • no role key (the line contains no role text at all), no reasoning field, no finish reason, no usage;
  • nothing derived from the withheld text, its length or its timing beyond the fact that generation started;
  • once per request; no periodic heartbeat.

An empty content delta is a legal OpenAI streaming chunk; stream parsers append it as nothing.

How: the Inkling router emits one marker event at the first withheld reasoning piece (InklingWithheldReasoningHeartbeat.event); the coordinator serving path, which alone turns it on (a task-local set around the stream's start), rewrites that frame to the chunk above (frame(rewriting:)) and claims output first, as a first content frame does. Every other path, reasoning-on Inkling streams, other models and non-streamed responses are unchanged. No new log line; withheld reasoning is still counted as reasoning and never emitted. No rendered prompt changes.

Side effects (Inkling 2, withheld reasoning, streamed, coordinator path only)

These match what a reasoning-on stream already does once its first reasoning chunk leaves:

  • Output is claimed when the empty delta leaves. A request that has sent it no longer gives way to the Mac owner's own local request, as after any first content frame.
  • The response counts as started. A strict call that fails its check after the empty delta leaves as generated (StrictToolCallPolicy) instead of being refused, since the stream is already committed.

Client note

openai-go's ChatCompletionAccumulator treats "content": "" as content state: for a reasoning-off Inkling answer that is only a tool call, JustFinishedContent() fires once with "", and the accumulated content stays "". That is a helper-signal artefact, not a message.

Test plan

  • CI (dev) on this head: InklingWithheldReasoningHeartbeatTests
    • exactly one heartbeat at the start of a withheld thought (widths 1, 7, 4096), the rest of the stream identical to the stream without it, withheld text still counted;
    • no thought, no heartbeat;
    • reasoning-on Inkling and a withheld Qwen-style thought stream unchanged;
    • calls and stops unaffected;
    • the rewritten frame's exact bytes, with no role, reasoning, usage or finish_reason text;
    • every other frame (reasoning, content, role preamble, finish, usage, [DONE]) left alone;
    • through the SDK's stream encoder: exactly one heartbeat frame.
  • Red control (draft): the router never sends it and no frame is rewritten, so these fail: aWithheldThoughtStartsWithExactlyOneEmptyAnswerDelta (3 cases), callsAndStopsAreUnaffected, theFrameIsAPlainEmptyContentChunk, theSDKStreamCarriesExactlyOneHeartbeatFrame.
  • scripts/changelog.py check.

Refactor pass: no change justified.

Components touched

  • provider-swift (Swift CLI)

Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

…s reasoning

With reasoning off, Inkling 2 still thinks and the provider withholds that
thought, so a stream sends only its role preamble until the answer. When
withholding starts, the router now emits one event the coordinator serving
path writes as a plain chunk with delta {"content": ""}: no role, no
reasoning field, no finish reason, no usage, nothing derived from the
withheld text (InklingWithheldReasoningHeartbeat). It claims output first,
as a first content frame does. Only the coordinator path turns it on;
reasoning-on Inkling streams, other models and non-streamed responses are
unchanged. An empty content delta is a legal OpenAI streaming chunk.
@jonathan308 jonathan308 added the run-ci Trigger one-shot PR CI run (auto-removed when run starts) label Nov 24, 2026
@vercel

vercel Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
d-inference-landing Ready Ready Preview Nov 24, 2026 7:05pm UTC
darkbloom-status Ready Ready Preview Nov 24, 2026 7:05pm UTC
eigen-homepages-darkbloom Ready Ready Preview Nov 24, 2026 7:05pm UTC

Request Review

This branch was successfully deployed

3 active deployments
Preview – d-inference-landing — 7b9dc044 Deployed Nov 24, 2026 by vercel[bot]
Preview – eigen-homepages-darkbloom — 7b9dc044 Deployed Nov 24, 2026 by vercel[bot]
Preview – darkbloom-status — 7b9dc044 Deployed Nov 24, 2026 by vercel[bot]
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.

1 participant