atomic-agents icon indicating copy to clipboard operation
atomic-agents copied to clipboard

more precise docs on memory

Open xpluscal opened this issue 11 months ago • 4 comments

Memory is great, its unclear however how messages get added.

in most of the examples only the initial message is added, not any subsequent runs - is this automatic? how would you handle lets say a loop where one agent does a thing, the second evaluates and then passes the result to memory for the first agent to do again.

xpluscal avatar Jan 10 '25 03:01 xpluscal

Yes new messages are automatically added to the memory.

I agree we could use some better docs on that, for now I'd advise to have a look in the source file of the memory, there is an elaborate mainguard that, if you run it, demos everything memory can do...

how would you handle lets say a loop where one agent does a thing, the second evaluates and then passes the result to memory for the first agent to do again.

I would just do something like:

agent_one.memory.add_message("system", OUTPUT OF AGENT TWO)
OR
agent_one.memory.add_message("user", OUTPUT OF AGENT TWO)

depending on what is allowed by your LLM provider/client (some don't allow system messages past the first message, for example)

I will leave this issue open for now as it pertains to improving the docs

KennyVaneetvelde avatar Jan 12 '25 19:01 KennyVaneetvelde

@KennyVaneetvelde - I was going to open a new issue but this one is related enough that we may be able to address it here. When I was poking through AgentMemory I didn't see any place where the turn gets reset. I didn't see it in the BaseAgent either. My understanding is that a "turn" is generally a single exchange User -> Assistant. Is that the same definition atomic-agents wants to go with or is a "turn" equivalent to something closer to a "session"?

jonchun avatar Jan 28 '25 04:01 jonchun

I'd be interested in knowing this too. My understanding of turn is same as @jonchun

cmardiros avatar Feb 15 '25 16:02 cmardiros

Wow I am so so sorry for missing this question

So, the .run() method in an agent can be used in two ways. Either you have an input parameter, or you don't. If you have an input parameter, this is a new user message, and a new user message is a new interaction, so a new turn.

If for some reason you do something more (semi or fully) autonomous, like (pseudocode)

output = agent.run(input)
while (output.some_condition):
   output = agent.run()
   if not (output.some_condition):
      break

Then that means that as long as you don't exit that while loop and do another .run() with some input, that is still one turn, but now that one turn has a user message followed by maybe the agent executing a tool, contemplating, executing another tool, ...

Just visualize it as if it is a chat window, really, and every time you type its a turn

Anyways, came here to say this issue and #115 should be picked up together

KennyVaneetvelde avatar Apr 24 '25 12:04 KennyVaneetvelde