Repository navigation
fix(cloud-agent): handle stream churn - #57079
Merged
Merged
Conversation
Contributor
Prompt To Fix All With AIFix the following 2 code review issues. Work through them one at a time, proposing concise fixes.
---
### Issue 1 of 2
products/tasks/backend/temporal/process_task/activities/tests/test_relay_sandbox_events.py:337-364
**Missing unit tests for `_is_keepalive_event`**
`_is_keepalive_event` is a new exported helper analogous to `_is_session_update` and `_is_end_of_turn`, both of which have dedicated parameterized test classes. There are no direct unit tests for `_is_keepalive_event`, leaving the new reset-skipping logic (`if not _is_keepalive_event(event_data): reconnect_count = 0`) covered only implicitly by the integration test. A small parameterized suite (e.g. `{"type": "keepalive"} → True`, `{"type": "notification"} → False`, `{} → False`) would make the contract explicit and consistent with the rest of the file.
### Issue 2 of 2
products/tasks/backend/temporal/process_task/activities/tests/test_relay_sandbox_events.py:337-364
**`_mark_complete_if_run_is_terminal` `DoesNotExist` branch is untested**
The existing `_mark_error_unless_run_is_terminal` has a dedicated test for the `DoesNotExist` case (see `test_missing_run_marks_stream_error_on_relay_error`). The new `_mark_complete_if_run_is_terminal` has the analogous branch — `mark_error("Task run not found")` + `return True` — but no test covering it. If `TaskRunModel.DoesNotExist` is raised during a normal stream closure, the relay currently stops (returns `True`) and marks the stream errored, which may be surprising. A test would pin that behaviour and catch future regressions.
Reviews (1): Last reviewed commit: "fix(cloud-agent): handle stream churn" | Re-trigger Greptile |
joshsny
approved these changes
Apr 30, 2026
sakce
pushed a commit
that referenced
this pull request
Apr 30, 2026
sakce
pushed a commit
that referenced
this pull request
May 7, 2026
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.
Problem
cloud task stream relays could mark the Redis stream complete when the sandbox
/eventsSSE connection closed normally, even if the task run was still non-terminal.ph-code then saw the stream end, fetched an
in_progressrun state, and reconnected, which can produce repeated stream churn.Changes