Method for providing services using multi-turn AI agent and AI agent using the same

By maintaining recent original messages and using summary messages for previous turns, the AI agent reduces costs and enhances efficiency in multi-turn interactions while minimizing data search and information loss.

JP7808905B1Active Publication Date: 2026-01-30SUPERB AI CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
JP2025146385
Authority / Receiving Office
JP · JP
Patent Type
Patents
Current Assignee / Owner
Priority Date
2025-08-11
Filing Date
2025-09-03
Publication Date
2026-01-30
Estimated Expiration
2045-09-03

AI Technical Summary

Technical Problem

AI agents using multi-turn methods face challenges such as increased cost and latency due to exceeding context length and data search inefficiencies, with risks of information loss during summarization and repeated database queries.

Method used

The AI agent maintains only the most recent j turns as original messages and uses summary messages for previous turns, storing original messages externally to minimize data search and reduce information loss.

Benefits of technology

This approach reduces execution costs and improves speed by minimizing data searches and eliminating information loss in multi-turn interactions.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure 0007808905000001_ABST
    Figure 0007808905000001_ABST
Patent Text Reader

Abstract

We provide a method for AI agents to provide services using multi-turn. [Solution] This method reduces task execution costs by maintaining only the messages for the most recent j turns as originals and using their respective summary messages for messages for previous turns. Also, the risk of information loss is eliminated by storing the original messages corresponding to the summary messages in external storage so that the original messages can be accessed when needed. Furthermore, when data used in previous turns is needed, it is obtained from the original messages stored corresponding to the summary messages instead of from a database through a data search operation, thereby minimizing data search operations.
Need to check novelty before this filing date? Find Prior Art

Description

[Technical Field]

[0001] The present invention relates to an AI (Artificial Intelligence) agent, and more particularly to a method for an AI agent to provide a service using multi-turns, and an AI agent using the same. [Background technology]

[0002] An AI agent is an intelligent software system that can solve complex problems and make decisions on its own without user intervention, and also uses various tools such as databases, web searches, and coding to accomplish its goals.

[0003] AI agents are being used in a variety of fields, including customer service (chatbots or virtual secretaries), business automation (automating repetitive tasks or data analysis), industrial automation (robot control or process optimization), personal assistants (scheduling or email organization), healthcare (diagnosing diseases or establishing treatment plans), and research and development (experimental design or data analysis).

[0004] Such AI agents often use a multi-turn method, which allows for repeated questions and answers to be given, rather than a single-turn method, which ends with one question and one answer. In the multi-turn method, messages corresponding to questions and answers from the previous turn are stored in the chat history, and the stored messages from the previous turn and the question of the current turn are used to carry out the task of the current turn.

[0005] When using such multi-turns, various constraints arise as the number of turns increases, for example, the length of the message input to the LLM (Large Language Model) to perform the current turn may exceed the set context length, or the cost of calling the LLM may increase as the number of input tokens increases. In particular, when an AI agent tries to obtain an answer to a question desired by a user from a database, the length of the messages exchanged between the user and the AI ​​agent increases rapidly as the data search operation progresses, which increases the cost and latency required for the AI ​​agent to perform the task.

[0006] To solve this problem, messages from previous turns are summarized and the current turn is carried out using the summary, which allows the AI ​​agent to carry out multiple turns by maintaining the overall message context even when the number of turns increases.

[0007] However, when using a summary book that summarizes previous messages, there is a risk that important detailed information may be lost during the summarization process, which may prevent the user from generating the accurate response they desire.

[0008] In addition, when an AI agent tries to obtain an answer to a question from a database, the data obtained through data search in the previous turn is not included in the summary, so there is a problem that the agent must repeatedly perform data search to obtain the relevant data from the database. Summary of the Invention [Problem to be solved by the invention]

[0009] An object of the present invention is to solve all of the problems of the prior art mentioned above.

[0010] Another object of the present invention is to reduce the cost and speed of an AI agent's task execution by maintaining only the messages for the most recent j turns as the originals and using summary messages for messages for previous turns.

[0011] Another object of the present invention is to eliminate the risk of information loss in multiple turns of an AI agent by storing original messages corresponding to summary messages in external storage and making the original messages accessible when necessary.

[0012] Another object of the present invention is to minimize the data search work of an AI agent by obtaining data used in a previous turn from the original message stored in correspondence with the summary message instead of obtaining it from a database through a data search work, even when the data is needed. [Means for solving the problem]

[0013] According to one embodiment of the present invention, in a method for an AI agent to provide a service using multi-turns, (a) when a p-th query for requesting a p-th service is acquired from a user for p, which is an integer that sequentially increases from 1 to j (j is a preset integer greater than or equal to 1), the AI ​​agent analyzes a first original message through a (p-1)-th original message stored in a chat history and the p-th query (when p is 1, only the p-th query is analyzed), and determines a p-th task for providing the p-th service, and retrieves the p-th service from at least one database according to the p-th task. a step of repeatedly performing a p-th turn of acquiring p-th data required to provide the p-th service, generating a p-th response corresponding to the p-th query using the p-th data, providing the p-th response to the user, and storing a p-th original message (the p-th original message includes (i) p-th query information related to the p-th query, (ii) p-th agent operation information related to a process of analyzing the first original message through the (p-1)th original message and the p-th query to determine the p-th task and a process of generating the p-th response using the p-th data, and (iii) p-th response information related to the p-th response) in the chat history;(b) When a (j+1)th query for requesting the (j+1)th service is acquired from the user, the AI ​​agent analyzes the first original message through the jth original message and the (j+1)th query stored in the chat history to determine a (j+1)th task for providing the (j+1)th service, acquires the (j+1)th data necessary to provide the (j+1)th service from the at least one database through the (j+1)th task, generates a (j+1)th response corresponding to the (j+1) query using the (j+1)th data, and provides the (j+1) response to the user, and generates a (j+1)th original message (the (j+1)th original message includes (i) the (j+1)th query information regarding the (j+1) query, (ii) the (iii) (j+1)th response information regarding the (j+1)th response; and (iii) (j+1)th agent operation information regarding the process of analyzing the first original message through the j original message and the (j+1) query to determine the (j+1) task and the process of generating the (j+1) response using the (j+1) data. In the chat history, a first summary message (the first summary message includes a summary regarding at least the first query information and the first response information) corresponding to the first original message stored in the chat history is generated, the first summary message is stored in an external storage, and the first original message stored in the chat history is updated to the first summary message.and (c) when a k-th query for requesting a k-th service is acquired from the user, where k is an integer that sequentially increases from j+2, the AI ​​agent analyzes the first summary message through the (k-j-1)-th summary message stored in the chat history, the (k-j)-th original message through the (k-1)-th original message stored in the chat history, and the k-th query to determine a k-th task for providing the k-th service, acquires k-th data necessary for providing the k-th service from the at least one database according to the k-th task, generates a k-th response corresponding to the k-th query using the k-th data, and provides the k-th response to the user, and the k-th original message (the k-th original message) includes (i) k-th query information regarding the k-th query, (ii) the first summary message through the (k-j)-th summary message, and (iii) the k-th query information regarding the k-th query. -1) storing a summary message, the (k-j) original message or the (k-1) original message and the k query to determine the k task, and the k-th agent operation information relating to the process of generating the k response using the k data, and (iii) k-th response information relating to the k response) in the chat history, generating a (k-j) summary message (the (k-j) summary message including at least a summary of the (k-j) query information and the (k-j) response information) corresponding to the (k-j) original message stored in the chat history, storing the (k-j) original message in an external storage, and repeatedly performing a k-th turn of updating the (k-j) original message stored in the chat history to the (k-j) summary message;

[0014] In one example, in step (c), if the AI ​​agent determines that at least one specific data corresponding to at least one specific summary message among the first summary message through the (k-j-1)th summary message is necessary to generate the kth response, the AI ​​agent acquires at least one specific original message corresponding to the at least one specific summary message stored in the external storage, acquires the at least one specific data included in the at least one specific original message, and generates the kth response using the at least one specific data acquired from the at least one specific original message.

[0015] In one example, when the AI ​​agent stores the kth original message including the kth query information, the kth agent action information, and the kth response information in the chat history, it deletes the kth agent sub-action information (the kth agent sub-action information indicates the process of obtaining the at least one specific original message corresponding to the at least one specific summary message stored in the external storage and obtaining the at least one specific data included in the at least one specific original message) from the kth agent action information, and stores the kth agent action information with the kth agent sub-action information deleted in the chat history.

[0016] In one example, when the AI ​​agent stores the kth original message including the kth query information, the kth agent action information, and the kth response information in the chat history, it adds kth agent sub-action information (the kth agent sub-action information indicates the process of acquiring the at least one specific original message corresponding to the at least one specific summary message stored in the external storage and acquiring the at least one specific data included in the at least one specific original message) to the kth agent action information, and stores the kth agent action information with the added kth agent sub-action information in the chat history.

[0017] In one example, in step (a), the AI ​​agent adds the first through (p-1) original messages and the p query to a pre-defined chat prompt template and requests the p service from an LLM (Large Language Model), thereby performing the pth turn using the LLM; in step (b), the AI ​​agent adds the first through jth original messages and the (j+1) query to the chat prompt template and requests the (j+1) service from the LLM, thereby performing the (j+1)th turn using the LLM; and in step (c), the AI ​​agent adds the first through (k-j-1) summary messages, the (k-j)th original messages and the (k-1) original messages and the k query to the chat prompt template and requests the kth service from the LLM, thereby performing the kth turn using the LLM.

[0018] According to one embodiment of the present invention, an AI agent providing a service using multi-turns includes a memory storing instructions for providing the service using multi-turns; and a processor performing an operation for providing the service using multi-turns according to the instructions stored in the memory, wherein the processor (I) when a p-th query for requesting a p-th service is received from a user for p, where p is an integer that sequentially increases from 1 to j (j is a preset integer of 1 or more), analyzes a first original message through a (p-1)-th original message stored in a chat history and the p-th query (if p is 1, analyzes only the p-th query), and determines a p-th task for providing the p-th service, obtains p-th data required to provide the p-th service from at least one database according to the p-th task, generates a p-th response corresponding to the p-th query using the p-th data, and provides the p-th response to the user, and generates a p-th original message (the p-th original message is a message that (i) p-th query information regarding the p-th query, (ii) p-th agent operation information regarding a process of analyzing the first original message through the (p-1)-th original message and the p-th query to determine the p-th task and a process of generating the p-th response using the p-th data, and (iii) p-th response information regarding the p-th response; (II) if a (j+1)-th query to request a (j+1)-th service is acquired from the user, the process of storing the p-th query information in the chat history. and determining a (j+1)th task for providing the (j+1)th service by analyzing the 1st through jth original messages and the (j+1)th query stored in the tree, acquiring the (j+1)th data necessary to provide the (j+1)th service from the at least one database through the (j+1)th task, generating a (j+1)th response corresponding to the (j+1)th query using the (j+1)th data, and providing the (j+1) response to the user; and(i) (j+1)th query information regarding the (j+1)th query, (ii) (j+1)th agent operation information regarding a process of determining the (j+1)th task by analyzing the first original message through the jth original message and the (j+1)th query, and a process of generating the (j+1)th response using the (j+1)th data, and (iii) (j+1)th response information regarding the (j+1)th response) is stored in the chat history, and a first summary message ( (III) performing a (j+1)th turn of updating the first original message stored in the chat history to the first summary message, where k is an integer that sequentially increases from j+2, when a k-th query for requesting a k-th service is received from a user, the first summary message is updated to the first summary message (the first summary message includes a summary of at least the first query information and the first response information), the first original message is stored in an external storage, and the first summary message is updated to the first summary message (the first summary message includes a summary of at least the first query information and the first response information), the first original message is stored in an external storage, and the first original message stored in the chat history is updated to the first summary message; and (III) performing a (j+1)th turn of updating the first original message stored in the chat history to the first summary message, where k is an integer that sequentially increases from j+2, when a k-th query for requesting a k-th service is received from a user, the first summary message is updated to the first summary message (the first summary message includes a summary of at least the first query information and the first response information), ... summary message), the first summary message is updated to the first summary message (the first summary message includes a summary of at least the first summary message), the a message, analyze the (k-j)th original message or the (k-1)th original message and the k query stored in the chat history to determine a k-th task for providing the k service, obtain k-th data necessary for providing the k service from the at least one database through the l task, generate a k-th response corresponding to the k query using the k data, and provide the k-th response to the user; store a k-th original message (the k-th original message includes (i) k-th query information related to the k query, (ii) k-th agent operation information related to a process of analyzing the first summary message or the (k-j-1) summary message, the (k-j)th original message or the (k-1) original message, and the k query to determine the k task, and a process of generating the k response using the k data, and (iii) k-th response information related to the k response) in the chat history; and store a (k-j)th summary message (the (k-j) summary message corresponding to the (k-j)th original message stored in the chat history (the (k-j) summary message includesAn AI agent is provided that performs a process of repeatedly performing a k-th turn of generating a summary message (including at least a summary of the (k-j)th query information and the (k-j)th response information), storing the (k-j)th original message in an external storage, and updating the (k-j)th original message stored in the chat history to the (k-j)th summary message.

[0019] In one example, if the processor determines in process (III) that at least one specific piece of data corresponding to at least one specific summary message among the first summary message through the (k-j-1) summary messages is necessary to generate the kth response, the processor acquires at least one specific original message corresponding to the at least one specific summary message stored in the external storage, acquires the at least one specific piece of data included in the at least one specific original message, and generates the kth response using the at least one specific piece of data acquired from the at least one specific original message.

[0020] In one example, when the processor stores the kth original message including the kth query information, the kth agent action information, and the kth response information in the chat history, it deletes the kth agent sub-action information (the kth agent sub-action information indicates the process of obtaining the at least one specific original message corresponding to the at least one specific summary message stored in the external storage and obtaining the at least one specific piece of data included in the at least one specific original message) from the kth agent action information, and stores the kth agent action information from which the kth agent sub-action information has been deleted in the chat history.

[0021] In one example, when the processor stores the kth original message including the kth query information, the kth agent action information, and the kth response information in the chat history, the processor adds kth agent sub-action information (the kth agent sub-action information indicates a process of acquiring the at least one specific original message corresponding to the at least one specific summary message stored in the external storage and acquiring the at least one specific piece of data included in the at least one specific original message) to the kth agent action information, and stores the kth agent action information with the added kth agent sub-action information in the chat history.

[0022] In one example, in the process (I), the processor performs the pth turn using a Large Language Model (LLM) by adding the first through the (p-1)th original message and the pth query to a pre-defined chat prompt template and requesting the pth service from the LLM; in the process (II), the processor performs the (j+1)th turn using the LLM by adding the first through the jth original message and the (j+1)th query to the chat prompt template and requesting the (j+1)th service from the LLM; and in the process (III), the processor performs the kth turn using the LLM by adding the first through the (k-j-1)th summary message, the (k-j)th original message to the (k-1)th original message, and the kth query to the chat prompt template and requesting the kth service from the LLM. [Effects of the Invention]

[0023] According to the present invention, by maintaining only the messages for the most recent j turns as the originals and using the summary messages for the previous turns, the cost of the AI ​​agent's task execution can be reduced and the speed can be improved.

[0024] According to the present invention, the original message corresponding to the summary message is stored in external storage, and the original message can be accessed when necessary, thereby eliminating the risk of information loss in multiple turns of the AI ​​agent.

[0025] According to the present invention, even when data used in a previous turn is required, instead of obtaining it from a database through a data search operation, the data can be obtained from the original message stored corresponding to the summary message, thereby minimizing the data search operation of the AI ​​agent. [Brief explanation of the drawings]

[0026] The following drawings, attached for use in explaining embodiments of the present invention, are merely a part of the embodiments of the present invention, and a person having ordinary knowledge in the technical field to which the present invention pertains (hereinafter referred to as "ordinary engineer") can derive each of the other drawings based on these drawings without performing any inventive work.

[0027] [Figure 1] 1 is a simplified illustration of an AI agent providing services using multiple turns according to one embodiment of the present invention. [Figure 2] 1 is a simplified diagram illustrating how an AI agent provides services using multiple turns according to one embodiment of the present invention. [Figure 3] 1 is a simplified illustration of an exemplary scenario illustrating how an AI agent can provide services using multiple turns according to one embodiment of the present invention. [Figure 4a]1 is a simplified illustration of an exemplary scenario illustrating how an AI agent can provide services using multiple turns according to one embodiment of the present invention. [Figure 4b] 1 is a simplified illustration of an exemplary scenario illustrating how an AI agent can provide services using multiple turns according to one embodiment of the present invention. [Figure 5a] 1 is a simplified illustration of an exemplary scenario illustrating how an AI agent can provide services using multiple turns according to one embodiment of the present invention. [Figure 5b] 1 is a simplified illustration of an exemplary scenario illustrating how an AI agent can provide services using multiple turns according to one embodiment of the present invention. DETAILED DESCRIPTION OF THE INVENTION

[0028] The following detailed description of the present invention refers to the accompanying drawings, which show, by way of example, specific embodiments in which the present invention may be practiced. These embodiments are described in sufficient detail to enable those skilled in the art to practice the invention. It should be understood that although various embodiments of the present invention are different from one another, they are not necessarily mutually exclusive. For example, specific shapes, structures, and characteristics described herein may be embodied in different embodiments without departing from the spirit and scope of the present invention. It should also be understood that the location or arrangement of individual components within each embodiment may be changed without departing from the spirit and scope of the present invention. Therefore, the following detailed description is not intended to be taken in a limiting sense, and the scope of the present invention should be understood to encompass the scope of the appended claims and all equivalents thereto. In the drawings, like reference numerals refer to the same or similar functionality throughout the various aspects.

[0029] DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS Hereinafter, various preferred embodiments of the present invention will be described in detail with reference to the accompanying drawings so that those skilled in the art can easily practice the present invention.

[0030] FIG. 1 is a simplified diagram of an AI agent that provides a service using multi-turns according to one embodiment of the present invention. Referring to FIG. 1, the AI ​​agent 1000 may include a memory 1100 that stores instructions for providing a service using multi-turns, and a processor 1200 that performs operations for providing a service using multi-turns according to the instructions stored in the memory 1100.

[0031] Specifically, AI agent 1000 typically utilizes, but is not limited to, a combination of computing devices (e.g., devices that may include computer processors, memory, storage, input and output devices, and other components of existing computing devices; electronic communication devices such as routers, switches, etc.; electronic information storage systems such as network attached storage (NAS) and storage area networks (SAN)) and computer software (i.e., instructions that cause a computing device to function in a particular manner) to achieve desired system performance.

[0032] The processor 1200 of the AI ​​agent 1000 may include hardware components such as a microprocessing unit (MPU) or central processing unit (CPU), cache memory, and data bus. The computing device may also include software components such as an operating system and applications that perform specific purposes.

[0033] However, this does not exclude the case where the AI ​​agent 1000 includes an integrated processor in which a medium, processor, and memory for implementing the present invention are integrated.

[0034] Meanwhile, when processor 1200 of AI agent 1000 receives a p-th query from a user requesting a p-th service, where p is an integer that sequentially increases from 1 to j, according to instructions stored in memory 1100, processor 1200 analyzes the first original message through the (p-1)th original message and the p-th query stored in the chat history to determine a p-th task for providing the p-th service, obtains p-th data necessary to provide the p-th service from at least one database according to the p-th task, generates a p-th response corresponding to the p-th query using the p-th data, provides the p-th response to the user, and stores the p-th original message in the chat history, repeating the p-th turn. Here, j may be a preset integer greater than or equal to 1, and when p is 1, processor 1200 may analyze only the p-th query to determine the first task. In this case, the pth original message may include (i) pth query information regarding the pth query, (ii) pth agent operation information regarding the process of determining the pth task by analyzing the first original message through the (p-1)th original message and the pth query, and the process of generating the pth response using the pth data, and (iii) pth response information regarding the pth response.

[0035] Thereafter, when the processor 1200 of the AI ​​agent 1000 receives a (j+1)th query to request the (j+1)th service from the user according to the instructions stored in the memory 1100, the processor 1200 can perform the (j+1)th turn of analyzing the first original message through the j-th original message and the (j+1)th query stored in the chat history to determine a (j+1)th task for providing the (j+1)th service, obtaining the (j+1)th data necessary to provide the (j+1)th service from at least one database using the (j+1)th data, generating a (j+1)th response corresponding to the (j+1)th query using the (j+1)th data, and providing the (j+1)th response to the user, storing the (j+1)th original message in the chat history, generating a first summary message corresponding to the first original message stored in the chat history, storing the first original message in external storage, and updating the first original message stored in the chat history to the first summary message.

[0036] In this case, the (j+1)th original message may include (i) the (j+1)th query information regarding the (j+1)th query, (ii) the (j+1)th agent operation information regarding the process of determining the (j+1)th task by analyzing the first original message through the jth original message and the (j+1)th query, and the process of generating the (j+1)th response using the (j+1)th data, and (iii) the (j+1)th response information regarding the (j+1)th response.

[0037] The first summary message may include a summary of at least the first query information and the first response information. Thereafter, when the processor 1200 of the AI ​​agent 1000 receives a k-th query for requesting the k-th service from a user, where k is an integer that sequentially increases from j+2, according to instructions stored in the memory 1100, the processor 1200 analyzes the first summary message through the (k-j-1)th summary message stored in the chat history, the (k-j)th original message through the (k-1)th original message stored in the chat history, and the k query to determine a k-th task for providing the k-th service, obtains the k-th data necessary to provide the k-th service from at least one database using the k-th data, generates a k-th response corresponding to the k-th query and provides the k-th response to the user, stores the k-th original message in the chat history, generates a (k-j)th summary message corresponding to the (k-j)th original message stored in the chat history, stores the (k-j)th original message in external storage, and updates the (k-j)th original message stored in the chat history to the (k-j)th summary message, thereby repeating the k-th turn.

[0038] In this case, the (kj)th summary message may include a summary of at least the (kj)th query information and the (kj)th response information.

[0039] The kth original message may include (i) kth query information regarding the kth query, (ii) kth agent operation information regarding the process of determining the kth task by analyzing the first summary message through the (k-j-1)th summary message, the (k-j)th original message through the (k-1)th original message, and the kth query, and the process of generating the kth response using the kth data, and kth response information regarding the kth response.

[0040] A method for providing a service using multi-turns in the AI ​​agent 1000 configured as above will be described in more detail with reference to FIG.

[0041] First, the AI ​​agent 1000 may sequentially increase an integer p from 1 to j, and repeatedly perform a pth turn (S100) of providing a pth response to a pth query received from the user 100, i.e., the user terminal, and storing a pth original message in the chat history 1110. In this case, j may be a preset integer equal to or greater than 1. When a summary message and an original message of a previous turn stored in the chat history 1110 are used in the current turn, j represents the number of original messages used, and j original messages may correspond to the most recent j turns.

[0042] Specifically, when a p-th query for requesting a p-th service is acquired from a user 100 (S101), where p is an integer that sequentially increases from 1 to j, the AI ​​agent 1000 acquires the first through (p-1)th original messages stored in the chat history 1110 (S102), and analyzes the first through (p-1)th original messages and the p-th query to determine a p-th task for providing the p-th service (S103). On the other hand, when p is 1, i.e., the first turn in a multi-turn chat, there is no original message stored in the chat history 1110, so the AI ​​agent 1000 can determine the first task using only the first query.

[0043] At this time, the AI ​​agent 1000 adds the first original message to the (p-1)th original message obtained from the chat history 1110 to the pre-set chat prompt template, and further adds the pth query entered by the user to the chat prompt template to request the pth service from the LLM, i.e., by calling the LLM through the chat prompt template to which the first original message to the (p-1)th original message and the pth query have been added, the AI ​​agent 1000 can have the LLM determine the pth task.

[0044] Then, the AI ​​agent 1000 can acquire p-th data required to provide the p-th service from at least one database 200 according to the determined p-th task (S104).

[0045] Thereafter, the AI ​​agent 1000 can generate a pth response corresponding to the pth query using the pth data (S105) and provide the generated pth response to the user (S106).

[0046] Then, the AI ​​agent 1000 can store the p-th original message in the chat history 1110 (S107). At this time, the p-th original message can include (i) p-th query information related to the p-th query, (ii) p-th agent operation information related to a process of determining the p-th task by analyzing the first to (p-1)-th original messages and the p-th query and a process of generating the p-th response using the p-th data, and (iii) p-th response information related to the p-th response.

[0047] When the first through j-th turns are carried out in this manner, the chat history 1110 can store the first through j-th original messages.

[0048] Next, the AI ​​agent 1000 may perform the (j+1)th turn (S200) of providing the (j+1)th response to the (j+1)th query received from the user 100, storing the (j+1)th original message in the chat history 1110, generating a first summary message corresponding to the first original message stored in the chat history 1110, storing the first original message in the external storage 300, and updating the first original message stored in the chat history 1110 to the first summary message. At this time, the first summary message may include a summary of at least the first query information and the first response information.

[0049] Specifically, when the first through jth original messages are stored in the chat history 1110 and a (j+1)th query to request the (j+1)th service is acquired (S201) from the user 100, the AI ​​agent 1000 can acquire the first through jth original messages stored in the chat history 1110 (S202), analyze the first through kth original messages and the (j+1)th query, and determine the (j+1)th task to provide the (j+1)th service (S203).

[0050] At this time, the AI ​​agent 1000 adds the first to jth original messages obtained from the chat history 1110 to the chat prompt template, and further adds the (j+1)th query entered by the user to the chat prompt template to request the (j+1)th service from the LLM, i.e., by calling the LLM through the chat prompt template to which the first to jth original messages and the (j+1)th query have been added, the AI ​​agent 1000 can have the LLM determine the (j+1)th task.

[0051] Then, the AI ​​agent 1000 can acquire (j+1)th data necessary to provide the (j+1)th service from at least one database 200 according to the determined (j+1)th task (S204).

[0052] Thereafter, the AI ​​agent 1000 can generate a (j+1)th response corresponding to the (j+1)th query using the (j+1)th data (S205) and provide the generated (j+1)th response to the user (S206).

[0053] The AI ​​agent 1000 can then store the (j+1)th original message in the chat history 1110 (S207). At this time, the (j+1)th original message can include (i) the (j+1)th query information corresponding to the (j+1)th query, (ii) the (j+1)th agent operation information related to the process of determining the (j+1)th task by analyzing the first to jth original messages and the (j+1)th query and the process of generating the (j+1)th response using the (j+1)th data, and (iii) the (j+1)th response information related to the (j+1)th response.

[0054] In addition, after generating a first summary message corresponding to the first original message stored in the chat history 1110, the AI ​​agent 1000 can update the first original message stored in the chat history 1110 to the first summary message (S208) and store the first original message in the external storage 300 (S209).

[0055] At this time, the AI ​​agent 1000 inputs the first original message into the LLM and uses the LLM to summarize the first original message to generate a first summary message, which may include a summary of at least the first query information and the first response information.

[0056] When the (j+1)th turn is completed in the above manner, the first summary message and the second to pth original messages can be stored in the chat history 1110, and the first original message can be stored in the external storage 300.

[0057] Next, the AI ​​agent 1000 may sequentially increase the integer k from (j+2), provide the kth response to the kth query received from the user 100, store the kth original message in the chat history 1110, generate a (k-j)th summary message for the (k-j)th original message stored in the chat history 1110, store the (k-j)th original message in the external storage 300, and update the (k-j)th original message stored in the chat history 1110 to the (k-j)th summary message (S300). In this case, the (k-j)th summary message may include at least a summary of the (k-j)th query information and the (k-j)th response information.

[0058] Specifically, when the first summary message through the (k-j-1)th summary message and the (k-j)th original message through the (k-1)th original message are stored in the chat history 1110 and the first original message through the (k-j-1)th original message are stored in the external storage 300, and when a kth query for requesting the kth service is acquired from the user 100 (S301), where k is an integer that sequentially increases from j+2, the AI ​​agent 1000 acquires the first summary message through the (k-j-1)th summary message, the (k-j)th original message, and the (k-1)th original message stored in the chat history 1110 (S302), and analyzes the first summary message through the (k-j-1)th summary message, the (k-j)th original message, the (k-1)th original message, and the kth query to determine the kth task for providing the kth service (S303).

[0059] At this time, the AI ​​agent 1000 adds the first summary message through the (k-j-1)th summary message and the (k-j)th original message through the (k-1)th original message obtained from the chat history 1110 to the chat prompt template, and further adds the kth query entered by the user to the chat prompt template to request the kth service from the LLM, i.e., by calling the LLM through the chat prompt template to which the first summary message through the (k-j-1)th summary message, the (k-j)th original message through the (k-1)th original message, and the kth query have been added, the AI ​​agent 1000 can have the LLM determine the kth task.

[0060] Then, the AI ​​agent 1000 can acquire k-th data necessary to provide the k-th service from at least one database 200 according to the determined k-th task (S304).

[0061] Thereafter, the AI ​​agent 1000 can generate a kth response corresponding to the kth query using the kth data (S305) and provide the generated kth response to the user 100 (S306).

[0062] The AI ​​agent 1000 can then store the k-th original message in the chat history 1110 (S307). At this time, the k-th original message can include (i) k-th query information corresponding to the k-th query, (ii) k-th agent operation information related to a process of determining the k-th task by analyzing the first summary message through the (k-j-1)-th summary message, the (k-j)-th original message through the (k-1)-th original message, and the k-th query, and a process of generating the k-th response using the k-th data, and (iii) k-th response information related to the k-th response.

[0063] In addition, after generating the (k-j)th summary message corresponding to the (k-j)th original message stored in the chat history 1110, the AI ​​agent 1000 can update the (k-j)th original message stored in the chat history 1110 to the (k-j)th summary message (S308) and store the (k-j)th original message in the external storage 300 (S309).

[0064] In this case, the AI ​​agent 1000 inputs the (k-j)th original message into the LLM and uses the LLM to summarize the (k-j)th original message to generate the (k-j)th summary message, and the (k-j)th summary message can include at least a summary of the (k-j)th query information and the (k-j)th response information.

[0065] Meanwhile, if, while repeating the kth turn, it is determined that at least one specific piece of data corresponding to at least one specific summary message among the first summary message through the (k-j-1)th summary message is necessary to generate the kth response, the AI ​​agent 1000 can acquire at least one specific original message corresponding to the at least one specific summary message stored in the external storage 300, acquire at least one specific piece of data contained in the at least one specific original message, and generate the kth response using the at least one specific piece of data acquired from the at least one specific original message.

[0066] At this time, when the AI ​​agent 1000 stores the kth original message including the kth query information, the kth agent action information, and the kth response information in the chat history 1110, it can acquire at least one specific original message corresponding to at least one specific summary message stored in the external storage 300 from the kth agent action information, delete the kth agent sub-action information indicating the process of acquiring at least one specific data included in the at least one specific original message, and store the kth agent action information from which the kth agent sub-action information has been deleted in the chat history 1110.

[0067] Alternatively, when the AI ​​agent 1000 stores the kth original message including the kth query information, the kth agent action information, and the kth response information in the chat history 1110, it can add the kth agent sub-action information to the kth agent action information and store the kth agent action information with the kth agent sub-action information added in the chat history 1110.

[0068] The method for an AI agent to provide a service using multiple turns according to the present invention will be briefly explained below using the exemplary scenarios of Figures 3 to 5b. For reference, in the following scenarios, it is assumed that a service is provided in the current turn using one original message from the previous turn.

[0069] First, Figure 3 shows an example of the first original message 2100 stored in the chat history after the first turn in which the user asks about the temperature in "San Francisco" today and tomorrow and the AI ​​agent responds to the question.

[0070] Referring to FIG. 3, a first original message 2100 may include first query information 2110 , first agent operation information 2121 and 2122 , and first response information 2130 .

[0071] According to the first query information 2110 of the first original message 2100, it is clear that the user has requested today's and tomorrow's temperatures in "San Francisco" on September 30, 2024.

[0072] According to the first agent operation information 2121, 2122 of the first original message 2100, the AI ​​agent analyzed the user's first query, determined the location parameters of "San Francisco," and determined the exact date parameters for today and tomorrow requested by the user based on September 30, 2024. Thereafter, it determined 2121 a first task to obtain today's and tomorrow's temperatures in "San Francisco" from the database, and obtained 2122 the first data, which is today's and tomorrow's temperatures in "San Francisco," from the database using the determined first task.

[0073] Furthermore, the first response information 2130 of the first original message 2100 indicates that the AI ​​agent has provided the first response to the user using the first data.

[0074] Next, Figure 4a shows a simplified diagram of the second turn providing a second response to the user's second query. For reference, the second turn is assumed to be a query and response similar to the first turn for comparison with the summary message.

[0075] As shown in Figure 4a, when a second query is input by the user, the AI ​​agent analyzes the first original message 2100 and the second query to determine a second task, obtains second data from the database through the second task, generates a second response using the second data, provides it to the user, and then stores the second original message 2200 in the chat history.

[0076] Referring to FIG. 4b, the AI ​​agent stores the first original message stored in the chat history in external storage, then summarizes the first original message to generate a first summary message 2100′, and updates the first original message stored in the chat history to the first summary message 2100′.

[0077] Next, referring to Figure 5a, when the user inputs a third query inquiring about the results of the first turn, the AI ​​agent analyzes the first summary message 2100', the second original message 2200, and the third query to determine a third task, and performs a third agent sub-operation to obtain the first data of the first turn by obtaining the first original message (turn 1 message 2000) stored in external storage corresponding to the first summary message 2100' through the third task, and provides third response information to the third query using the first data obtained by the third agent sub-operation, i.e., today's and tomorrow's temperatures in "San Francisco."

[0078] Referring to FIG. 5b, the AI ​​agent then updates the second original message stored in the chat history to a second summary message 2200', and stores the third original message 2300 in the chat history with the third agent sub-action information 2320 in the third original message 2300 of FIG. 5a deleted.

[0079] Meanwhile, unlike the third original message being stored in the chat history with the third agent sub-action information 2320 deleted as shown in Figure 5b, the third original message with the third agent sub-action information 2320 added can also be stored in the chat history as is as shown in Figure 5a.

[0080] The above-described embodiments of the present invention may be embodied in the form of program instructions executable by various computer components and stored on a computer-readable recording medium. The computer-readable recording medium may include program instructions, data files, data structures, and the like, alone or in combination. The program instructions stored on the computer-readable recording medium may be specially designed and constructed for the present invention, or may be known and available to those skilled in the art of computer software. Examples of computer-readable recording media include magnetic media such as hard disks, floppy disks, and magnetic tapes; optical media such as CD-ROMs and DVDs; magneto-optical media such as floptical disks; and hardware devices specially configured to store and execute program instructions, such as ROM, RAM, and flash memory. Examples of program instructions include not only machine language code, such as that produced by a compiler, but also high-level language code executed by a computer using an interpreter. The hardware devices may be configured to operate as one or more software modules to perform the processes of the present invention, or vice versa.

[0081] Although the present invention has been described above using specific details such as specific components and limited examples and drawings, this is provided merely to aid in a more general understanding of the present invention, and the present invention is not limited to the above examples. Those skilled in the art will be able to make various modifications and variations from such descriptions.

[0082] Therefore, the concept of the present invention should not be limited to the above-described embodiments, and all modifications equivalent to or equivalent to the scope of the claims, as well as the scope of the claims described below, are within the scope of the concept of the present invention. [Explanation of symbols]

[0083] 1000 AI agents, 1100 memory 1200 processor

Claims

1. In a method for providing a service by an AI agent using multi-turn, (a) When a p-th query for requesting a p-th service is acquired from a user for p, which is an integer that sequentially increases from 1 to j (j is a preset integer of 1 or more), an AI agent analyzes the first original message to the (p-1)-th original message stored in the chat history and the p-th query (when p is 1, only the p-th query is analyzed), determines a p-th task for providing the p-th service, acquires p-th data required to provide the p-th service from at least one database according to the p-th task, and executes the p-th data. generating a p-th response corresponding to the p-th query using the p-th data, providing the p-th response to the user, and storing a p-th original message (the p-th original message includes (i) p-th query information related to the p-th query, (ii) p-th agent operation information related to a process of analyzing the first original message through the (p-1)th original message and the p-th query to determine the p-th task and a process of generating the p-th response using the p-th data, and (iii) p-th response information related to the p-th response) in the chat history; (b) when a (j+1)th query for requesting a (j+1)th service is acquired from the user, the AI ​​agent analyzes the first original message through the jth original message and the (j+1)th query stored in the chat history to determine a (j+1)th task for providing the (j+1)th service, acquires (j+1)th data necessary for providing the (j+1)th service from the at least one database according to the (j+1)th task, generates a (j+1)th response corresponding to the (j+1)th query using the (j+1)th data, and provides the (j+1)th response to the user, and the (j+1)th original message (the (j+1)th message) includes (i) the (j+1)th query information related to the (j+1)th query, (ii) the (iii) (j+1)th response information regarding the (j+1)th response (including (j+1)th agent operation information regarding a process of determining the (j+1)th task by analyzing the 1st original message through the jth original message and the (j+1)th query and a process of generating the (j+1)th response using the (j+1)th data), and (iii) (j+1)th response information regarding the (j+1)th response in the chat history, generating a first summary message corresponding to the first original message stored in the chat history (the first summary message including a summary regarding at least the first query information and the first response information), storing the first original message in an external storage, and updating the first original message stored in the chat history to the first summary message; (c) When a k-th query for requesting a k-th service is acquired from the user, where k is an integer that sequentially increases from j+2, the AI ​​agent analyzes the first summary message through the (k-j-1)-th summary message stored in the chat history, the (k-j)-th original message through the (k-1)-th original message stored in the chat history, and the k-th query to determine a k-th task for providing the k-th service, acquires k-th data necessary for providing the k-th service from the at least one database according to the k-th task, generates a k-th response corresponding to the k-th query using the k-th data, and provides the k-th response to the user, and generates a k-th original message (the k-th original message includes: (i) k-th query information regarding the k-th query, (ii) the first summary message through the (k-j-1)-th original message, and (iii) the k-th query information regarding the k-th query. storing the (k-j-1)th summary message, the (k-j)th original message, or the (k-1)th original message and the kth query to determine the kth task, and the kth agent operation information related to the process of generating the kth response using the kth data, and (iii) the kth response information related to the kth response, in the chat history; generating a (k-j)th summary message (the (k-j) summary message including at least a summary of the (k-j)th query information and the (k-j)th response information) corresponding to the (k-j)th original message stored in the chat history; storing the (k-j)th original message in an external storage; and repeatedly performing a kth turn of updating the (k-j)th original message stored in the chat history to the (k-j)th summary message; A method comprising:

2. In the step (c), 2. The method of claim 1, wherein, if the AI ​​agent determines that at least one specific piece of data corresponding to at least one specific summary message among the first summary message through the (k-j-1)th summary message is necessary to generate the kth response, the AI ​​agent acquires at least one specific original message corresponding to the at least one specific summary message stored in the external storage, acquires the at least one specific piece of data included in the at least one specific original message, and generates the kth response using the at least one specific piece of data acquired from the at least one specific original message.

3. 3. The method of claim 2, wherein when the AI ​​agent stores the kth original message including the kth query information, the kth agent action information, and the kth response information in the chat history, the AI ​​agent deletes kth agent sub-action information (the kth agent sub-action information indicates a process of acquiring the at least one specific original message corresponding to the at least one specific summary message stored in the external storage and acquiring the at least one specific piece of data included in the at least one specific original message) from the kth agent action information, and stores the kth agent action information from which the kth agent sub-action information has been deleted in the chat history.

4. 3. The method of claim 2, wherein when the AI ​​agent stores the kth original message including the kth query information, the kth agent action information, and the kth response information in the chat history, the AI ​​agent adds kth agent sub-action information (the kth agent sub-action information indicating a process of acquiring the at least one specific original message corresponding to the at least one specific summary message stored in the external storage and acquiring the at least one specific piece of data included in the at least one specific original message) to the kth agent action information, and stores the kth agent action information with the kth agent sub-action information added in the chat history.

5. In the step (a), The AI ​​agent adds the first original message to the (p-1)th original message and the pth query to a pre-set chat prompt template and requests the pth service from an LLM (Large Language Model), thereby performing the pth turn with the LLM; In the step (b), The AI ​​agent adds the first original message through the jth original message and the (j+1)th query to the chat prompt template and requests the (j+1)th service from the LLM, thereby performing the (j+1)th turn with the LLM; In the step (c), 2. The method of claim 1, wherein the AI ​​agent performs the kth turn with the LLM by adding the first summary message through the (k-j-1)th summary message, the (k-j)th original message through the (k-1)th original message, and the kth query to the chat prompt template and requesting the kth service from the LLM.

6. In an AI agent that provides services using multi-turns, a memory storing instructions for providing a service using multi-turn; a processor that performs an operation to provide a service using the multi-turn according to the instructions stored in the memory; Including, The processor (I) analyzes a first original message through a (p-1)th original message and the p query stored in a chat history (if p is 1, analyzes only the p query) when a p-th query for requesting a p-th service is received from a user, where p is an integer that sequentially increases from 1 to j (j is a preset integer of 1 or more), to determine a p-th task for providing the p-th service, obtains p-th data required to provide the p service from at least one database according to the p task, generates a p-th response corresponding to the p query using the p data, and provides the p-th response to the user, and sends a p-th original message (the p-th original message includes (i) p-th query information regarding the p query, (ii) p-th agent operation information regarding a process of determining the p task by analyzing the first original message through the (p-1)th original message and the p query and a process of generating the p response using the p data, and (iii) p-th response information regarding the p response) to the chat. (II) when a (j+1)th query for requesting a (j+1)th service is acquired from the user, the (j+1)th task for providing the (j+1)th service is determined by analyzing the first original message through the jth original message and the (j+1)th query stored in the chat history, and acquiring the (j+1)th data required to provide the (j+1)th service from the at least one database according to the (j+1)th task, and generating a (j+1)th response corresponding to the (j+1)th query using the (j+1)th data and providing the (j+1)th response to the user; and a (j+1)th original message (the (j+1)th original message includes: (i) (j+1)th query information regarding the (j+1)th query; (ii) (j+1)th agent operation information regarding a process of analyzing the first original message through the jth original message and the (j+1)th query to determine the (j+1)th task and a process of generating the (j+1)th response using the (j+1)th data;and (iii) performing a (j+1)th turn of storing the (j+1)th response information (including the (j+1)th response information regarding the (j+1)th response) in the chat history, generating a first summary message (the first summary message including at least the first query information and a summary regarding the first response information) corresponding to the first original message stored in the chat history, storing the first original message in an external storage, and updating the first original message stored in the chat history to the first summary message; and (III) when a k-th query for requesting a k-th service is acquired from a user, where k is an integer that sequentially increases from j+2, analyzing the first summary message through the (k-j-1)th summary message stored in the chat history, the (k-j)th original message through the (k-1)th original message stored in the chat history, and the k-th query to determine a k-th task for providing the k-th service, acquiring k-th data required to provide the k-th service from the at least one database according to the k-th task, and updating the k-th data. a k-th response corresponding to the k-th query using the k-th data, and providing the k-th response to the user; and a k-th original message (the k-th original message includes: (i) k-th query information regarding the k-th query; (ii) k-th agent operation information regarding a step of analyzing the first summary message through the (k-j-1) summary message, the (k-j)th original message through the (k-1)th original message, and the k-th query to determine the k-th task and a step of generating the k-th response using the k-th data; and (iii) k-th agent operation information regarding a step of generating the k-th response using the k-th data. and storing the (k-j) original message (including k-j) response information related to the (k-j) original message) in the chat history, generating a (k-j) summary message corresponding to the (k-j) original message stored in the chat history (the (k-j) summary message including at least a summary related to the (k-j) query information and the (k-j) response information), storing the (k-j) original message in an external storage, and updating the (k-j) original message stored in the chat history to the (k-j) summary message, thereby repeatedly performing a k-th turn.AI agent.

7. The processor:

7. The AI ​​agent of claim 6, wherein, in the process (III), if it is determined that at least one specific piece of data corresponding to at least one specific summary message among the first summary message through the (k-j-1) summary messages is necessary to generate the kth response, the AI ​​agent obtains at least one specific original message corresponding to the at least one specific summary message stored in the external storage, obtains the at least one specific piece of data included in the at least one specific original message, and generates the kth response using the at least one specific piece of data obtained from the at least one specific original message.

8. The processor:

8. The AI ​​agent of claim 7, wherein when the kth original message including the kth query information, the kth agent action information, and the kth response information is stored in the chat history, kth agent sub-action information (the kth agent sub-action information indicates a process of acquiring the at least one specific original message corresponding to the at least one specific summary message stored in the external storage and acquiring the at least one specific piece of data included in the at least one specific original message) is deleted from the kth agent action information, and the kth agent action information from which the kth agent sub-action information has been deleted is stored in the chat history.

9. The processor:

8. The AI ​​agent of claim 7, wherein when the kth original message including the kth query information, the kth agent action information, and the kth response information is stored in the chat history, kth agent sub-action information (the kth agent sub-action information indicating a process of acquiring the at least one specific original message corresponding to the at least one specific summary message stored in the external storage and acquiring the at least one specific piece of data included in the at least one specific original message) is added to the kth agent action information, and the kth agent action information with the kth agent sub-action information added is stored in the chat history.

10. The processor: In the process (I), the first original message through the (p-1)th original message and the pth query are added to a pre-set chat prompt template, and the pth service is requested from an LLM (Large Language Model), thereby performing the pth turn with the LLM; In the process (II), the first original message through the jth original message and the (j+1)th query are added to the chat prompt template to request the (j+1)th service from the LLM, thereby performing the (j+1)th turn with the LLM; 7. The AI ​​agent of claim 6, wherein in the process (III), the first summary message through the (k-j-1) summary message, the (k-j) original message through the (k-1) original message, and the k query are added to the chat prompt template to request the k service from the LLM, thereby performing the k turn with the LLM.

Citation Information

Patent Citations

  • An automatic aligning method, and a gas monitoring system using thereof

    KR102918909B1

  • Leveraging inferred context to improve suggested messages

    US20240297856A1

  • Cache method and system for artificial intelligence service

    KR1020250057691A