Loading
Loading
Three function tools the agent can call. The recall tool surfaces ⚠/✓/· markers inline so the LLM can branch in-prompt.
from agents import Agent, function_tool
from atlaso import Memory
m = Memory()
@function_tool
def remember(content: str, user_id: str) -> dict:
"""Save a memory deposit for the given user."""
user = m.for_user(user_id)
r = user.add(content)
return {"id": r.id, "saved": True}
@function_tool
def recall(query: str, user_id: str, limit: int = 8) -> str:
"""Search memory. Each line is prefixed with a verdict marker:
✓ confident, ⚠ has disagreement, · unverified."""
user = m.for_user(user_id)
hits = user.recall(query, limit=limit)
if not hits:
return "(no memory)"
lines = [f"VERDICT: {hits.explain()}"]
for h in hits:
marker = "⚠" if h.has_disagreement else ("✓" if h.is_confident else "·")
lines.append(f"{marker} {h.content}")
return "\n".join(lines)
@function_tool
def contradict(new_text: str, old_id: str, user_id: str, reason: str) -> dict:
"""Supersede a previous deposit with a new fact."""
user = m.for_user(user_id)
r = user.contradict(new_text, contradicts=[old_id], reason=reason)
return {"new_id": r.id, "supersedes": old_id}
agent = Agent(
name="memory-agent",
instructions="Use 'recall' before answering. Use 'remember' to save facts.",
tools=[remember, recall, contradict],
)Was this page helpful?