MCPcopy
hub / github.com/shareAI-lab/learn-claude-code / handle_inbox_message

Function handle_inbox_message

s16_team_protocols/code.py:451–475  ·  view source on GitHub ↗

Dispatch incoming protocol messages by type. Returns True if teammate should stop.

(name: str, msg: dict, messages: list)

Source from the content-addressed store, hash-verified

449 f"Check inbox for protocol messages (shutdown_request, etc).")
450
451 def handle_inbox_message(name: str, msg: dict, messages: list) -> bool:
452 """Dispatch incoming protocol messages by type.
453 Returns True if teammate should stop."""
454 msg_type = msg.get("type", "message")
455 meta = msg.get("metadata", {})
456 req_id = meta.get("request_id", "")
457
458 if msg_type == "shutdown_request":
459 BUS.send(name, "lead", "Shutting down gracefully.",
460 "shutdown_response",
461 {"request_id": req_id, "approve": True})
462 print(f" \033[35m[protocol] {name} approved shutdown "
463 f"({req_id})\033[0m")
464 return True # stop the loop
465
466 if msg_type == "plan_approval_response":
467 approve = meta.get("approve", False)
468 if approve:
469 messages.append({"role": "user",
470 "content": f"[Plan approved] Proceed with the task."})
471 else:
472 messages.append({"role": "user",
473 "content": f"[Plan rejected] Feedback: {msg['content']}"})
474
475 return False # continue
476
477 def run():
478 messages = [{"role": "user", "content": prompt}]

Callers 1

runFunction · 0.70

Calls 2

getMethod · 0.45
sendMethod · 0.45

Tested by

no test coverage detected