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

Method _emit

src/server/agent_server.py:135–146  ·  view source on GitHub ↗

Thread-safe enqueue of one outbound SDK message. Every message is passed through ``_json_safe`` so a stray non-serializable value can never make the server's ``json.dumps`` in the WS pump raise and silently kill the outbound stream.

(self, msg: dict)

Source from the content-addressed store, hash-verified

133 # ─── outbound helpers (worker thread → main loop) ──────────────────────
134
135 def _emit(self, msg: dict) -> None:
136 """Thread-safe enqueue of one outbound SDK message.
137
138 Every message is passed through ``_json_safe`` so a stray
139 non-serializable value can never make the server's ``json.dumps`` in
140 the WS pump raise and silently kill the outbound stream.
141 """
142 try:
143 self.loop.call_soon_threadsafe(self.out_queue.put_nowait, _json_safe(msg))
144 except RuntimeError:
145 # Loop closed (server shutting down) — drop.
146 pass
147
148 def _close_stream(self) -> None:
149 try:

Callers 10

emit_initMethod · 0.95
_replyMethod · 0.95
_emit_agent_progressMethod · 0.95
permission_handlerMethod · 0.95
_run_turnMethod · 0.95
on_text_chunkMethod · 0.95
on_thinking_chunkMethod · 0.95
on_messageMethod · 0.95
_elicitFunction · 0.80

Calls 1

_json_safeFunction · 0.85

Tested by

no test coverage detected