-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
48 lines (36 loc) · 1.36 KB
/
main.py
File metadata and controls
48 lines (36 loc) · 1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
"""07_delegate — Multi-Agent Delegation.
A coordinator agent calls researcher and writer as tools.
strands-compose wires the connections from config.yaml automatically.
Usage:
uv run python examples/07_delegate/main.py
"""
from __future__ import annotations
from pathlib import Path
CONFIG = Path(__file__).parent / "config.yaml"
STARTER = "Write a short guide on how Python manages memory."
def main() -> None:
from strands_compose import load
resolved = load(CONFIG)
agent = resolved.entry
print(f"\n{52 * '-'}")
print(f"Try: {STARTER}\n")
print("coordinator -> researcher + writer")
print("Type a message and press Enter. Empty line to exit.\n")
try:
while True:
msg = input("You: ").strip()
if not msg:
break
print("\nAgent is thinking...")
result = agent(msg)
print(f"\n\n{52 * '-'}")
print(f"Agent: {result}\n")
except KeyboardInterrupt:
print("\nGoodbye!")
finally:
resolved.mcp_lifecycle.stop()
# ── entry point ───────────────────────────────────────────────────────────────
if __name__ == "__main__":
from strands_compose import cli_errors
with cli_errors():
main()