MCPcopy Create free account
hub / github.com/agentforce314/clawcodex / _handle_control_request

Method _handle_control_request

src/server/agent_server.py:193–470  ·  view source on GitHub ↗
(self, msg: dict)

Source from the content-addressed store, hash-verified

191 logger.debug("[agent-server] ignoring unknown inbound type: %s", msg_type)
192
193 async def _handle_control_request(self, msg: dict) -> None:
194 inner = msg.get("request")
195 if not isinstance(inner, dict):
196 return
197 subtype = inner.get("subtype")
198 request_id = msg.get("request_id")
199 if subtype == "interrupt":
200 with self._lock:
201 abort = self._current_abort
202 pendings = list(self._pending.values())
203 # Release any in-flight permission ask NOW so the worker unblocks
204 # immediately rather than at permission_timeout_s (proposal §7: ESC
205 # during a permission prompt must both deny the pending ask AND
206 # abort the turn). Mirrors shutdown()'s deny-release.
207 for pending in pendings:
208 pending.reply = {"behavior": "deny", "message": "interrupted"}
209 pending.event.set()
210 if abort is not None:
211 abort.abort("user_interrupt")
212 return
213 if subtype == "set_permission_mode":
214 mode = inner.get("mode")
215 if isinstance(mode, str) and self.tool_context is not None:
216 _set_mode(self.tool_context, mode)
217 self._ack(request_id)
218 return
219 if subtype == "set_model":
220 model = inner.get("model")
221 if isinstance(model, str) and self.provider is not None:
222 try:
223 self.provider.model = model
224 except Exception: # noqa: BLE001
225 pass
226 self._ack(request_id)
227 return
228 if subtype == "set_provider":
229 self._do_set_provider(request_id, inner.get("provider"))
230 return
231 if subtype == "set_output_style":
232 self._do_set_output_style(request_id, inner.get("style"))
233 return
234 if subtype == "knowledge":
235 self._do_knowledge(request_id, inner.get("action"))
236 return
237 if subtype == "wiki":
238 self._do_wiki(request_id, inner.get("action"), inner.get("path"))
239 return
240 if subtype in ("bg_run", "bg_list", "bg_kill", "bg_agent"):
241 self._do_bgtask(request_id, subtype, inner.get("command"), inner.get("id"))
242 return
243 if subtype == "insights":
244 self._do_insights(request_id)
245 return
246 if subtype == "plan":
247 self._do_plan(request_id, inner.get("action"), inner.get("text"))
248 return
249 if subtype == "set_language":
250 self._do_set_language(request_id, inner.get("language"))

Callers 1

send_to_agentMethod · 0.95

Calls 15

_ackMethod · 0.95
_do_set_providerMethod · 0.95
_do_set_output_styleMethod · 0.95
_do_knowledgeMethod · 0.95
_do_wikiMethod · 0.95
_do_bgtaskMethod · 0.95
_do_insightsMethod · 0.95
_do_planMethod · 0.95
_do_set_languageMethod · 0.95
_do_set_thinkingMethod · 0.95
_do_set_mcp_enabledMethod · 0.95
_replyMethod · 0.95

Tested by

no test coverage detected