Repository navigation
Accept sticky history suffixes only when they continue the cache (#300) - #301
Merged
Merged
Conversation
Workers with a sticky cache advertise sticky_history_suffix v1 (server#1017). A suffix answer is used only on a sticky hit whose cached history ends at exactly history_after_sequence and whose events run gap-free to history_last_sequence; anything else drops the entry and refetches full history from the start. The completion claim reports the cached last sequence when the Server supports suffixes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
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.



Python half of
sticky_history_suffixv1 (server#1017), ported from sdk-php#384 (shipped in PHP SDK 3.14.0). Closes #300.Change
sticky_history_suffixandcapability_manifest.sticky_history_suffix = {supported: true, minimum_protocol_version: "1.18", version: 1}. Support is read from the Server'sserver_capabilities.sticky_history_suffix(supported: true, version: 1).history_after_sequence = N > 0goes through_load_suffix_history. Any further suffix pages are fetched first. The suffix is used only onsticky_hit_expectedwhen the cached history ends at exactly N and the events run gap-free from N+1 tohistory_last_sequence. Anything else drops the entry, countsforced_cold_replayand refetches fromMA==(base64("0")) on the current lease. A suffix is never treated as full history.history_last_sequence, the last cached sequence.history_after_sequenceabsent or 0, which is every pre-3.5.0 Server, keep the existing path unchanged.Tests
tests/test_sticky_history_suffix.py: the five server#1017 vectors (hit, gap, overlap, non-contiguous, cold), plus a suffix that ends short, a boundary that differs from the cache, empty suffixes, a paged suffix, a suffix outside a sticky hit, a Server without suffix support, boundary 0, and the claim field.TestStickyWorkerRegistration: advertisement and Server-support parsing (version1 only).sticky-history-suffix-gap-refetchesdrives the real worker through a hit (no fetch) and a gap (oneMA==refetch).🤖 Generated with Claude Code