Dynamic graph memory for agents
A large language model (LLM) can receive input data and process the input data. The processing can include generating a response to the input data, generating a first memory entry corresponding to the input data, generating a second memory entry corresponding to the response, and generating a relationship between the first memory entry and the second memory entry. Memory entries and relationships can be stored in a graph memory structure. Processing can include accessing the graph memory structure, searching the graph memory structure for information associated with at least a portion of the input data and obtaining a search result comprising at least one of the at least two nodes and the at least one edge, and generating a response to the input data.
1 . A method comprising:
receiving, with a large language model (LLM) provided by at least one processor, input data;
processing, by the LLM, the input data, the processing comprising:
generating a response to the input data,
generating a first memory entry corresponding to the input data,
generating a second memory entry corresponding to the response, and
generating a relationship between the first memory entry and the second memory entry, the relationship defining:
a dependency between the first memory entry and the second memory entry defining at least one effect by data within one of the first memory entry or the second memory entry on data within the other of the first memory entry or the second memory entry, and
a direction of the dependency between the first memory entry and the second memory entry; and
storing, by the at least one processor, the first memory entry as a first node in a graph memory structure, the second memory entry as a second node in the graph memory structure, and the relationship as an edge connecting the first node and the second node in the graph memory structure, wherein the at least one processor is configured to cause the LLM to generate at least one additional response incorporating data stored in the graph memory structure including at least one node and at least one edge.
2 . The method of claim 1 , wherein the processing comprises generating the first memory entry, the second memory entry, and the relationship in response to at least one system prompt instruction.
3 . The method of claim 1 , wherein the storing comprises:
sending at least one structured call to the at least one database; and
wherein the at least one database is configured to store at least a portion of data included in the at least one structured call according to at least one instruction in the at least one structured call.
4 . The method of claim 3 , wherein the at least one structured call comprises at least one of an application programming interface (API) call and a model context protocol (MCP) call.
5 . The method of claim 3 , further comprising generating the at least one structured call by the LLM in response to at least one system prompt instruction.
6 . The method of claim 3 , further comprising invoking at least one tool by the LLM, the at least one tool performing processing comprising:
generating the at least one structured call to at least one database; and
performing the sending of the at least one structured call to the at least one database.
7 . A method comprising:
receiving, with a large language model (LLM) provided by at least one processor, input data;
processing, by the LLM, the input data, the processing comprising:
accessing a graph memory structure comprising at least two nodes and at least one edge linking the at least two nodes, wherein each node of the at least two nodes represents a respective interaction between the LLM and a user, and each edge of the at least one edge represents a respective relationship between the interactions,
searching the graph memory structure for information associated with at least a portion of the input data and obtaining a search result comprising extracted data from at least one of a first memory entry in the graph memory structure corresponding to a first one of the at least two nodes and a second memory entry in the graph memory structure corresponding to a second one of the at least two nodes and an extracted relationship stored in the graph memory structure and associated with the at least one edge, the relationship defining:
a dependency between the first memory entry and the second memory entry defining at least one effect by data within one of the first memory entry or the second memory entry on data within the other of the first memory entry or the second memory entry, and
a direction of the dependency between the first memory entry and the second memory entry, and
generating a response to the input data, the generating comprising incorporating data from the search result into the response; and
providing, by the at least one processor, the response to the user.
8 . The method of claim 7 , wherein the accessing and the searching are performed in response to at least one system prompt instruction.
9 . The method of claim 7 , further comprising:
generating, by the LLM a first memory entry corresponding to the input data;
generating, by the LLM, a second memory entry corresponding to the response;
generating, by the LLM, a relationship between the first memory entry and the second memory entry; and
storing, by the at least one processor, the first memory entry as a first node in the graph memory structure, the second memory entry as a second node in the graph memory structure, and the relationship as an edge connecting the first node and the second node in the graph memory structure.
10 . The method of claim 9 , wherein the first memory entry, the second memory entry, and the relationship are generated in response to at least one system prompt instruction.
11 . The method of claim 9 , wherein the storing comprises:
sending at least one structured call to the at least one database; and
wherein the at least one database is configured to store at least a portion of data included in the at least one structured call according to at least one instruction in the at least one structured call.
12 . The method of claim 11 , wherein the at least one structured call comprises at least one of an application programming interface (API) call and a model context protocol (MCP) call.
13 . The method of claim 11 , further comprising generating the at least one structured call by the LLM in response to at least one system prompt instruction.
14 . The method of claim 11 , further comprising invoking at least one tool by the LLM, the at least one tool performing processing comprising:
generating the at least one structured call to at least one database; and
performing the sending of the at least one structured call to the at least one database.
15 . The method of claim 7 , wherein at least one of the accessing and the searching comprises:
sending at least one structured call to the at least one database; and
wherein the at least one database is configured to return data according to at least one instruction in the at least one structured call.
16 . The method of claim 15 , wherein the at least one structured call comprises at least one of an application programming interface (API) call and a model context protocol (MCP) call.