handleAgentEvent method

void handleAgentEvent(
  1. AgentEvent event
)

Forwards one engine event to the attached client as a wire frame. Without a client events are dropped — the session file is the replay surface, not the wire.

Implementation

void handleAgentEvent(AgentEvent event) {
  final client = _client;
  if (client == null) return;
  if (event is ToolCallStuckEvent && redactionPipeline != null) {
    final pipeline = redactionPipeline!;
    event = ToolCallStuckEvent(
      toolCallId: event.toolCallId,
      toolName: event.toolName,
      args: event.args,
      elapsed: event.elapsed,
      action: event.action,
      detail: pipeline.redact(event.detail),
      timestamp: event.timestamp,
    );
  }
  _sendSafely(_protocol.encodeEvent(event), client);
}