-
Notifications
You must be signed in to change notification settings - Fork 2
fix(watchdog): two-phase timeout + consume prompt_progress keepalives for llama.cpp
#946
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Aaronontheweb
merged 4 commits into
netclaw-dev:dev
from
Aaronontheweb:fix/watchdog-prefill-liveness
May 9, 2026
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
5dcfe94
fix(watchdog): two-phase timeout + consume prompt_progress keepalives
Aaronontheweb 41c7268
refactor(watchdog): deduplicate Promote/Refresh and fix double timer …
Aaronontheweb 021345f
refactor(watchdog): replace operation name string literals with const…
Aaronontheweb 35846af
Merge branch 'dev' into fix/watchdog-prefill-liveness
Aaronontheweb File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -74,9 +74,17 @@ public async IAsyncEnumerable<ChatResponseUpdate> GetStreamingResponseAsync( | |
| if (line is null) | ||
| break; | ||
|
|
||
| if (string.IsNullOrWhiteSpace(line) || !line.StartsWith("data:", StringComparison.Ordinal)) | ||
| if (string.IsNullOrWhiteSpace(line)) | ||
| continue; | ||
|
|
||
| if (!line.StartsWith("data:", StringComparison.Ordinal)) | ||
| { | ||
| // SSE comment lines (`:` prefix) and event-type lines — yield keepalive | ||
| // so the watchdog knows the connection is alive during prefill/queuing. | ||
| yield return KeepaliveUpdate; | ||
| continue; | ||
| } | ||
|
|
||
| var ssePayload = line[5..].Trim(); | ||
| if (ssePayload == "[DONE]") | ||
| break; | ||
|
|
@@ -173,6 +181,9 @@ private JsonObject BuildPayload(IEnumerable<ChatMessage> messages, ChatOptions? | |
| if (stream) | ||
| { | ||
| body["stream_options"] = new JsonObject { ["include_usage"] = true }; | ||
| // llama-server sends prefill progress as SSE data events when enabled. | ||
| // Harmless on servers that don't support it (unknown fields are ignored). | ||
| body["return_progress"] = true; | ||
| } | ||
|
|
||
| if (options?.Temperature is { } temperature) | ||
|
|
@@ -576,7 +587,12 @@ private static IEnumerable<ChatResponseUpdate> ParseStreamingUpdates(JsonElement | |
| contents.Add(new UsageContent(usage)); | ||
|
|
||
| if (contents.Count == 0 && finishReason is null) | ||
| { | ||
| // Content-less data events (e.g. prompt_progress during prefill) — yield | ||
| // keepalive so the watchdog timer resets while the server is working. | ||
| yield return KeepaliveUpdate; | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should prevent netclaw's watchdog from aggressively nuking sessions when the model is sending back progress reports, thinking-only updates, etc. |
||
| yield break; | ||
| } | ||
|
|
||
| yield return new ChatResponseUpdate(ChatRole.Assistant, contents) | ||
| { | ||
|
|
||
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Encourages
llama-serverto send us progress updates during prefill et al