Skip to content

feat: unified management stop event - #28

Open
tomerqodo wants to merge 3 commits into
augment_only-issues-20260113-augment-codex-sentry_base_feat_unified_management_stop_event_pr171from
augment_only-issues-20260113-augment-codex-sentry_head_feat_unified_management_stop_event_pr171
Open

feat: unified management stop event#28
tomerqodo wants to merge 3 commits into
augment_only-issues-20260113-augment-codex-sentry_base_feat_unified_management_stop_event_pr171from
augment_only-issues-20260113-augment-codex-sentry_head_feat_unified_management_stop_event_pr171

Conversation

@tomerqodo

Copy link
Copy Markdown

Benchmark PR from qodo-benchmark#171

@tomerqodo

Copy link
Copy Markdown
Author

augment review

@augmentcode

augmentcode Bot commented Jan 15, 2026

Copy link
Copy Markdown
🤖 Augment PR Summary

Summary: This PR unifies workflow cancellation by introducing a shared threading.Event managed by GraphEngine.

Changes:

  • Create and store a single stop_event in GraphEngine and propagate it via GraphRuntimeState.
  • Pass the shared stop signal into Dispatcher, WorkerPool, and Worker instead of each creating their own.
  • Clear the stop signal on execution start and set it on execution stop.
  • Add node-level cancellation checks during event streaming to emit a cancellation failure event.
  • Reduce join timeouts for dispatcher and workers from 10s to 2s.
  • Add unit tests intended to verify stop propagation and timeout behavior.

Technical Notes: Cancellation is now coordinated by a single event shared across orchestration and execution components, aiming for consistent shutdown behavior and faster teardown.

🤖 Was this summary useful? React with 👍 or 👎

@augmentcode augmentcode Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review completed. 5 suggestions posted.

Fix All in Augment

Comment augment review to trigger a new review at any time.

self._stop_event = stop_event
self._layers = layers if layers is not None else []

def stop(self) -> None:

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With Worker.stop() now a no-op, WorkerPool._remove_worker() (used for scale-down) can no longer actually terminate an individual worker, so “removed” workers may keep running and processing tasks outside the pool’s accounting.

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎

self._thread = threading.Thread(target=self._dispatcher_loop, name="GraphDispatcher", daemon=True)
self._thread.start()

def stop(self) -> None:

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since Dispatcher.stop() no longer sets _stop_event, callers that invoke stop() without first setting the shared event may leave the dispatcher thread running (the join() just times out).

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎


def _should_stop(self) -> bool:
"""Check if execution should be stopped."""
return self.graph_runtime_state.stop_event and self.graph_runtime_state.stop_event.is_set()

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_should_stop() can return None when graph_runtime_state.stop_event is unset, despite being annotated -> bool; that can leak non-bool values into callers/tests.

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎

node_type=self.node_type,
start_at=self._start_at,
node_run_result=NodeRunResult(
status=WorkflowNodeExecutionStatus.FAILED,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cancellation emits a NodeRunFailedEvent with WorkflowNodeExecutionStatus.FAILED; since there is also a STOPPED status, marking cancelled nodes as failed may misclassify user stops in UI/metrics.

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎

assert not answer_node._should_stop()

# Set the stop_event
runtime_state.stop_event.set()

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this test, GraphRuntimeState.stop_event defaults to None, so runtime_state.stop_event.set() will raise; this also applies to the other runtime_state.stop_event.set() usages in this file.

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants