Repository navigation
Conversation
register_interrupt_callback registered asyncio.current_task() in StreamInterruptRegistry together with an on_interrupt closure that persisted the interrupted turn, and returned a dual-persist guard. It exists only for the ASGI task-cancel interrupt model, which the PAI CancellationToken migration replaces (design sections 4.2, 4.3, 4.7). Remove the function. generate_agent_response now starts with a local persist_guard of [False]; its CancelledError handler, uncancel() and the deregister_stream call in finally stay unchanged. Tests: drop the unit test of the removed function, the patches that stubbed it with [False], and the guard tests that simulated on_interrupt persisting first (that scenario no longer exists). The autouse stream_interrupt_mocks fixture no longer patches get_stream_interrupt_registry: register_interrupt_callback was its only caller, so the fixture now patches deregister_stream alone. The turn persistence integration tests interrupt a stream by cancelling the task that consumes it, as a client disconnect does, instead of through the registry, so they keep checking that an interrupted turn is stored once. Nothing registers a stream any more, so on this feature branch the interrupt endpoint returns 404 for live streams until LCORE-4733 mints and registers a token per run. Removing persist_guard, uncancel() and the CancelledError interrupt path is LCORE-4735.
StreamInterruptRegistry held the asyncio task serving the SSE response and an interrupt cancelled that task. Per design sections 4.2-4.3 it becomes an ownership and cancellation index: request_id -> owning user + the agent run's CancellationToken (+ conversation_id). ActiveStream holds user_id, token and conversation_id; register_stream takes the token where the task was. Under the registry lock cancel_stream returns NOT_FOUND, FORBIDDEN (warning log kept), ALREADY_DONE when the token is already cancelled, or calls token.cancel() and returns CANCELLED, so exactly one interrupt call reports interrupted=true. No task cancel, callback, persistence or SSE. Tests: a parametrized registry test covers all four outcomes, one of them after deregister_stream; the endpoint unit tests and the integration round trip use real tokens and assert token.cancelled. Left to sibling stories: token per run (LCORE-4733), RunCancelled finalize (LCORE-4734), CancelledError path removal (LCORE-4735), endpoint wording (LCORE-4736). Live interrupt returns 404 until 4733.
…pt-cancellation-token LCORE-4732: Cancel streams through a PAI CancellationToken in StreamInterruptRegistry
…errupt LCORE-4731: merge main into feature/stream-interrupt
Contributor
|
Caution Review failedThe pull request is closed.
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
|
🤖 Finished Review · ⏭️ Skipped (PR #3185 is already closed) · Started 1:26 PM UTC · Completed 1:26 PM UTC Commit: Effort: high |
|
Review skipped — this PR is already closed. The Posted by fullsend pre-review check |
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.
Description
Type of change
pyproject.toml+uv.lock]requirements.*.txtfor Konflux]Tools used to create PR
Identify any AI code assistants used in this PR (for transparency and review context)
Related Tickets & Documents
Checklist before requesting a review
Testing