A message compression method and device, electronic equipment and storage medium

By employing a multi-layered compression strategy to compress messages generated during the interaction between the user terminal and the large model, the problem of matching the call and execution results of the duplicate content destruction tool is solved, thereby improving the accuracy of session analysis.

CN122496567APending Publication Date: 2026-07-31CHUANGXIN QIZHI (BEIJING) TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
CHUANGXIN QIZHI (BEIJING) TECH CO LTD
Filing Date
2026-05-25
Publication Date
2026-07-31

AI Technical Summary

Technical Problem

Existing technologies contain duplicate content in messages generated during the interaction between user terminals and large models. Simple truncation methods disrupt the pairing relationship between tool calls and tool execution results, leading to low accuracy in session analysis.

Method used

A multi-layer compression strategy is adopted, including tool output compression algorithm, user message compression algorithm, model output message compression algorithm and intermediate elimination algorithm. Different types of messages are compressed in layers according to the priority order of message type, ensuring that different message types are compressed according to priority.

Benefits of technology

It improves the accuracy of message compression under the intelligent agent framework, avoids the discarding of duplicate content, and maintains the pairing relationship between tool calls and execution results.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122496567A_ABST
    Figure CN122496567A_ABST
Patent Text Reader

Abstract

This application provides a message compression method, apparatus, electronic device, and storage medium. The method includes: acquiring a message to be compressed, the message to be compressed including messages of different message types; employing a multi-layer compression strategy to compress messages of different message types in the message to be compressed according to message type, to obtain a target compressed message corresponding to the message to be compressed; wherein, the multi-layer compression strategy includes a tool output compression algorithm, a user message compression algorithm, a model output message compression algorithm, and an intermediate elimination algorithm, that is, different compression algorithms are used to compress different types of information in the message to be compressed according to priority, and finally obtain a target compressed message corresponding to the message to be compressed, thereby improving the accuracy of message compression under the intelligent agent framework.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of artificial intelligence technology, and more specifically, to a message compression method, apparatus, electronic device, and storage medium. Background Technology

[0002] With the rapid development of artificial intelligence, user terminals interact with large models through intelligent agents to achieve certain business functions through interactions requiring multiple sessions. During the sessions, many messages are generated. As the number of sessions increases, the number of messages also increases. During the analysis process, there will be a lot of duplicate content. Currently, a simple truncation scheme is used, which directly discards old session information in the messages. This disrupts the pairing relationship between tool calls and tool execution results. This compression method makes the accuracy of session analysis low. Summary of the Invention

[0003] The purpose of some embodiments of this application is to provide a message compression method, apparatus, electronic device, and storage medium. Through the technical solutions of the embodiments of this application, a message to be compressed is obtained, wherein the message to be compressed is determined based on initial information generated by the agent's interaction with a large model and an execution tool, respectively. The message to be compressed includes messages of different message types, including user information, agent analysis messages, model analysis messages, and tool execution messages. The messages of different message types in the message to be compressed are compressed according to the priority order of each compression algorithm in a multi-layer compression strategy to obtain a target compressed message corresponding to the message to be compressed. The multi-layer compression strategy includes a tool output compression algorithm, a user message compression algorithm, a model output message compression algorithm, and an intermediate elimination algorithm. The tool output compression algorithm is used to compress the tool execution information, the user message compression algorithm is used to compress the user information, the model output message compression algorithm is used to compress the agent analysis message, and the intermediate elimination algorithm is used to compress the session of the agent, the large model, and the execution tool. In this embodiment, messages of different message types in the message to be compressed are obtained, and a multi-layer compression strategy is adopted to determine different compression algorithms according to different message types. According to different compression algorithms, messages of different message types are compressed, and different compression algorithms are set according to priority. That is, different compression algorithms are used to compress different types of information in the message to be compressed according to priority, and finally the target compressed message corresponding to the message to be compressed is obtained, thereby improving the accuracy of message compression under the agent framework.

[0004] Firstly, some embodiments of this application provide a message compression method, including: Obtain messages to be compressed, wherein the messages to be compressed are determined based on initial information generated by the agent through conversational interactions with the large model and the execution tool, and the messages to be compressed include messages of different message types, including user information, agent analysis messages, model analysis messages and tool execution messages; According to the priority order of the compression algorithms in the multi-layer compression strategy, messages of different message types in the message to be compressed are compressed to obtain the target compressed message corresponding to the message to be compressed; wherein, the multi-layer compression strategy includes a tool output compression algorithm, a user message compression algorithm, a model output message compression algorithm, and an intermediate elimination algorithm. The tool output compression algorithm is used to compress the tool execution information, the user message compression algorithm is used to compress the user information, the model output message compression algorithm is used to compress the agent analysis message, and the intermediate elimination algorithm is used to compress the sessions of the agent, the large model, and the execution tool.

[0005] Some embodiments of this application obtain messages of different message types from the message to be compressed, employ a multi-layer compression strategy to determine different compression algorithms according to different message types, compress messages of different message types according to different compression algorithms, and set different compression algorithms according to priority. That is, different compression algorithms are used to compress different types of information in the message to be compressed according to priority, and finally obtain the target compressed message corresponding to the message to be compressed, thereby improving the accuracy of message compression under the intelligent agent framework.

[0006] Optionally, the user information is a session request received from a client; The agent analysis information consists of prompts and a list of preset tools output by the agent that correspond to the session request. The model analysis message is the analysis content and target tool list obtained by the large model analyzing the prompt words and the preset tool list; The tool execution message is the execution result output by the tool corresponding to the business operation in the target tool list. Some embodiments of this application obtain messages from each stage of the interaction between the client terminal and the intelligent agent, large model and tools, and combine the messages from all stages. If the combined message is greater than or equal to the compression threshold, then the message to be compressed is obtained.

[0007] Optionally, the step of compressing messages of different message types in the message to be compressed according to the priority order of the compression algorithms in the multi-layer compression strategy to obtain the target compressed message corresponding to the message to be compressed includes: The tool output compression algorithm is used to compress the tool execution message in the message to be compressed to obtain the first compressed message; The user message compression algorithm is used to compress the user information in the first compressed message to obtain the second compressed message; The model output message compression algorithm is used to compress the model analysis message in the second compressed message to obtain the third compressed message; The intermediate elimination algorithm is used to compress the session information of the third compressed message to obtain a fourth compressed message corresponding to the message to be compressed. The first compressed message, the second compressed message, the third compressed message, or the fourth compressed message are identified as the target compressed message.

[0008] Some embodiments of this application employ a multi-layer compression strategy to determine different compression algorithms according to different message types. Based on different compression algorithms, messages of different message types are compressed, and different compression algorithms are set according to priority. That is, different compression algorithms are used to compress different types of information in the message to be compressed according to priority, and finally the target compressed message corresponding to the message to be compressed is obtained, thereby improving the accuracy of message compression under the intelligent agent framework.

[0009] Optionally, the step of using the tool output compression algorithm to compress the tool execution message in the message to be compressed to obtain a first compressed message includes: After multiple rounds of conversations between the agent, the large model, and the tool, the tool execution message of the preset tool in the most recent first preset number of conversations in the message to be compressed is retained, and the tool execution messages of the preset tools in other conversations are deleted to obtain the first compressed message corresponding to the message to be compressed. Some embodiments of this application set a tool compression algorithm to compress the execution messages of preset tools in the compression algorithm. That is, while keeping other messages unchanged, the tool execution messages of preset tools in the most recent first preset number of sessions in the message to be compressed are retained, and the tool execution messages of preset tools in other sessions are deleted to obtain a first compressed message corresponding to the message to be compressed. That is, the message to be compressed is initially compressed. If the first compressed message is less than the compression threshold, the first compressed message is determined as the target compressed message.

[0010] Optionally, the step of using the user message compression algorithm to compress the user information in the first compressed message to obtain a second compressed message includes: If the first compressed message is greater than or equal to the compression threshold, the user messages in the most recent second preset number of sessions in the first compressed message are retained, and the user messages in other sessions are truncated according to the preset length of the user information to obtain the truncated user information. Based on the retained user message and the intercepted user information, a second compressed message corresponding to the first compressed message is determined. In some embodiments of this application, the first compressed message is judged. If it is still greater than or equal to the compression threshold, the user message in the first compressed message is compressed using a user message compression algorithm to obtain a second compressed message. If the second compression algorithm is greater than or equal to the compression threshold, the second compression algorithm is determined as the target compressed message.

[0011] Optionally, the step of using the model output message compression algorithm to compress the model analysis message in the second compressed message to obtain a third compressed message includes: If the second compressed message is greater than or equal to the compression threshold, the analysis content in the model analysis message of the most recent third preset number of sessions in the second compressed message is retained, and the analysis content in the model analysis messages of other sessions is truncated according to the preset length of the analysis content to obtain the truncated analysis content. Based on the retained analysis content and the truncated analysis content, a third compressed message corresponding to the second compressed message is determined.

[0012] In some embodiments of this application, if the intelligent agent compresses the second compressed message and the second compressed message is still greater than or equal to the compression threshold, then the model output message compression algorithm is used to compress the model analysis message in the second compressed message to obtain a third compressed message. If the third compressed message is less than the compression threshold, then the third compressed message is determined as the target compressed message.

[0013] Optionally, the step of using the intermediate elimination algorithm to compress the session information of the third compressed message to obtain a fourth compressed message corresponding to the message to be compressed includes: If the third compressed message is greater than or equal to the compression threshold, the message corresponding to the intermediate session in the third compressed message is deleted to obtain the fourth compressed message corresponding to the third compressed message.

[0014] In some embodiments of this application, if the intelligent agent compresses the message to be compressed in multiple layers and the resulting compressed message is still greater than or equal to the compression threshold, then an intermediate elimination algorithm is used to compress the third compressed message to obtain the target compressed message.

[0015] Secondly, some embodiments of this application provide a message compression apparatus, including: The acquisition module is used to acquire messages to be compressed, wherein the messages to be compressed are determined based on initial information generated by the agent through conversational interactions with the large model and the execution tool, and the messages to be compressed include messages of different message types, including user information, agent analysis messages, model analysis messages and tool execution messages; The compression module is used to compress messages of different message types in the message to be compressed according to the priority order of each compression algorithm in the multi-layer compression strategy, to obtain the target compressed message corresponding to the message to be compressed; wherein, the multi-layer compression strategy includes a tool output compression algorithm, a user message compression algorithm, a model output message compression algorithm, and an intermediate elimination algorithm, wherein the tool output compression algorithm is used to compress the tool execution information, the user message compression algorithm is used to compress the user information, the model output message compression algorithm is used to compress the agent analysis message, and the intermediate elimination algorithm is used to compress the sessions of the agent, the large model, and the execution tool.

[0016] Some embodiments of this application obtain messages of different message types from the message to be compressed, employ a multi-layer compression strategy to determine different compression algorithms according to different message types, compress messages of different message types according to different compression algorithms, and set different compression algorithms according to priority. That is, different compression algorithms are used to compress different types of information in the message to be compressed according to priority, and finally obtain the target compressed message corresponding to the message to be compressed, thereby improving the accuracy of message compression under the intelligent agent framework.

[0017] Optionally, the user information is a session request received from a client; The agent analysis information consists of prompts and a list of preset tools output by the agent that correspond to the session request. The model analysis message is the analysis content and target tool list obtained by the large model analyzing the prompt words and the preset tool list; The tool execution message is the execution result output by the tool corresponding to the business operation in the target tool list.

[0018] Some embodiments of this application obtain messages from each stage of the interaction between the client terminal and the intelligent agent, large model and tools, and combine the messages from all stages. If the combined message is greater than or equal to the compression threshold, then the message to be compressed is obtained.

[0019] Optionally, the compression module is used for: The tool output compression algorithm is used to compress the tool execution message in the message to be compressed to obtain the first compressed message; The user message compression algorithm is used to compress the user information in the first compressed message to obtain the second compressed message; The model output message compression algorithm is used to compress the model analysis message in the second compressed message to obtain the third compressed message; The intermediate elimination algorithm is used to compress the session information of the third compressed message to obtain a fourth compressed message corresponding to the message to be compressed. The first compressed message, the second compressed message, the third compressed message, or the fourth compressed message are identified as the target compressed message.

[0020] Some embodiments of this application employ a multi-layer compression strategy to determine different compression algorithms according to different message types. Based on different compression algorithms, messages of different message types are compressed, and different compression algorithms are set according to priority. That is, different compression algorithms are used to compress different types of information in the message to be compressed according to priority, and finally the target compressed message corresponding to the message to be compressed is obtained, thereby improving the accuracy of message compression under the intelligent agent framework.

[0021] Optionally, the compression module is used for: After multiple rounds of conversations between the agent, the large model, and the tool, the tool execution message of the preset tool in the most recent first preset number of conversations in the message to be compressed is retained, and the tool execution messages of the preset tools in other conversations are deleted to obtain the first compressed message corresponding to the message to be compressed. Some embodiments of this application set a tool compression algorithm to compress the execution messages of preset tools in the compression algorithm. That is, while keeping other messages unchanged, the tool execution messages of preset tools in the most recent first preset number of sessions in the message to be compressed are retained, and the tool execution messages of preset tools in other sessions are deleted to obtain a first compressed message corresponding to the message to be compressed. That is, the message to be compressed is initially compressed. If the first compressed message is less than the compression threshold, the first compressed message is determined as the target compressed message.

[0022] Optionally, the compression module is used for: If the first compressed message is greater than or equal to the compression threshold, the user messages in the most recent second preset number of sessions in the first compressed message are retained, and the user messages in other sessions are truncated according to the preset length of the user information to obtain the truncated user information. Based on the retained user message and the intercepted user information, a second compressed message corresponding to the first compressed message is determined. In some embodiments of this application, the first compressed message is judged. If it is still greater than or equal to the compression threshold, the user message in the first compressed message is compressed using a user message compression algorithm to obtain a second compressed message. If the second compression algorithm is greater than or equal to the compression threshold, the second compression algorithm is determined as the target compressed message.

[0023] Optionally, the compression module is used for: If the second compressed message is greater than or equal to the compression threshold, the analysis content in the model analysis message of the most recent third preset number of sessions in the second compressed message is retained, and the analysis content in the model analysis messages of other sessions is truncated according to the preset length of the analysis content to obtain the truncated analysis content. Based on the retained analysis content and the truncated analysis content, a third compressed message corresponding to the second compressed message is determined.

[0024] In some embodiments of this application, if the intelligent agent compresses the second compressed message and the second compressed message is still greater than or equal to the compression threshold, then the model output message compression algorithm is used to compress the model analysis message in the second compressed message to obtain a third compressed message. If the third compressed message is less than the compression threshold, then the third compressed message is determined as the target compressed message.

[0025] Optionally, the compression module is used for: If the third compressed message is greater than or equal to the compression threshold, the message corresponding to the intermediate session in the third compressed message is deleted to obtain the fourth compressed message corresponding to the third compressed message.

[0026] In some embodiments of this application, if the intelligent agent compresses the message to be compressed in multiple layers and the resulting compressed message is still greater than or equal to the compression threshold, then an intermediate elimination algorithm is used to compress the third compressed message to obtain the fourth compressed message.

[0027] Thirdly, some embodiments of this application provide an electronic device including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor, when executing the program, can implement the message compression method as described in any embodiment of the first aspect.

[0028] Fourthly, some embodiments of this application provide a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, can implement the message compression method as described in any embodiment of the first aspect.

[0029] Fifthly, some embodiments of this application provide a computer program product, the computer program product including a computer program, wherein when the computer program is executed by a processor, it can implement the message compression method as described in any embodiment of the first aspect. Attached Figure Description

[0030] To more clearly illustrate the technical solutions of some embodiments of this application, the accompanying drawings used in some embodiments of this application will be briefly described below. It should be understood that the following drawings only show some embodiments of this application and should not be regarded as a limitation of the scope. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.

[0031] Figure 1 A flowchart illustrating a message compression method provided in an embodiment of this application; Figure 2 A flowchart illustrating yet another message compression method provided in this application embodiment; Figure 3 This is a schematic diagram of the structure of a message compression device provided in an embodiment of this application; Figure 4 This is a schematic diagram of an electronic device provided in an embodiment of this application. Detailed Implementation

[0032] The technical solutions of some embodiments of this application will now be described with reference to the accompanying drawings.

[0033] It should be noted that similar reference numerals and letters in the following figures indicate similar items; therefore, once an item is defined in one figure, it does not need to be further defined and explained in subsequent figures. Furthermore, in the description of this application, terms such as "first," "second," etc., are used only to distinguish descriptions and should not be construed as indicating or implying relative importance.

[0034] With the rapid development of artificial intelligence, user terminals interact with large models through intelligent agents, requiring multiple sessions to achieve certain business functions. During these sessions, numerous messages are generated, and this number increases with the number of sessions, leading to a lot of repetitive content during analysis. Currently, a simple truncation scheme is used, directly discarding old session information from messages. This disrupts the pairing relationship between tool calls and execution results, resulting in low accuracy in session analysis. Therefore, some embodiments of this application provide a message compression method. This method includes acquiring messages to be compressed, wherein the messages to be compressed are determined based on initial information generated from session interactions between the intelligent agent and the large model and execution tools. The messages to be compressed include messages of different types, including user information, intelligent agent analysis messages, model analysis messages, and tool execution messages. The method further involves compressing the different message types in the messages to be compressed according to the priority order of various compression algorithms in a multi-layer compression strategy. The message is compressed to obtain a target compressed message corresponding to the message to be compressed. The multi-layer compression strategy includes a tool output compression algorithm, a user message compression algorithm, a model output message compression algorithm, and an intermediate elimination algorithm. The tool output compression algorithm is used to compress tool execution information, the user message compression algorithm is used to compress user information, the model output message compression algorithm is used to compress agent analysis messages, and the intermediate elimination algorithm is used to compress the sessions of the agent, the large model, and the execution tool. In this embodiment, messages of different message types are obtained from the message to be compressed. A multi-layer compression strategy is used to determine different compression algorithms according to different message types. Messages of different message types are compressed according to different compression algorithms, and these algorithms are set according to priority. That is, different compression algorithms are used to compress different types of information in the message to be compressed according to priority, ultimately obtaining the target compressed message corresponding to the message to be compressed, thus improving the accuracy of message compression under the agent framework.

[0035] like Figure 1 As shown, an embodiment of this application provides a message compression method, the method comprising: S101. Obtain the message to be compressed, wherein the message to be compressed is determined based on the initial information generated by the agent through conversational interaction with the large model and the execution tool, and the message to be compressed includes messages of different message types, including user information, agent analysis messages, model analysis messages and tool execution messages. Specifically, in this embodiment, an intelligent agent is installed on the server, and the intelligent agent interacts with the large model and the execution tools respectively. The intelligent agent receives a session request sent by the client terminal, analyzes the session request, and sends the analysis result to the large model. The large model analyzes the analysis result and returns the model output result and the tool list to the intelligent agent. The intelligent agent controls each execution tool to perform the corresponding business operation according to the tool list. In this process, messages from different processes are obtained, including user information, intelligent agent analysis messages, model analysis messages, and tool execution messages. These messages are of different message types. The server judges the messages of different message types. If these messages (initial messages) are greater than or equal to the compression threshold, these initial messages are taken as messages to be compressed.

[0036] S102. According to the priority order of each compression algorithm in the multi-layer compression strategy, the messages of different message types in the message to be compressed are compressed to obtain the target compressed message corresponding to the message to be compressed; wherein, the multi-layer compression strategy includes a tool output compression algorithm, a user message compression algorithm, a model output message compression algorithm, and an intermediate elimination algorithm, the tool output compression algorithm is used to compress the tool execution information, the user message compression algorithm is used to compress the user information, the model output message compression algorithm is used to compress the agent analysis message, and the intermediate elimination algorithm is used to compress the session of the agent, the large model, and the execution tool; Specifically, the server is configured with a multi-layer compression strategy, which includes a tool output compression algorithm, a user message compression algorithm, a model output message compression algorithm, and an intermediate elimination algorithm. The priority order of these algorithms is set according to different needs. For example, the priority order can be the tool output compression algorithm, the user message compression algorithm, the model output message compression algorithm, and the intermediate elimination algorithm, or the user message compression algorithm, the model output message compression algorithm, the tool output compression algorithm, and the intermediate elimination algorithm, or the intermediate elimination algorithm, the tool output compression algorithm, the user message compression algorithm, and the model output message compression algorithm. The specific compression order is not specifically limited in this embodiment.

[0037] The server employs a multi-layered compression strategy with a priority order. Based on different message types, different compression algorithms are used to compress different message types in the message to be compressed in layers to obtain the target compressed message corresponding to the message to be compressed. Then, the target compressed message is saved to the database to avoid redundant calculations.

[0038] Some embodiments of this application obtain messages of different message types from the message to be compressed, employ a multi-layer compression strategy to determine different compression algorithms according to different message types, compress messages of different message types according to different compression algorithms, and set different compression algorithms according to priority. That is, different compression algorithms are used to compress different types of information in the message to be compressed according to priority, and finally obtain the target compressed message corresponding to the message to be compressed, thereby improving the accuracy of message compression under the intelligent agent framework.

[0039] Another embodiment of this application further supplements the message compression method provided in the above embodiments.

[0040] Optionally, the method further includes: Get the initial message; Based on the initial message and the model type of the large model, determine the word segmentation unit value corresponding to the initial message; If the value of the word segmentation unit is greater than or equal to the compression threshold, then the initial message is determined as the message to be compressed.

[0041] Specifically, an agent is installed on the server, and the agent interacts with the large model and tools respectively. The agent receives session requests sent by the client terminal, analyzes the session requests, and sends the analysis results to the large model. The large model analyzes the analysis results and returns the model output results and tool list to the agent. The agent controls each tool to perform corresponding operations according to the tool list. In this process, messages in different processes are treated as different message types, and the server uses messages of different message types as initial information.

[0042] Different types of large models correspond to different token values. Based on the correspondence between the initial information and the token number of the large model, the token value corresponding to the initial information is obtained. The token value is then judged. If the token value is greater than the compression threshold, it means that the initial message corresponding to the token value is a message to be compressed. The compression threshold is a pre-set value.

[0043] Some embodiments of this application obtain initial information from conversations between the agent and the large model and the tool, and determine the word segmentation unit value and compression threshold of the initial information. If the value is greater than or equal to the compression threshold, the initial information is determined as a message to be compressed.

[0044] Optionally, the user information is a session request received from a client; The agent analysis information consists of prompts and a list of preset tools output by the agent that correspond to the session request. The model analysis message is the analysis content and target tool list obtained by the large model analyzing the prompt words and the preset tool list; The tool execution message is the execution result output by the tool corresponding to the business operation in the target tool list.

[0045] Specifically, in this embodiment of the application, the received session request sent by the client terminal is identified as user information; The session request, prompts, and tool list are sent to the large model to obtain agent analysis information; The analysis results and tool list returned by the large model are identified as model analysis messages, wherein the model analysis messages are obtained by the large model from analyzing the session request; Control the tools corresponding to the tool list to perform corresponding operations, obtain tool execution results, receive the tool execution results returned by each tool, and obtain tool execution messages; Based on user information, agent analysis messages, model analysis messages, and tool execution messages, the session context information is determined, thus completing a session.

[0046] Based on the conversation context information, the initial message is obtained through multiple interactions between the agent, the large model, and the tool. By judging the initial message, the message to be compressed is obtained. That is to say, the message to be compressed can be obtained after one conversation or after multiple conversations. If the token value of the message to be compressed is greater than the compression threshold, it needs to be compressed.

[0047] Some embodiments of this application obtain messages from each stage of the interaction between the client terminal and the intelligent agent, large model and tools, and combine the messages from all stages. If the combined message is greater than or equal to the compression threshold, then the message to be compressed is obtained.

[0048] Since different types of messages have different information values ​​and compression characteristics, a single compression strategy cannot balance efficiency and effectiveness. The Tiered Progressive Compression strategy provided in this application embodiment can perform multi-level progressive compression on the messages to be compressed. Since the output of each tool is usually the largest, the compression efficiency is highest when it is prioritized. Therefore, in this application embodiment, the compression algorithm with the highest priority is used for compression, and the most recent messages are kept intact to ensure task continuity. The hysteresis mechanism prevents repeated compression near the threshold.

[0049] Optionally, the step of compressing messages of different message types in the message to be compressed according to the priority order of the compression algorithms in the multi-layer compression strategy to obtain the target compressed message corresponding to the message to be compressed includes: The tool output compression algorithm is used to compress the tool execution message in the message to be compressed to obtain the first compressed message; The user message compression algorithm is used to compress the user information in the first compressed message to obtain the second compressed message; The model output message compression algorithm is used to compress the model analysis message in the second compressed message to obtain the third compressed message; The intermediate elimination algorithm is used to compress the session information of the third compressed message to obtain a fourth compressed message corresponding to the message to be compressed. The first compressed message, the second compressed message, the third compressed message, or the fourth compressed message are identified as the target compressed message.

[0050] In this embodiment of the application, the tool output compression algorithm is first used to compress the tool execution message in the message to be compressed to obtain a first compressed message. If the first compressed message is less than the compression threshold, the first compressed message is used as the target compressed message. If the first compressed message is greater than or equal to the compression threshold, then the first compressed message needs to be compressed a second time, that is, the user message compression algorithm is used to compress the user information in the first compressed message to obtain the second compressed message. If the second compressed message is less than the compression threshold, then the second compressed message is used as the target compressed message. If the second compressed message is greater than or equal to the compression threshold, then the second compressed message needs to be compressed a third time, that is, the model output message compression algorithm is used to compress the model analysis message in the second compressed message to obtain the third compressed message. If the third compressed message is less than the compression threshold, then the third compressed message is used as the target compressed message. If the third compressed message is greater than or equal to the compression threshold, then the third compressed message needs to be compressed a fourth time. The intermediate elimination algorithm is used to compress the session information of the third compressed message to obtain the fourth compressed message corresponding to the message to be compressed. If the fourth compressed message is less than the compression threshold, then the fourth compressed message is used as the target compressed message.

[0051] If the fourth compressed message is greater than or equal to the compression threshold, other compression algorithms can be used for further compression until the requirements are met.

[0052] Some embodiments of this application employ a multi-layer compression strategy to determine different compression algorithms according to different message types. Based on different compression algorithms, messages of different message types are compressed, and different compression algorithms are set according to priority. That is, different compression algorithms are used to compress different types of information in the message to be compressed according to priority, and finally the target compressed message corresponding to the message to be compressed is obtained, thereby improving the accuracy of message compression under the intelligent agent framework.

[0053] Optionally, the step of using the tool output compression algorithm to compress the tool execution message in the message to be compressed to obtain a first compressed message includes: After multiple rounds of conversations between the agent, the large model, and the tool, the tool execution message of the preset tool in the most recent first preset number of conversations in the message to be compressed is retained, and the tool execution messages of the preset tools in other conversations are deleted to obtain the first compressed message corresponding to the message to be compressed. Specifically, the Tool Output Compression algorithm set on the server, after obtaining the message to be compressed, retains the user information, agent analysis message, and model analysis message unchanged, and only compresses the tool execution message. It retains the tool execution message of the preset tool in the most recent first preset number of sessions. For example, if the complete content of the most recent N tool outputs is retained, the tool execution message of the most recent N sessions is retained. For example, N=5, and the tool execution message of the previous N-1 sessions is deleted. N is a natural number greater than 1.

[0054] Some embodiments of this application set a tool compression algorithm to compress the execution messages of preset tools in the compression algorithm. That is, while keeping other messages unchanged, the tool execution messages of preset tools in the most recent first preset number of sessions in the message to be compressed are retained, and the tool execution messages of preset tools in other sessions are deleted to obtain a first compressed message corresponding to the message to be compressed. That is, the message to be compressed is initially compressed. If the first compressed message is less than the compression threshold, the first compressed message is determined as the target compressed message.

[0055] Optionally, the step of using the user message compression algorithm to compress the user information in the first compressed message to obtain a second compressed message includes: If the first compressed message is greater than or equal to the compression threshold, the user messages in the most recent second preset number of sessions in the first compressed message are retained, and the user messages in other sessions are truncated according to the preset length of the user information to obtain the truncated user information. Based on the retained user message and the intercepted user information, a second compressed message corresponding to the first compressed message is determined. Specifically, after the server compresses the message to be compressed using the tool's output compression algorithm, it obtains the first compressed message. Then, it judges the first compressed message to determine whether further compression is needed.

[0056] If the value of the word segmentation unit corresponding to the first compressed message is greater than or equal to the compression threshold, then the User Message Compression algorithm is adopted. In this compression process, the tool execution message has been compressed, the agent analysis message and the model analysis message are kept unchanged, and only the user message is compressed. That is, the user message in the most recent second preset number of sessions in the first compressed message is retained, and the user message in other sessions is truncated according to the preset length of the user information to obtain the truncated user information. For example, the complete content of the user message in the most recent M sessions is retained, and the user message in the first M-1 sessions is truncated to the preset length of the user information to obtain the second compressed message, where M is a natural number greater than 1, for example, M=10.

[0057] In some embodiments of this application, the first compressed message is judged. If it is still greater than or equal to the compression threshold, the user message in the first compressed message is compressed using a user message compression algorithm to obtain a second compressed message. If the second compression algorithm is greater than or equal to the compression threshold, the second compression algorithm is determined as the target compressed message.

[0058] Optionally, the step of using the model output message compression algorithm to compress the model analysis message in the second compressed message to obtain a third compressed message includes: If the second compressed message is greater than or equal to the compression threshold, the analysis content in the model analysis message of the most recent third preset number of sessions in the second compressed message is retained, and the analysis content in the model analysis messages of other sessions is truncated according to the preset length of the analysis content to obtain the truncated analysis content. Based on the retained analysis content and the truncated analysis content, a third compressed message corresponding to the second compressed message is determined.

[0059] Specifically, the server first compresses the tool execution information in the message to be compressed. If the requirements are not met, it needs to be compressed again, that is, the user information is compressed. If the compression requirements are still not met after the compression is completed, it needs to be compressed again, that is, the model output message compression algorithm is used to compress the model analysis message. In this way, the analysis content in the model analysis message of the most recent third preset number of sessions in the second compressed message is retained, and the analysis content in the model analysis message of other sessions is truncated to the preset length of the analysis content. For example, the server retains the model analysis message of the most recent K sessions, truncates the analysis content in the model analysis message of the first K-1 sessions to the preset length of the analysis content, and retains the tool list.

[0060] In some embodiments of this application, if the intelligent agent compresses the second compressed message and the second compressed message is still greater than or equal to the compression threshold, then the model output message compression algorithm is used to compress the model analysis message in the second compressed message to obtain a third compressed message. If the third compressed message is less than the compression threshold, then the third compressed message is determined as the target compressed message.

[0061] Optionally, the step of using the intermediate elimination algorithm to compress the session information of the third compressed message to obtain a fourth compressed message corresponding to the message to be compressed includes: If the third compressed message is greater than or equal to the compression threshold, the message corresponding to the intermediate session in the third compressed message is deleted to obtain the fourth compressed message corresponding to the third compressed message.

[0062] Specifically, after the server compresses the message to be compressed, if the third compressed message is still greater than or equal to the compression threshold, the intermediate elimination algorithm is used to compress the third compressed message, that is, the head and tail context is retained, the intermediate message group is removed, and the removed message is saved as a placeholder in the database.

[0063] Since the beginning and end of a conversation usually contain the most important context (task definition, latest status), the conversational interactions in the middle are relatively unimportant. Therefore, by deleting one or more conversations in the middle, the task definition and initial context, the latest execution status and results can be preserved, and repetitive interactions in the middle can be safely removed.

[0064] In some embodiments of this application, if the intelligent agent compresses the message to be compressed in multiple layers and the resulting compressed message is still greater than or equal to the compression threshold, then an intermediate elimination algorithm is used to compress the third compressed message to obtain the target compressed message.

[0065] like Figure 2 As shown in the figure, this application provides a message compression method, including: Step 1: The server receives the session request sent by the client terminal as user information, and interacts with the intelligent agent and the large model, and executes it through the control tool; Step 2: The server accumulates the messages from each session to obtain initial information; Step 3: Calculate the Token value based on the initial information.

[0066] Step 4: Determine the Token value (Token-count) and compression threshold (threshold). If the Token-count is greater than or equal to the threshold, then compress the message to be compressed.

[0067] Step 5, First layer: Use the tool's output compression algorithm to compress the message to be compressed, and obtain the first compressed message; Step 6, Second layer: If the first compressed message is greater than or equal to the preset threshold, the first compressed message is compressed using the user message compression algorithm to obtain the second compressed message; Step 7, Third Layer: If the second compressed message is greater than or equal to the preset threshold, the model output message compression algorithm is used to compress the second compressed message to obtain the third compressed message; Step 8: Determine whether the compressed message (i.e., the third compressed message) has reached the compression threshold; Step 9, Fourth Layer: If the third compressed message is larger than the compression threshold, the intermediate elimination algorithm is used to compress the third compressed message again.

[0068] Step 10: After compression is complete, the server performs bidirectional pairing verification and repair on the compression result; Because message compression may accidentally disrupt the pairing relationships of tool calls, the server performs a two-way verification of the target tool list and tool execution messages. First, perform positive validation on the target tool list and tool execution messages. All target tool lists must have corresponding tool execution results. Traverse the target tool list returned by the large model, obtain the first tool identifier ID of each tool in the target tool list, and then obtain the second tool identifier ID of the returned tool execution result. Then determine whether the first tool identifier matches the second tool identifier. If they all match, the validation is successful. If they do not match, search for other tool identifiers in the first tool identifier that do not match the second tool identifier, that is, tool identifiers that have not returned tool execution results.

[0069] Second, perform reverse verification on the target tool list and tool execution messages. All tool execution results must have a corresponding tool. Iterate through the third tool identifier of the tool in all tool execution results and check whether the third tool identifier exists in the target tool list. If it is not found, it means that there is an executed tool, but the tool does not exist in the identifier of the target tool list, which means that the verification has failed.

[0070] Regardless of whether it's forward or reverse verification, if both match, the compression result passes verification. If it fails verification, an automatic repair strategy is adopted, which involves deleting the execution results of tools that cannot be found. If the tool identifier corresponding to the execution result is not found in the target tool list, and if there is no analysis content in the model analysis message returned by the large model, then the model analysis message is deleted. If there is analysis content in the model analysis message returned by the large model, then the analysis content in the model analysis message is retained, and the target attack list is deleted.

[0071] Step 11: Save the compression results to the database; Step 12: Output the compressed message.

[0072] It should be noted that each of the implementable methods in this embodiment can be implemented individually or in any combination without conflict. This application does not limit this.

[0073] Another embodiment of this application provides a message compression apparatus for performing the message compression method provided in the above embodiments.

[0074] like Figure 3 The diagram shown is a structural schematic of a message compression device provided in an embodiment of this application. The message compression device includes an acquisition module 301 and a compression module 302, wherein: The acquisition module 301 is used to acquire messages to be compressed, wherein the messages to be compressed are determined based on the initial information generated by the agent through conversational interactions with the large model and the execution tool, and the messages to be compressed include messages of different message types, including user information, agent analysis messages, model analysis messages and tool execution messages; Compression module 302 is used to compress messages of different message types in the message to be compressed according to the priority order of each compression algorithm in the multi-layer compression strategy, to obtain a target compressed message corresponding to the message to be compressed; wherein, the multi-layer compression strategy includes a tool output compression algorithm, a user message compression algorithm, a model output message compression algorithm, and an intermediate elimination algorithm, wherein the tool output compression algorithm is used to compress the tool execution information, the user message compression algorithm is used to compress the user information, the model output message compression algorithm is used to compress the agent analysis message, and the intermediate elimination algorithm is used to compress the session of the agent, the large model, and the execution tool.

[0075] Regarding the apparatus in this embodiment, the specific manner in which each module performs its operations has been described in detail in the embodiments related to the method, and will not be elaborated upon here.

[0076] Some embodiments of this application obtain messages of different message types from the message to be compressed, employ a multi-layer compression strategy to determine different compression algorithms according to different message types, compress messages of different message types according to different compression algorithms, and set different compression algorithms according to priority. That is, different compression algorithms are used to compress different types of information in the message to be compressed according to priority, and finally obtain the target compressed message corresponding to the message to be compressed, thereby improving the accuracy of message compression under the intelligent agent framework.

[0077] Another embodiment of this application further supplements the description of the message compression device provided in the above embodiments.

[0078] Optionally, the user information is a session request received from a client; The agent analysis information consists of prompts and a list of preset tools output by the agent that correspond to the session request. The model analysis message is the analysis content and target tool list obtained by the large model analyzing the prompt words and the preset tool list; The tool execution message is the execution result output by the tool corresponding to the business operation in the target tool list.

[0079] Some embodiments of this application obtain messages from each stage of the interaction between the client terminal and the intelligent agent, large model and tools, and combine the messages from all stages. If the combined message is greater than or equal to the compression threshold, then the message to be compressed is obtained.

[0080] Optionally, the compression module is used for: The tool output compression algorithm is used to compress the tool execution message in the message to be compressed to obtain the first compressed message; The user message compression algorithm is used to compress the user information in the first compressed message to obtain the second compressed message; The model output message compression algorithm is used to compress the model analysis message in the second compressed message to obtain the third compressed message; The intermediate elimination algorithm is used to compress the session information of the third compressed message to obtain a fourth compressed message corresponding to the message to be compressed. The first compressed message, the second compressed message, the third compressed message, or the fourth compressed message are identified as the target compressed message.

[0081] Some embodiments of this application employ a multi-layer compression strategy to determine different compression algorithms according to different message types. Based on different compression algorithms, messages of different message types are compressed, and different compression algorithms are set according to priority. That is, different compression algorithms are used to compress different types of information in the message to be compressed according to priority, and finally the target compressed message corresponding to the message to be compressed is obtained, thereby improving the accuracy of message compression under the intelligent agent framework.

[0082] Optionally, the compression module is used for: After multiple rounds of conversations between the agent, the large model, and the tool, the tool execution message of the preset tool in the most recent first preset number of conversations in the message to be compressed is retained, and the tool execution messages of the preset tools in other conversations are deleted to obtain the first compressed message corresponding to the message to be compressed. Some embodiments of this application set a tool compression algorithm to compress the execution messages of preset tools in the compression algorithm. That is, while keeping other messages unchanged, the tool execution messages of preset tools in the most recent first preset number of sessions in the message to be compressed are retained, and the tool execution messages of preset tools in other sessions are deleted to obtain a first compressed message corresponding to the message to be compressed. That is, the message to be compressed is initially compressed. If the first compressed message is less than the compression threshold, the first compressed message is determined as the target compressed message.

[0083] Optionally, the compression module is used for: If the first compressed message is greater than or equal to the compression threshold, the user messages in the most recent second preset number of sessions in the first compressed message are retained, and the user messages in other sessions are truncated according to the preset length of the user information to obtain the truncated user information. Based on the retained user message and the intercepted user information, a second compressed message corresponding to the first compressed message is determined. In some embodiments of this application, the first compressed message is judged. If it is still greater than or equal to the compression threshold, the user message in the first compressed message is compressed using a user message compression algorithm to obtain a second compressed message. If the second compression algorithm is greater than or equal to the compression threshold, the second compression algorithm is determined as the target compressed message.

[0084] Optionally, the compression module is used for: If the second compressed message is greater than or equal to the compression threshold, the analysis content in the model analysis message of the most recent third preset number of sessions in the second compressed message is retained, and the analysis content in the model analysis messages of other sessions is truncated according to the preset length of the analysis content to obtain the truncated analysis content. Based on the retained analysis content and the truncated analysis content, a third compressed message corresponding to the second compressed message is determined.

[0085] In some embodiments of this application, if the intelligent agent compresses the second compressed message and the second compressed message is still greater than or equal to the compression threshold, then the model output message compression algorithm is used to compress the model analysis message in the second compressed message to obtain a third compressed message. If the third compressed message is less than the compression threshold, then the third compressed message is determined as the target compressed message.

[0086] Optionally, the compression module is used for: If the third compressed message is greater than or equal to the compression threshold, the message corresponding to the intermediate session in the third compressed message is deleted to obtain the fourth compressed message corresponding to the third compressed message.

[0087] In some embodiments of this application, if the intelligent agent compresses the message to be compressed in multiple layers and the resulting compressed message is still greater than or equal to the compression threshold, then an intermediate elimination algorithm is used to compress the third compressed message to obtain the fourth compressed message.

[0088] Some embodiments of this application obtain initial information from conversations between the agent and the large model and the tool, and determine the word segmentation unit value and compression threshold of the initial information. If the value is greater than or equal to the compression threshold, the initial information is determined as a message to be compressed.

[0089] Regarding the apparatus in this embodiment, the specific manner in which each module performs its operations has been described in detail in the embodiments related to the method, and will not be elaborated upon here.

[0090] It should be noted that each of the implementable methods in this embodiment can be implemented individually or in any combination without conflict. This application does not limit this.

[0091] This application also provides a computer-readable storage medium storing a computer program thereon, which, when executed by a processor, can perform the operation of any of the methods corresponding to the message compression methods provided in the above embodiments.

[0092] This application also provides a computer program product, which includes a computer program, wherein when the computer program is executed by a processor, it can implement the operation of any of the methods corresponding to the message compression methods provided in the above embodiments.

[0093] like Figure 4 As shown, some embodiments of this application provide an electronic device 400, which includes a memory 410, a processor 420, and a computer program stored in the memory 410 and executable on the processor 420. When the processor 420 reads the program from the memory 410 via a bus 430 and executes the program, it can implement any of the methods included in the above-described message compression method.

[0094] Processor 420 can process digital signals and may include various computing architectures. For example, it may be a complex instruction set computer architecture, a reduced instruction set computer architecture, or an architecture that implements multiple instruction set combinations. In some examples, processor 420 may be a microprocessor.

[0095] Memory 410 can be used to store instructions executed by processor 420 or data related to the execution of instructions. These instructions and / or data may include code for implementing some or all of the functions of one or more modules described in the embodiments of this application. The processor 420 of this disclosure embodiment can be used to execute instructions in memory 410 to implement the methods shown above. Memory 410 includes dynamic random access memory, static random access memory, flash memory, optical memory, or other memories well known to those skilled in the art.

[0096] The above are merely embodiments of this application and are not intended to limit the scope of protection of this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the scope of protection of this application. It should be noted that similar reference numerals and letters in the following figures indicate similar items; therefore, once an item is defined in one figure, it does not need to be further defined and explained in subsequent figures.

[0097] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.

[0098] It should be noted that, in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.

Claims

1. A message compression method, characterized in that, The method includes: Obtain messages to be compressed, wherein the messages to be compressed are determined based on initial information generated by the agent through conversational interactions with the large model and the execution tool, and the messages to be compressed include messages of different message types, including user information, agent analysis messages, model analysis messages and tool execution messages; According to the priority order of the compression algorithms in the multi-layer compression strategy, messages of different message types in the message to be compressed are compressed to obtain the target compressed message corresponding to the message to be compressed; wherein, the multi-layer compression strategy includes a tool output compression algorithm, a user message compression algorithm, a model output message compression algorithm, and an intermediate elimination algorithm. The tool output compression algorithm is used to compress the tool execution information, the user message compression algorithm is used to compress the user information, the model output message compression algorithm is used to compress the agent analysis message, and the intermediate elimination algorithm is used to compress the sessions of the agent, the large model, and the execution tool.

2. The message compression method according to claim 1, characterized in that, The user information is the session request received from the client; The agent analysis information consists of prompts and a list of preset tools output by the agent that correspond to the session request. The model analysis message is the analysis content and target tool list obtained by the large model analyzing the prompt words and the preset tool list; The tool execution message is the execution result output by the tool corresponding to the business operation in the target tool list.

3. The message compression method according to claim 1, characterized in that, The step of compressing messages of different message types in the message to be compressed according to the priority order of the compression algorithms in the multi-layer compression strategy to obtain the target compressed message corresponding to the message to be compressed includes: The tool output compression algorithm is used to compress the tool execution message in the message to be compressed to obtain the first compressed message; The user message compression algorithm is used to compress the user information in the first compressed message to obtain the second compressed message; The model output message compression algorithm is used to compress the model analysis message in the second compressed message to obtain the third compressed message; The intermediate elimination algorithm is used to compress the session information of the third compressed message to obtain a fourth compressed message corresponding to the message to be compressed. The first compressed message, the second compressed message, the third compressed message, or the fourth compressed message are identified as the target compressed message.

4. The message compression method according to claim 3, characterized in that, The tool output compression algorithm is used to compress the tool execution message in the message to be compressed to obtain a first compressed message, including: After multiple rounds of conversations between the agent, the large model, and the tool, the tool execution message of the preset tool in the most recent first preset number of conversations in the message to be compressed is retained, and the tool execution messages of the preset tools in other conversations are deleted to obtain the first compressed message corresponding to the message to be compressed.

5. The message compression method according to claim 3, characterized in that, The step of using the user message compression algorithm to compress the user information in the first compressed message to obtain a second compressed message includes: If the first compressed message is greater than or equal to the compression threshold, the user messages in the most recent second preset number of sessions in the first compressed message are retained, and the user messages in other sessions are truncated according to the preset length of the user information to obtain the truncated user information. Based on the retained user message and the intercepted user information, a second compressed message corresponding to the first compressed message is determined.

6. The message compression method according to claim 3, characterized in that, The model output message compression algorithm is used to compress the model analysis message in the second compressed message to obtain a third compressed message, including: If the second compressed message is greater than or equal to the compression threshold, the analysis content in the model analysis message of the most recent third preset number of sessions in the second compressed message is retained, and the analysis content in the model analysis messages of other sessions is truncated according to the preset length of the analysis content to obtain the truncated analysis content. Based on the retained analysis content and the truncated analysis content, a third compressed message corresponding to the second compressed message is determined.

7. The message compression method according to claim 3, characterized in that, The step of using the intermediate elimination algorithm to compress the session information of the third compressed message to obtain a fourth compressed message corresponding to the message to be compressed includes: If the third compressed message is greater than or equal to the compression threshold, the message corresponding to the intermediate session in the third compressed message is deleted to obtain the fourth compressed message corresponding to the third compressed message.

8. A message compression device, characterized in that, The device includes: The acquisition module is used to acquire messages to be compressed, wherein the messages to be compressed are determined based on initial information generated by the agent through conversational interactions with the large model and the execution tool, and the messages to be compressed include messages of different message types, including user information, agent analysis messages, model analysis messages and tool execution messages; The compression module is used to compress messages of different message types in the message to be compressed according to the priority order of each compression algorithm in the multi-layer compression strategy, to obtain the target compressed message corresponding to the message to be compressed; wherein, the multi-layer compression strategy includes a tool output compression algorithm, a user message compression algorithm, a model output message compression algorithm, and an intermediate elimination algorithm, wherein the tool output compression algorithm is used to compress the tool execution information, the user message compression algorithm is used to compress the user information, the model output message compression algorithm is used to compress the agent analysis message, and the intermediate elimination algorithm is used to compress the sessions of the agent, the large model, and the execution tool.

9. An electronic device, characterized in that, The device includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor, when executing the program, implements the message compression method according to any one of claims 1-7.

10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program, characterized in that, when the program is executed by a processor, it can implement the message compression method according to any one of claims 1-7.