MCPcopy Create free account
hub / github.com/Louisym/MiniCC / send

Method send

tutorials/13_multi_agent_coordination.py:197–224  ·  view source on GitHub ↗

发送消息到目标 Agent 的收件箱。 真实实现中有锁文件保护(防止并发写入冲突)。 简化版直接写文件。 对应 Reference: EP08 §2 多个 Claude 实例可以并发写入 —— 锁文件通过指数退避重试序列化访问

(self, message: AgentMessage)

Source from the content-addressed store, hash-verified

195 return os.path.join(self.inbox_dir, f"{agent_name}.json")
196
197 def send(self, message: AgentMessage):
198 """
199 发送消息到目标 Agent 的收件箱。
200
201 真实实现中有锁文件保护(防止并发写入冲突)。
202 简化版直接写文件。
203
204 对应 Reference: EP08 §2
205 多个 Claude 实例可以并发写入 ——
206 锁文件通过指数退避重试序列化访问
207 """
208 inbox_path = self._inbox_path(message.to_agent)
209
210 # 读取现有消息
211 messages = []
212 if os.path.exists(inbox_path):
213 with open(inbox_path, "r") as f:
214 try:
215 messages = json.load(f)
216 except json.JSONDecodeError:
217 messages = []
218
219 # 追加新消息
220 messages.append(message.to_dict())
221
222 # 写回文件
223 with open(inbox_path, "w") as f:
224 json.dump(messages, f, ensure_ascii=False, indent=2)
225
226 def receive(self, agent_name: str) -> list[AgentMessage]:
227 """

Callers 9

execute_web_fetchFunction · 0.80
execute_web_searchFunction · 0.80
dropMethod · 0.80
exchange_oauth_codeMethod · 0.80
refresh_oauth_tokenMethod · 0.80
send_raw_requestMethod · 0.80
process_messagesMethod · 0.80
assign_taskMethod · 0.80
shutdown_allMethod · 0.80

Calls 4

_inbox_pathMethod · 0.95
appendMethod · 0.80
loadMethod · 0.45
to_dictMethod · 0.45

Tested by

no test coverage detected