# Agno

> Give an Agno agent a memory of each of your users, through dynamic instructions or a recall tool, with the user from the run.

Give an Agno agent a memory of each of your users. What is known goes into the agent's instructions as a
run dependency, or the agent looks it up with a tool that reads the user from the run; either way, each
exchange is saved after the run.

## Install

```bash
pip install agno anthropic geniffy
```

```bash
uv add agno anthropic geniffy
```

Set `ANTHROPIC_API_KEY`, and `GENIFFY_API_KEY` from **API keys** in the Geniffy app. Any model Agno supports
works the same way.

## Remember each user

```python
from agno.agent import Agent
from agno.models.anthropic import Claude
from agno.run import RunContext
from geniffy import Geniffy

geniffy = Geniffy()                      # reads GENIFFY_API_KEY


def instructions(run_context: RunContext) -> str:
    memory = run_context.dependencies["memory"]
    return f"You are a helpful assistant.\n\n<memory>\n{memory}\n</memory>"


agent = Agent(model=Claude(id="claude-opus-5-5"), instructions=instructions)


def chat(user_id: str, message: str) -> str:
    mem = geniffy.space(f"user_{user_id}")
    memory = mem.context(message)        # what is known that bears on the message
    response = agent.run(message, user_id=user_id, dependencies={"memory": memory})
    reply = response.content
    mem.memories.add(messages=[{"role": "user", "content": message},
                               {"role": "assistant", "content": reply}])
    return reply
```

The agent sees what is known about this user, each line with where it came from. When nothing is known, the
block says so in one sentence, so the agent says it doesn't know instead of guessing.

## Let the agent look things up

To let the agent decide when to look something up, give it a `recall` tool. Agno passes the run to the
tool, so it reads the user from `user_id` and the model never sees or chooses whose memory it reads.

```python
from agno.agent import Agent
from agno.models.anthropic import Claude
from agno.run import RunContext
from geniffy import Geniffy

geniffy = Geniffy()
INSTRUCTIONS = ("You are a helpful assistant. Use recall before answering anything "
                "that depends on what the user said before.")


def recall(run_context: RunContext, query: str) -> str:
    """Look up what is known about the user, with where it came from.

    Args:
        query: What to look up
    """
    return geniffy.space(f"user_{run_context.user_id}").context(query)


agent = Agent(
    model=Claude(id="claude-opus-5-5"), tools=[recall], instructions=INSTRUCTIONS,
)


def chat(user_id: str, message: str) -> str:
    reply = agent.run(message, user_id=user_id).content
    geniffy.space(f"user_{user_id}").memories.add(messages=[
        {"role": "user", "content": message},
        {"role": "assistant", "content": reply},
    ])
    return reply
```

Agno's own memory can stay off: Geniffy keeps what each user said, with where it came from, across every
agent and app you connect.

Source: https://docs.geniffy.com/integrations/agno
