Publish an explicit run cancellation lifecycle event.
(
&self,
run_id: &str,
session_id: &str,
reason: Option<&str>,
)
| 541 | |
| 542 | /// Publish an explicit run cancellation lifecycle event. |
| 543 | pub async fn publish_run_cancelled( |
| 544 | &self, |
| 545 | run_id: &str, |
| 546 | session_id: &str, |
| 547 | reason: Option<&str>, |
| 548 | ) { |
| 549 | self.record_event(); |
| 550 | self.runtime_state.clear_runtime_actions(); |
| 551 | let mut event = |
| 552 | crate::ahp::cancelled_run_event(run_id, session_id, &self.agent_id, self.depth, reason); |
| 553 | event.context = self.build_context(); |
| 554 | |
| 555 | if self.batch_enabled { |
| 556 | self.add_to_batch(event).await; |
| 557 | self.flush_batch().await; |
| 558 | return; |
| 559 | } |
| 560 | |
| 561 | if let Err(e) = self.client.send_event_full(&event).await { |
| 562 | warn!("AHP run cancellation event failed: {}", e); |
| 563 | } |
| 564 | } |
| 565 | |
| 566 | /// Start background tasks for heartbeat and idle detection. |
| 567 | /// |