Initialize agent with custom chat history

Hi All,
hope i can find some pointers here:

I have a conversation from some database and i want to intialize the agents memory (I just read its called storage in agno) / Message history to the one with the external database.
Whats the best way to go about this?
It seems its currently very much geared towards having the agent run from scratch with a blank database.

Some pointers would be great, i have something like this:
Role= ‘assistant’, message=‘some message1’;
Role=‘user’, message=‘some response’;

Thanks!

or is AgentMemory actually the way to go ? I am thoroughly confused.

Hi @nikste
Thanks for reaching out and for using Agno! I’ve looped in the right engineers to help with your question. We usually respond within 24 hours, but if this is urgent, just let us know, and we’ll do our best to prioritize it.
Appreciate your patience—we’ll get back to you soon!

For anyone having a similar issue, I’ve found a workaround using:

agent.run(prompt, messages=previous_messages, stream=True)

Which will take the previous messages into account when generating the answer. I’m not sure yet if it also stores the history in some way when invoking agent.run a second time.

It was rather difficult to find it though and I’m still confused about the difference between storage and memory and would still like to be able to initialize memory(or storage?) from some messages i already have/that are stored in some other format in our production system.

I politely suggest to improve the documentation and examples here: agno/cookbook/agent_concepts/memory at main · agno-agi/agno · GitHub
with the distinction between storage and memory concepts and messages argument in run.
I am wondering:

  • Why are there 3 distinct ways to do this?
  • What are the differences ?
  • When to use what?

Hi @nikste the confusion between storage and memory was valid. In the agno 2.0 versions we have a new interface and have merged everything as Storage you can read more about it here- Storage - Agno and Memory - Agno

That said the way you are passing the messages history is correct, we accept and use it in the context like that. But in 2.0 its changed a bit-
input can receive a list, so the way to pass the full history of messages or any subset of that is passing the list there:

messages = previous_messages + Message(prompt, ...)
agent.run(input=messages)

But probably a valid pointer: we have built-in ways to handle message history. Just add a db to the Agent and adjust num_history_messages and what we are trying to do here will be automatic.
See more in references- Agent - Agno

migration guide- Migrating to Agno v2.0 - Agno