fix: Progressive runs ignore cancellation while persisting synthetic follow-up/finalization turns#791
Closed
sam-saffron-jarvis wants to merge 1 commit into
Closed
Conversation
…follow-up/finalization turns
Owner
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()for progressive synthetic continuation/finalization persistence with a short derived context that honors the active progressive run's cancellation/deadlineprogressiveSyntheticUserMessageContextto boundOnSyntheticUserMessagecallbacks to 5 seconds at most, while still stopping immediately when the parent progressive context is canceled or times outWhy this is high-value
Progressive runs persist synthetic user turns through callbacks that ultimately write to the session SQLite store. Those writes can block behind SQLite busy/retry handling. Before this change, those two persistence calls used
context.Background(), so a timed-out run, canceled job, or Ctrl-C could stay stuck persisting synthetic turns long after the progressive run was supposed to stop.This fix closes that shutdown hole on the real
ask --progressive/ progressive jobs path without changing the broader progressive control flow.Validation
gofmt -w cmd/progressive.go cmd/progressive_test.gogo build ./...go test ./cmd -run 'TestRunProgressiveSessionSyntheticContinuationPersistenceHonorsContext|TestAttemptProgressiveFinalizationSyntheticPersistenceHonorsContext|TestRunProgressiveSessionTimeoutDoesNotStartDetachedFinalizationAfterDeadline|TestRunProgressiveSessionFinalizesOnNaturalCompletion'git diff --checkgo test ./...was run twice; the suite still hits the pre-existing unrelated flaky failure ininternal/tools(TestRunAgentScriptTool_TimeoutKillsGrandchildren) when the entire repo is run together, but that test passes when rerun in isolation viago test ./internal/tools -run TestRunAgentScriptTool_TimeoutKillsGrandchildren -count=1 -v