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

Method _handle_request

examples/ahp_agent_monitors_agent.py:183–191  ·  view source on GitHub ↗

请求需要响应

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

Source from the content-addressed store, hash-verified

181 }
182
183 def _handle_request(self, event_type: str, payload: Dict[str, Any], depth: int) -> Dict[str, Any]:
184 """请求需要响应"""
185 if event_type == "pre_action":
186 decision = self._handle_pre_tool_use(payload, depth)
187 if decision.get("action") == "block":
188 return {"decision": "block", "reason": decision.get("reason", "blocked by AHP")}
189 return {"decision": "allow", "metadata": {"reason": decision.get("reason", "")}}
190 # pre_prompt 和其他阻塞事件:默认允许
191 return {"decision": "allow"}
192
193 def dispatch(self, msg: Dict[str, Any]) -> Optional[Dict[str, Any]]:
194 method = msg.get("method")

Callers 1

dispatchMethod · 0.95

Calls 2

_handle_pre_tool_useMethod · 0.95
getMethod · 0.45

Tested by

no test coverage detected