-
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.4 KB
/
main.py
File metadata and controls
48 lines (36 loc) · 1.4 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
"""04_session — Persistent Memory.
Declare a session_manager in config.yaml — strands-compose wires persistent
conversation history automatically. State is saved to .sessions/ on disk.
Usage:
uv run python examples/04_session/main.py
"""
from __future__ import annotations
from pathlib import Path
CONFIG = Path(__file__).parent / "config.yaml"
STARTER = "My name is Alice and I work as a data engineer."
def main() -> None:
from strands_compose import load
resolved = load(CONFIG)
agent = resolved.entry
print(f"\n{52 * '-'}")
print(f"Try: {STARTER}\n")
print("The agent remembers everything you say — even across restarts.")
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()