()
| 475 | return False # continue |
| 476 | |
| 477 | def run(): |
| 478 | messages = [{"role": "user", "content": prompt}] |
| 479 | sub_tools = [ |
| 480 | {"name": "bash", "description": "Run a shell command.", |
| 481 | "input_schema": {"type": "object", |
| 482 | "properties": {"command": {"type": "string"}}, |
| 483 | "required": ["command"]}}, |
| 484 | {"name": "read_file", "description": "Read file.", |
| 485 | "input_schema": {"type": "object", |
| 486 | "properties": {"path": {"type": "string"}}, |
| 487 | "required": ["path"]}}, |
| 488 | {"name": "write_file", "description": "Write file.", |
| 489 | "input_schema": {"type": "object", |
| 490 | "properties": {"path": {"type": "string"}, |
| 491 | "content": {"type": "string"}}, |
| 492 | "required": ["path", "content"]}}, |
| 493 | {"name": "send_message", |
| 494 | "description": "Send message to another agent.", |
| 495 | "input_schema": {"type": "object", |
| 496 | "properties": {"to": {"type": "string"}, |
| 497 | "content": {"type": "string"}}, |
| 498 | "required": ["to", "content"]}}, |
| 499 | {"name": "submit_plan", |
| 500 | "description": "Submit a plan for Lead approval.", |
| 501 | "input_schema": {"type": "object", |
| 502 | "properties": {"plan": {"type": "string"}}, |
| 503 | "required": ["plan"]}}, |
| 504 | ] |
| 505 | sub_handlers = { |
| 506 | "bash": run_bash, "read_file": run_read, "write_file": run_write, |
| 507 | "send_message": lambda to, content: (BUS.send(name, to, content), |
| 508 | "Sent")[1], |
| 509 | "submit_plan": lambda plan: _teammate_submit_plan(name, plan), |
| 510 | } |
| 511 | |
| 512 | shutdown_requested = False |
| 513 | while not shutdown_requested: |
| 514 | # Check inbox for protocol messages |
| 515 | inbox = BUS.read_inbox(name) |
| 516 | should_stop = False |
| 517 | non_protocol = [] |
| 518 | for msg in inbox: |
| 519 | if msg.get("type") in ("shutdown_request", "plan_approval_response"): |
| 520 | should_stop = handle_inbox_message(name, msg, messages) |
| 521 | if should_stop: |
| 522 | break |
| 523 | else: |
| 524 | non_protocol.append(msg) |
| 525 | if should_stop: |
| 526 | shutdown_requested = True |
| 527 | break |
| 528 | if non_protocol: |
| 529 | inbox_json = json.dumps(non_protocol) |
| 530 | messages.append({"role": "user", |
| 531 | "content": "<inbox>" + inbox_json + "</inbox>"}) |
| 532 | |
| 533 | # LLM turn |
| 534 | try: |
nothing calls this directly
no test coverage detected