Agent history and chat memory

A record of all the interactions with your agents.

Agent history and memory are two similar but distinct concepts within AI agents. For more details on the exact difference, Langchain4J does a good job explaining the difference simply here: https://docs.langchain4j.dev/tutorials/chat-memory#memory-vs-history

The Talent Agent SDK implements both memory and history for you. The history is managed automatically behind the scenes and is stored forever. It is what powers the built-in search API. ChatMemory is also handled automatically with a built-in Spring component but can be overridden if you want it handled differently.

Viewing the agent history is an important part of improving your agents during initial deploys. You should ensure that any terms of service you have with your users and/or customers gives you access to view the AI responses for the purpose of improving their output.

Agent chat memory

Every agent that you build gets the built-in chat memory auto configured. This memory keeps a rolling 200 messages per conversation and by default the memory ID is managed automatically as you chat back and forth with the agents.

This window can be configured in application.properties through the setting:

peoplelogic.agent.memory.window=50

By default - the chat memory is not persistent through restarts. Future versions of the SDK will include an option to enable a memory stored in the database.

You can choose to create your own replacement of the ChatMemoryProvider interface and add it to your agents. The @PeoplelogicAgent annotation includes a chatMemoryProvider parameter that you can then point to your newly created Spring component.

For more details - check out Langchain4J's great documentation on implementing your own ChatMemory at https://docs.langchain4j.dev/tutorials/chat-memory

Agent chat history

History of the interactions with your agents is handled transparently behind the scenes. You can access this history several ways:

  1. Calling the web API for search (if using the web).

  2. Using the CLI to search (if using the CLI).

  3. Autowiring PeoplelogicAgentUtils and calling its search method.

  4. Autowiring AgentHistoryRepository and accessing the history directly.

All of these will yield the same results. Each message in the history is attached to a conversation and knows whether it was a user message or an agent response. If it was an agent response it also includes the token usage.

In addition to searching the agent history, one potential usage of the direct history might be to use it to break out the themes of queries that users are asking your agent to answer. You can send the anonymized user messages back to an agent within a tool to get the themes and then output those as the result of the tool. Or you could use the history to automatically improve the way that an agent responds to inputs. Feel free to get in touch if you'd like help implementing these ideas!

Last updated

Was this helpful?