Repository navigation
Conversation
…tles Canceling a task that an approval or ask-user answer had resumed waited up to 30s for Claude to reach a hook and stop by itself. When Claude was in a model call or a long tool after the replayed call returned, no hook fired, so CancelTask failed with "runtime cancellation cleanup failed: context deadline exceeded" and the session could not be deleted. Once the replayed call has its result, the rest of the turn is ordinary work, so the driver now stops it like any other turn and records the replay as canceled, so a restored harness does not report the session as abandoned. A cancel that arrives before the result still waits for Claude to settle it. Fixes kagent-dev#3314 Signed-off-by: Arunkumar Eli <elrarun@gmail.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.
Fixes #3314
Canceling a task that an approval or ask-user answer resumed waited up to 30s for Claude to reach a hook and stop by itself. If Claude was in a model call or a long tool after the replayed call returned, no hook fired, so CancelTask failed with
runtime cancellation cleanup failed: context deadline exceededand the session couldn't be deleted.Once the replayed call has its result, the rest of the turn is ordinary work:
consumenotes when the replayed call's tool result arrives, and after that a cancel stops the process like any other turn. This also covers a cancel that started cleanup just before the result arrived.Resume(andCancel, for its own replay) then records the journal as canceled, so a restored harness doesn't read it as an unfinished replay and returnErrSessionAbandoned.Tests:
TestDeferredReplayCancelsAfterItsCallSettlescovers both orderings (result then cancel, cancel then result). Both fail on main after the 30s timeout and pass with the fix,-race -count=10.TestSessionCancelAfterAskUserAnswer(e2e, all harnesses): ask, answer, hold the next model call open, cancel. On main the claude case fails with the error above; with the fix all four pass. Ran on a local kind cluster set up like CI (gvisor); the full e2e suite passed apart fromTestBuiltinHarnessDefaultImages/claude, which fails locally only because I rebuilt the claude image after packaging the chart.