Repository navigation
fix(agent): isolate cancellation of shared context estimates - #19
Merged
w01fb0ss merged 2 commits intoNov 25, 2026
Merged
Conversation
Keep the per-session estimate running for other callers when an individual request is cancelled. Signed-off-by: agooll <141763834+agooll@users.noreply.github.com>
Signed-off-by: agooll <141763834+agooll@users.noreply.github.com>
Owner
|
Thanks for the clear report and the focused fix! I traced it through |
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 and why
Fixes #18. Concurrent context estimates for one session share a file read. The shared calculation used the first caller's cancellation signal, while a later caller awaited the shared promise without applying its own signal.
Apply cancellation to each caller's wait and keep the in-flight entry until the shared calculation settles. Both callers can still reuse a single read.
Checks
pnpm verifypasses locally.envfiles or local pathsBoth cancellation arrangements failed before the fix. The Agent Vitest project passed all 65 tests with the patch. Biome and
git diff --checkpassed. The regression uses a temporary session file and a gated runtime fixture.