MCPcopy Create free account
hub / github.com/AI45Lab/Code / _handle_notification

Method _handle_notification

examples/ahp_agent_monitors_agent.py:160–169  ·  view source on GitHub ↗

通知是即发即弃的 — 不发送响应

(self, event_type: str, payload: Dict[str, Any], depth: int)

Source from the content-addressed store, hash-verified

158 return {"action": action, "reason": reason}
159
160 def _handle_notification(self, event_type: str, payload: Dict[str, Any], depth: int):
161 """通知是即发即弃的 — 不发送响应"""
162 if event_type == "post_action":
163 tool = payload.get("tool", "?")
164 output_len = len(str((payload.get("result") or {}).get("output", "")))
165 log(f"post_action (通知): tool={tool} output={output_len}B depth={depth}")
166 elif event_type == "session_start":
167 log(f"会话开始: {payload.get('session_id', '?')} depth={depth}")
168 elif event_type == "session_end":
169 log(f"会话结束。最终统计: {self.stats}")
170
171 def _handle_handshake(self, params: Dict[str, Any]) -> Dict[str, Any]:
172 """处理 AHP 握手请求"""

Callers 1

dispatchMethod · 0.95

Calls 2

logFunction · 0.70
getMethod · 0.45

Tested by

no test coverage detected