Skip to main content

trigger_agent_stop

Function trigger_agent_stop 

Source
pub async fn trigger_agent_stop(
    agent_id: &str,
    agent_type: &str,
    session_key: Option<String>,
) -> Result<InternalHookEvent>
Expand description

触发 agent:stop 事件

当 Agent 停止时调用此函数触发 agent:stop 事件。 事件的 context 包含 agent_idagent_type 字段。

§参数

  • agent_id: Agent 的唯一标识符
  • agent_type: Agent 的类型(如 “coding”、“chat” 等)
  • session_key: 可选的会话键

§返回值

返回触发后的 InternalHookEvent,调用者可以访问处理器添加的消息。

§示例

use aster::hooks::internal::trigger_agent_stop;

async fn stop_agent() {
    let event = trigger_agent_stop(
        "agent-001",
        "coding",
        Some("session-123".to_string()),
    ).await.unwrap();

    println!("Agent stopped, messages: {:?}", event.messages);
}

Validates: Requirements 7.2, 7.5