-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbasic_agent.py
More file actions
61 lines (47 loc) · 2.35 KB
/
Copy pathbasic_agent.py
File metadata and controls
61 lines (47 loc) · 2.35 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
49
50
51
52
53
54
55
56
57
58
59
60
61
"""Example: Deep Agent with Sulcus thermodynamic memory.
The agent has persistent memory across sessions. It can store, search,
recall, pin, and forget memories using the Sulcus tools. The middleware
automatically injects relevant context on every turn.
Usage:
pip install sulcus deepagents sulcus-deepagents
export SULCUS_API_KEY="sk-..."
export ANTHROPIC_API_KEY="sk-ant-..."
python basic_agent.py
"""
import os
from deepagents import create_deep_agent
from sulcus import Sulcus
from sulcus_deepagents import SulcusMemoryMiddleware, SulcusMemoryTools
# ── Sulcus client ────────────────────────────────────────────────
client = Sulcus(
api_key=os.environ.get("SULCUS_API_KEY", "sk-..."),
server_url=os.environ.get("SULCUS_SERVER_URL", "https://api.sulcus.ca"),
)
# ── Memory tools ─────────────────────────────────────────────────
memory_tools = SulcusMemoryTools(client=client)
# ── Create Deep Agent with Sulcus memory ─────────────────────────
agent = create_deep_agent(
# Middleware: injects relevant memories into every system prompt
middleware=[
SulcusMemoryMiddleware(client=client, search_limit=15, token_budget=2000),
],
# Tools: gives the agent explicit memory operations
tools=memory_tools.tools(),
system_prompt=(
"You are a helpful assistant with persistent memory. "
"You remember everything important across sessions. "
"Store preferences, facts, and procedures as you learn them."
),
)
# ── Run ──────────────────────────────────────────────────────────
if __name__ == "__main__":
# First run: the agent starts fresh
result = agent.invoke({
"messages": [{"role": "user", "content": "I prefer dark mode and use TypeScript."}]
})
print("Agent:", result["messages"][-1].content)
# Second run: the agent remembers
result = agent.invoke({
"messages": [{"role": "user", "content": "What do you know about my preferences?"}]
})
print("Agent:", result["messages"][-1].content)