fix: serve runtime persistence callbacks bypass engine deadlines and can stall streams/tool execution#835
Closed
sam-saffron-jarvis wants to merge 1 commit into
Conversation
…can stall streams/tool execution
Owner
|
Closing as requested: the high-confidence fixes have been applied or superseded in the current working tree. |
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.
What changed
inlinePersistContexthelper incmd/serve_runtime.gothat keeps the incoming context's cancellation and deadline while still bounding inline DB writes.persistSnapshotappendMessagesupsertPendingAssistantLockedAddMessagepath stays within the engine callback-scale deadline.Why this is high-value
These store writes run inline on the engine's streaming/tool orchestration path. Before this change, they wrapped the callback context with
context.WithoutCancel(..., 10s), which discarded the engine's 5s callback timeout and could let a slow or locked session DB stall streaming and delay tool execution for up to 10 seconds per callback.Preserving the callback context prevents that deadline bypass. The exact failure avoided is: a slow SQLite write in assistant snapshot/response/turn persistence no longer outlives the engine's callback budget and freeze the active run while waiting on DB I/O.
Validation
internal/llm/engine.goandcmd/serve_runtime.go: engine callbacks are created with a 5s callback timeout, but serve runtime callback persistence was re-wrapping those contexts withcontext.WithoutCancel(..., 10s).TestServeRuntimePersistSnapshotPreservesParentDeadlineTestServeRuntimeAppendMessagesPreservesParentDeadlineTestServeRuntimeSnapshotCallbackPreservesEngineDeadlinegofmt -w cmd/serve_runtime.go cmd/serve_runtime_test.gogo build ./...go test ./...git diff --statgit diff --check