fix: Response completion uses an unbounded context for durable-ID lookup and can leave runs stuck in_progress forever#871
Closed
sam-saffron-jarvis wants to merge 1 commit into
Conversation
…kup and can leave runs stuck in_progress forever
Owner
|
Implemented in local copy: durable response-id lookup on completion now uses a bounded best-effort context and falls back to the ephemeral response id on lookup failure/timeout. Verified with go build ./... and targeted tests. |
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
context.Background()durable response-id lookup on the response completion path with a short best-effort lookup that usescontext.WithTimeout(context.WithoutCancel(runCtx), 5*time.Second)resp_*id if the durable-id lookup errors or times out, so completion still proceeds and terminal events are emittedWhy this is high-value
This is on the core
/v1/responsessuccess path. Before this change, a completed model run could block forever waiting forGetLatestVisibleMessageIDon the single pooled SQLite connection, because the lookup used an unbounded background context. When that happened, the run never reachedrun.complete(...), clients never receivedresponse.completed/[DONE], the session stayed busy, replay subscribers hung, and shutdown waited on the stuck run.Bounding the lookup and treating it as best-effort preserves the intended durable-id behavior when the store is healthy, while guaranteeing the run can still finish and clear its active-run bookkeeping if the store is slow or wedged.
Validation
gofmt -w cmd/serve_response_runs.go cmd/serve_response_runs_test.gogo build ./...go test ./...git diff --statgit diff --check