Skip to content

Fix decode service token loss during snapshot throttling - #2

Open
Andresit0 wants to merge 1 commit into
rexmhall09:mainfrom
Andresit0:fix/decode-service-token-throttle
Open

Andresit0 wants to merge 1 commit into
rexmhall09:mainfrom
Andresit0:fix/decode-service-token-throttle

Conversation

@Andresit0

Copy link
Copy Markdown

Summary

Fixes loss of incremental text deltas in DecodeServiceInferenceClient when snapshot events are throttled.

Root cause

DecodeServiceOutbox emits incremental textDelta values. During snapshot throttling, the previous implementation discarded deltas that arrived between emitted snapshots, causing the OpenAI-compatible server path to receive only the first visible chunk even though inference completed normally.

Fix

Accumulate throttled textDelta values in pendingVisibleText, emit the accumulated text when a snapshot is forwarded, and flush any remaining text before the terminal event.

Verification

With the real model and inference path:

Generated tokens Emitted chunks Content
Before 30 1 Man
After 30 4–5 Complete 10-fruit list

The generated token count remains unchanged; the fix prevents intermediate text from being dropped.

Scope

This PR contains only the production fix in DecodeServiceInferenceClient.swift.

Unrelated Swift 6.4/Xcode 27 compatibility changes are intentionally excluded.

Testing limitation

The repository does not currently compile cleanly with Swift 6.4 / Xcode 27 because of pre-existing region-isolation and actor-isolation diagnostics in unrelated files. Behavioral verification above was obtained with local-only compatibility workarounds plus a temporary diagnostic probe; neither is part of this PR. The fix itself is a one-file change with no new dependencies or public API.

DecodeServiceOutbox reports incremental snapshot text. The decode-service
client throttled live updates but dropped the text it skipped: once the
first visible chunk was yielded, every later .token event carried an empty
textDelta. Consumers that accumulate .token events therefore saw only the
first chunk, while generation itself completed normally (finish_reason
"stop", full completion_tokens).

AppModel hides this because it rebuilds the answer from
GenerationTranscriptMailbox. AppServerInferenceBackend, which serves
/v1/chat/completions, does not, so the endpoint returned a single word for
a full answer.

Carry the pending text forward and flush it before the terminal event.
@Osiriss664

Copy link
Copy Markdown

I have made a patch which is Swift 6.4/Xcode 27 compatible. Meaning that it works. I am not a developer so i need to Trust Claude here a bit much

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.

2 participants