Message processing method and apparatus, electronic device, and storage medium

CN122985261APending Publication Date: 2026-10-27SHANGHAI XIAODU TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611056958.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-07-15
Publication Date
2026-10-27

AI Technical Summary

Benefits of technology

[0009]采用本公开能够提高消息处理的可靠性。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122985261A_ABST
    Figure CN122985261A_ABST
Patent Text Reader

Abstract

The present disclosure provides a message processing method and device, electronic equipment and storage medium, relates to the technical field of computers, in particular to the technical field of artificial intelligence, large model, natural language processing and the like. The specific implementation scheme comprises: in response to a current user message, writing the current user message into an event stream file of a current session; based on the event stream file, entering a processing flow for the current user message to obtain a current message processing result; the processing flow comprises: based on the event stream file, constructing session reference information; using a main intelligent agent, obtaining a model response result based on the session reference information; in the case that the model response result does not include function scheduling information, taking the model response result as the current message processing result; otherwise, in the execution layer, executing N to-be-executed functions indicated by the function scheduling information to obtain N function execution results corresponding to the N to-be-executed functions one by one. The present disclosure can improve the reliability of message processing.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This disclosure relates to the field of computer technology, particularly to the fields of artificial intelligence, large models, and natural language processing, and can be applied to application areas such as generative search, document editing, virtual humans, intelligent voice assistants, intelligent agent platforms, and development and debugging tools. Specifically, it relates to a message processing method, device, electronic device, and storage medium. Background Technology

[0002] Artificial intelligence agents, also known as "intelligent agents," are intelligent software systems driven by large models. They can interact with users through natural language, understand user intentions, and execute corresponding functions through autonomous decision-making to complete user-specified tasks. Summary of the Invention

[0003] This disclosure provides a message processing method, apparatus, electronic device, and storage medium.

[0004] According to a first aspect of this disclosure, a message processing method is provided, comprising: In response to the received current user message, the current user message is written to the event stream file of the current session; the event stream file is managed by the sourcing layer and persisted in an append-only manner; Based on the event stream file, the system enters the processing flow for the current user's message to obtain the processing result. The processing flow includes: Construct session reference information based on event stream files; The model response results are obtained by utilizing the main intelligent agent and based on the session reference information; If the model response result does not include function scheduling information, the model response result will be used as the current message processing result. Alternatively, if the model response result includes function scheduling information, in the execution layer, the N functions to be executed as indicated by the function scheduling information are executed to obtain N function execution results corresponding one-to-one with the N functions to be executed; where N≥1 and N is an integer; the N function execution results are used to obtain the current message processing result.

[0005] According to a second aspect of this disclosure, a message processing apparatus is provided, comprising: The message receiving unit is used to respond to the received current user message by writing the current user message into the event stream file of the current session; wherein the event stream file is managed by the sourcing layer and is persistently stored in an append-only manner; The message processing unit is used to enter the processing flow for the current user message based on the event stream file, in order to obtain the current message processing result; wherein the processing flow includes: Construct session reference information based on event stream files; The model response results are obtained by utilizing the main intelligent agent and based on the session reference information; If the model response result does not include function scheduling information, the model response result will be used as the current message processing result. Alternatively, if the model response result includes function scheduling information, in the execution layer, the N functions to be executed as indicated by the function scheduling information are executed to obtain N function execution results corresponding one-to-one with the N functions to be executed; where N≥1 and N is an integer; the N function execution results are used to obtain the current message processing result.

[0006] According to a third aspect of this disclosure, an electronic device is provided, comprising: At least one processor; Memory that is communicatively connected to at least one processor; The memory stores instructions that can be executed by at least one processor, which are executed by at least one processor to enable the at least one processor to perform the method provided in the first aspect of this disclosure.

[0007] According to a fourth aspect of this disclosure, a non-transitory computer-readable storage medium is provided storing computer instructions; wherein the computer instructions are used to cause a computer to perform the method provided in the first aspect of this disclosure.

[0008] According to a fifth aspect of this disclosure, a computer program product is provided, including a computer program; wherein, when executed by a processor, the computer program is capable of implementing the method provided in the first aspect of this disclosure.

[0009] Using this disclosure can improve the reliability of message processing.

[0010] It should be understood that the description in this section is not intended to identify key or essential features of the embodiments of this disclosure, nor is it intended to limit the scope of this disclosure. Other features of this disclosure will become readily apparent from the following description. Attached Figure Description

[0011] The accompanying drawings are provided to better understand this solution and do not constitute a limitation of this disclosure. Wherein: Figure 1 A flowchart illustrating a message processing method provided in an embodiment of this disclosure; Figure 2 A schematic diagram illustrating the writing process of valuable memory content provided in an embodiment of this disclosure; Figure 3 A schematic diagram of a key memory content retrieval process provided for an embodiment of this disclosure; Figure 4 An assembly diagram illustrating a system prompt provided in an embodiment of this disclosure; Figure 5 A schematic diagram illustrating the selection priority of a backend protocol provided in an embodiment of this disclosure; Figure 6 This is a schematic diagram of the architecture of a message processing system provided in an embodiment of the present disclosure; Figure 7 This is a complete flowchart illustrating a message processing method provided in an embodiment of the present disclosure; Figure 8 This is a schematic diagram illustrating an application scenario of a message processing method provided in an embodiment of the present disclosure; Figure 9 A schematic structural block diagram of a message processing apparatus provided in an embodiment of this disclosure; Figure 10 This is a schematic structural block diagram of an electronic device provided in an embodiment of the present disclosure. Detailed Implementation

[0012] The exemplary embodiments of this disclosure are described below with reference to the accompanying drawings, including various details of the embodiments to aid understanding, and should be considered merely exemplary. Therefore, those skilled in the art will recognize that various changes and modifications can be made to the embodiments described herein without departing from the scope of this disclosure. Similarly, for clarity and brevity, descriptions of well-known functions and structures are omitted in the following description.

[0013] Currently, the mainstream intelligent agent frameworks include: (1) Chain-based language framework (LangChain) / Chain-based graph framework (LangGraph) Chained language frameworks employ an abstract design of chain scheduling (Chain) / agent (Agent), managing session state through a session buffer memory or session summary memory in the electronic device's memory. Its agent execution cyclically maintains a variable list of messages in memory, and tool scheduling results are directly appended to memory. Chained graph frameworks introduce a graph-based state machine, but the state is still stored in memory as an object (e.g., a Python object), lacking the ability to recover from process crashes.

[0014] (2) Autonomous decision-making engine type intelligent agent Such intelligent agents (e.g., AutoGPT, BabyAGI) use large models as autonomous decision-making engines, executing a "plan-execute-evaluate" process in an infinite loop. They store session history locally in a lightweight data-interchange format (JavaScript Object Notation, JSON) file, but lack event sourcing semantics, failing to support accurate reconstruction of session state after process crash recovery. Furthermore, their function scheduling lacks access control; all functions execute with equal privileges.

[0015] (3) Open AI Assistant Application Programming Interface (API) Open AI assistant APIs host session state on a server (specifically, a Thread object), while function scheduling is driven by instance (Run) objects. However, this approach is a purely managed service, which does not support private deployment and lacks fine-grained access control and function execution isolation.

[0016] (4) Anthropic Claude Tool Use Protocol The protocol defines the message format specifications from large models to tools, but does not specify the isolation boundaries for tool execution, access control mechanisms, or session state persistence strategies.

[0017] (5) Traditional rule-driven chatbots Traditional rule-driven chatbots are built on intent recognition and slot filling technologies. Their conversation flow is entirely determined by preset rules, making them unable to handle user requests outside the preset intent range and having zero generalization ability.

[0018] The inventors discovered the following technical problems with the above-mentioned mainstream intelligent agent frameworks: (1) Session state is fragile Session state is stored in memory and is lost when the process crashes. It is impossible to accurately restore session state after the process restarts, which affects the reliability of message processing.

[0019] (2) The scheduler is stateful The scheduling of functions depends on the internal state of the instance (e.g., the current dialogue round, the function execution result, and historical dialogue information). If the process crashes, it cannot be taken over by other instances, and the entire session must be recreated.

[0020] (3) Full injection of skill documents All skill documents are injected with system prompts all at once. For example, 10 skill documents occupy approximately 6,800 minimal semantic units (Tokens), which severely consumes the context window, resulting in a reduction in the number of available dialogue turns (i.e., the difference between the maximum number of dialogue turns and the current number of dialogue turns) and an increase in API scheduling costs.

[0021] (4) Lack of access control mechanism All functions are executed with equal permissions, which cannot meet the security requirements of special scenarios (such as transaction scenarios).

[0022] (5) Lack of tenant segregation The lack of tenant-level rate limits and resource quotas means that abuse by one tenant could block the global scheduler and affect the use by other tenants.

[0023] (6) Unauthorized execution of tools Skill functions can access host environment variables and credentials, lacking a zero-credential boundary, which poses a risk of information leakage.

[0024] (7) Poor Chinese memory retrieval performance The default tokenizer (e.g., Unicode61) of the fifth-generation Full-Text Search virtual table extension module (Full-Text Search version 5, FTS5) treats consecutive Chinese, Japanese and Korean characters as a single term, which cannot achieve sub-phrase level matching queries, resulting in extremely low key memory recall rate in Chinese scenarios.

[0025] (8) The cache is not optimized. The system prompts change with the current dialogue round, causing the entire API prompt cache to become invalid; each request requires retransmitting the complete system prompt, resulting in high scheduling costs.

[0026] To address at least some of the aforementioned technical issues, this embodiment decouples the agent runtime into three orthogonal layers with single, independently replaceable responsibilities: a tracing layer (Session), a scheduling layer (Harness), and an execution layer (Sandbox). Thus, this embodiment achieves separation of session state management and inference computation through event tracing. The core concept of this design is that the agent runtime will eventually become standardized (e.g., destroyed or rebuilt), and session state is the truly core asset that needs to be held long-term.

[0027] Based on the above settings, this disclosure provides a message processing method that can be executed by a scheduling layer, and the scheduling layer can be applied to an electronic device. The electronic device can be a service device, such as a server (specifically a server cluster), a workbench, a mainframe computer, or other similar computing devices. The following will be combined with... Figure 1 The flowchart shown illustrates a message processing method provided in an embodiment of this disclosure. It should be noted that, in this embodiment, although... Figure 1 The flowchart shown illustrates the logical order; however, in some cases, the steps shown or described in the flowchart may be performed in a different order.

[0028] Step S101: In response to the received current user message, write the current user message to the event stream file of the current session.

[0029] In this context, the current user message can be sent by a user of the main intelligent agent (hereinafter referred to as the current user) through an intelligent agent client installed on the terminal device. Here, the main intelligent agent can be an intelligent software system driven by a first large model, which can be a large language model (LLM), specifically a pre-trained autoregressive generative model (e.g., an autoregressive generative model with a Transformer architecture), possessing general language knowledge, world knowledge, and domain-specific expertise; the terminal device can be a conventional computer (e.g., a desktop computer, laptop, tablet, smartphone, in-vehicle computer, etc.); the intelligent agent client can be, but is not limited to, generative search tools, document editing tools, virtual human clients, intelligent voice assistants, intelligent agent platforms, development and debugging tools, etc.

[0030] In this embodiment of the disclosure, the current user message can be the i-th user message sent by the current user in the current session between the current user and the main intelligent agent; i ≥ 1 and i is an integer. Based on this, it can be understood that in this embodiment of the disclosure, the current session is the ongoing session between the current user and the main intelligent agent, which may include multiple rounds of dialogue, and the value of i is the current dialogue round number.

[0031] In this embodiment, the event stream file can store multiple related event streams of the current session to characterize the session state. The event stream file can be managed by the sourcing layer and persistently stored in an append-only manner, specifically persistently stored on the target storage device. Here, the target storage device can be a storage device independent of the scheduling layer process lifecycle, specifically a physical storage medium, including but not limited to disks, solid-state drives, non-volatile memory chips (e.g., flash memory, magnetoresistive random access memory (MRAM), phase-change memory (PCM), etc.), or a storage service, including but not limited to distributed file systems and cloud storage services.

[0032] Step S102: Based on the event stream file, enter the processing flow for the current user message to obtain the current message processing result.

[0033] The current message processing result is the reply content for the current user's message.

[0034] In this embodiment of the disclosure, the processing flow may include: Step S102-1: Construct session reference information based on the event stream file.

[0035] The session reference information can be used to characterize the current user message, and may also include historical dialogue information (if it exists) that occurred before the current user message was sent.

[0036] Step S102-2: Using the main agent, based on the session reference information, obtain the model response result.

[0037] The model response results may include function scheduling information to indicate N functions to be executed in the execution layer; N≥1 and N is an integer.

[0038] In this embodiment of the disclosure, if the model response result does not include function scheduling information, step S102-3 is executed; if the model response result includes function scheduling information, step S102-4 is executed.

[0039] Step S102-3: Use the model response result as the current message processing result.

[0040] Step S102-4: In the execution layer, execute the N functions to be executed as indicated by the function scheduling information to obtain the N function execution results that correspond one-to-one with the N functions to be executed.

[0041] The results of N function executions can be used to obtain the current message processing result. For example, the results of N function executions can be written to the event stream file of the current session, and the processing flow for the current user message can be re-entered. That is, based on the updated event stream file, the session reference information is reconstructed, and the main agent performs the next round of inference calculation based on the reconstructed session reference information. This process is repeated until the model response result does not include tool scheduling information, and then the model response result is used as the current message processing result.

[0042] The message processing method provided in this disclosure can write the current user message into an event stream file managed by the tracing layer and persistently stored in an append-only manner, and then enter the processing flow for the current user message based on the event stream file. The processing flow includes: constructing session reference information based on the event stream file, and using the main intelligent agent, obtaining the model response result based on the session reference information; if the model response result does not include function scheduling information, the model response result is used as the current message processing result; or, if the model response result includes function scheduling information, in the execution layer, the N functions to be executed as indicated by the function scheduling information are executed to obtain N function execution results corresponding one-to-one with the N functions to be executed, and the N function execution results are written into the event stream file to trigger the next round of processing flow, until the model response result no longer includes tool scheduling information. In other words, in this disclosure embodiment, the event stream file is managed by the tracing layer and persistently stored in an append-only manner, so that the lifecycle of the event stream file is independent of the running state of the scheduling layer process, allowing the scheduling layer to be implemented as a stateless logical scheduling unit. In this way, when a process crashes in the scheduling layer, the event information written to the event stream file will not be lost. The newly started scheduling layer process only needs to reread the event stream file to accurately reconstruct the session state before the scheduling layer process crash without the user's awareness, which significantly improves the reliability of message processing.

[0043] Based on this, the message processing method provided in this embodiment may further include: after a process crash occurs in the scheduling layer, in response to the restart operation of the scheduling layer, reading an event stream file from the target storage device so as to re-execute step S102, that is, based on the event stream file, entering the processing flow for the current user message to obtain the current message processing result.

[0044] Moreover, in this embodiment of the disclosure, the execution layer serves as an execution environment specifically for executing specific functions, which can ensure the mutual isolation between function execution and session state management and inference computation. This not only further improves the reliability of message processing but also ensures the security of message processing.

[0045] Furthermore, it should be noted that in this embodiment, the event stream file managed by the tracing layer can be an append-only JSON Lines (JSONL) format file, corresponding to only one session, i.e., the current session, used to store multiple related event streams of the current session. It should also be noted that in this embodiment, each of the multiple related event streams can include at least one related event (e.g., it can include multiple related events with a time order). For example, a system message event stream can include at least one system message event; a user message event stream can include at least one user message event; and a message digest event stream can include at least one message digest event. For each of the multiple related event streams, the related events included therein can be forcibly written to the target storage device through target system scheduling (Fsync). Based on this, it can be understood that in this embodiment, the session state of the current session is the projection of the related events included in at least some of the multiple related event streams, which is non-mutable state information.

[0046] In one example, multiple related event flows may include system message event flows, user message event flows, model response event flows, function execution event flows, lazy loading unpacking record event flows, message summary event flows, summary failure event flows, user cancellation event flows, user cancellation behavior awareness event flows, waiting for user authorization event flows, user authorization decision event flows, and reaching the maximum loop count event flows. Based on this, the related events involved in multiple related event flows can be shown in Table 1: In this embodiment of the disclosure, the tracing layer involves the following mechanisms: System scheduling guarantee: For each of the multiple related event streams, the related events included therein can be forcibly written to the target storage device using the target system scheduling method (os.fsync()). That is, the data in the operating system buffer is flushed to the target storage device, thereby ensuring zero data loss after the scheduling layer process crashes.

[0047] Projection of relevant events: The `Session.to_messages()` method is executed to construct session reference information based on the event stream file. Specifically, this method iterates through the event stream file, mapping system message events included in the system message event stream to system status information, user message events included in the user message event stream to raw user status information, model response events included in the model response event stream to intelligent assistant information, function execution events included in the function execution event stream to function execution information, and message digest events included in the message digest event stream to synthesized user status information, without maintaining a variable list of messages in the electronic device's memory.

[0048] Multi-tenant layout: Event stream files can adopt a multi-tenant directory layout, and their storage path can be...<log_dir> / tenants / <tenant_id> / <session_id> The .jsonl file contains the tenant_id, which undergoes strict path traversal validation to reject invalid values ​​including " / ", "\", and "..". This prevents path traversal attacks and ensures file isolation between different tenants.

[0049] Based on the above, it can be understood that in this embodiment of the disclosure, when performing step S101, that is, writing the current user message to the event stream file of the current session, a user message event can be generated based on the current user message (that is, the current user message can be encapsulated into a user message event), and the target system scheduling method can be used to append the user message event to the user message event stream stored in the event stream file. In some optional implementations, "writing the current user message to the event stream file of the current session" may include: Identify key memory content related to the current user's message from the current user's long-term memory. Generate a new current user message based on the current user message and key memory content; Based on the new current user message, a user message event is generated to be appended to the user message event stream stored in the event stream file.

[0050] The current user's long-term memory content can be stored in the assembly layer, employing a two-layer write architecture: a human-readable lightweight markup language (Markdown) file (hereinafter referred to as the memory file, denoted as Memory.md) serves as the authoritative source; and an SQLite FTS5 index (memory.index.sqlite) acts as a recall accelerator. The SQLite FTS5 index can be reconstructed from the memory file (e.g., via the rebuild_from_markdown() method).

[0051] Based on this, the message processing method provided in this embodiment may further include, after receiving the current user message: Extract valuable memories from current user messages; The system updates the user's long-term memory content based on valuable memories.

[0052] In other words, in this embodiment of the disclosure, valuable memory content can be extracted from the current user's messages and written into the current user's long-term memory content, thereby updating the current user's long-term memory content (i.e., writing valuable memory content as new memory entries into the memory file). Please refer to... Figure 2 The process of writing valuable memory content can include: Step S201: In response to the memory write command, extract the content unit to be evaluated from the current user message.

[0053] The memory write instruction can be triggered by the scheduling layer when it schedules the memory write tool (AppendUserMemoryTool) in response to the received current user message; the content unit to be evaluated can be a paragraph, sentence, phrase, etc., split from the current user message.

[0054] Step S202: If the category of the content unit to be evaluated belongs to the valuable category, the content unit to be evaluated is regarded as valuable memory content, and after the valuable memory content is processed according to the preset memory format, the long-term memory content of the current user is updated.

[0055] The valuable categories can be user preferences, background, facts, and goals. User preferences can define a user's subjective likes, dislikes, and biases; background can define a user's objective attributes, identity information, and long-term state; facts can represent specific events, experiences, and clearly stated information that a user has had; and goals can represent a user's desired future intentions, plans, and long-term goals.

[0056] The default memory format can be: <Category> (YYYY-MM-DD) <Valuable Memory Content> For example, the valuable memory content is "I like seaside cities," the category is preference, and the date is 2026-07-07. Then, after processing the valuable memory content according to a preset memory format, the new memory entry could be: preference (2026-07-07) Prefer coastal cities Thereafter, the long-term memory content of the current user may be updated based on the new memory entry, that is, the new memory entry is written into the memory file.

[0057] In addition, it should be noted that in the embodiments of the present disclosure, when an old memory entry semantically opposite to the new memory entry is stored in the memory file, the old memory entry may be deleted. Continuing with the above example, when the old memory entry "preference (2026-07-07) Dislike coastal cities" is stored in the memory file, the old memory entry may be deleted.

[0058] In step S203, the index writing interface (MemoryIndex.add_entry()) is scheduled to synchronously insert the valuable memory content into the SQLite FTS5 index.

[0059] In the embodiments of the present disclosure, when performing step S203, a fail-open policy may be adopted, that is, when the insertion into the SQLite FTS5 index fails, only a warning log is recorded, and the writing operation of the memory file is not blocked. In this way, it can be ensured that even when the SQLite FTS5 index is temporarily unavailable, the authoritative data source of the long-term memory content can still be reliably saved.

[0060] In an example, when synchronously inserting the valuable memory content into the SQLite FTS5 index, index-side Chinese, Japanese, Korean (CJK) word segmentation processing may be performed on the valuable memory content: traverse each character in the valuable memory content; when the digital code point (Unicode code point) of the currently traversed target character falls within the preset CJK character range, insert a space before and after the target character respectively, so that each character in the valuable memory content becomes an independent FTS5 term. The preset CJK character range may include, but is not limited to, the CJK Unified Ideographs range (U+4E00-U+9FFF), the CJK Compatibility Ideographs range (U+F900-U+FAFF), and the CJK Punctuation range (U+3000-U+303F). Exemplarily, for the valuable memory content "Prefer coastal cities", after the index-side CJK word segmentation processing, it becomes "Prefer c o a s t a l c i t i e s", with each character becoming an independent FTS5 term.

[0061] Furthermore, it should be noted that in this embodiment, the CJK word segmentation processing at the index end can be implemented by registering a user-defined function (cjk_split), and automatically applied during FTS5 index writes using SQLite triggers (AFTER INSERT, AFTER DELETE, AFTER UPDATE). When a new memory entry is added to the memory file, the SQLite trigger automatically schedules the user-defined function to perform word segmentation processing on the memory content and synchronously updates the FTS5 index; similarly, when an old memory entry needs to be deleted from the memory file, the FTS5 index is also synchronously updated.

[0062] Based on the above valuable memory content writing process, in this embodiment of the disclosure, "determining key memory content related to the current user's message from the current user's long-term memory content; generating a new current user message based on the current user message and the key memory content; generating a user message event based on the new current user message, and appending the user message event to the user message event stream stored in the event stream file" may include: Step S301: In response to the received current user message, a long-term memory retrieval process for the current user message is triggered.

[0063] In this embodiment of the disclosure, the memory recall module (_maybe_augment_with_memory_recall) can be scheduled to trigger a long-term memory retrieval process for the current user's message.

[0064] Step S302: Extract the user ID of the current user from the event stream file of the current session, and create a memory index instance based on the user ID of the current user.

[0065] In this embodiment of the disclosure, the user ID of the current user can be extracted from the system message event stream (including at least one system message event) stored in the event stream file.

[0066] Step S303: Using the memory index instance, the recall function (recall(user_msg, top_n=N)) is scheduled to perform query preprocessing on the current user message to obtain the target query statement. The SQLiteFTS5 index is then retrieved using the BM25 ranking function of FTS5. The top K memory entries related to the target query statement are selected in descending order of relevance as key memory content.

[0067] Wherein, K≥1 and K is an integer, and its specific value can be set based on application requirements. For example, it can be set to 2. This disclosure does not limit this.

[0068] In this embodiment of the disclosure, when performing query preprocessing on the current user message, FTS5 special operators (e.g., double quotes, parentheses, colons, plus and minus signs, etc.) can be stripped from the current user message. Each Chinese, Japanese and Korean character in the current user message can be split into independent numeric code points, and spaces can be inserted between each split character. Then, FTS5 reserved words (e.g., AND, OR, NOT, NEAR) that may exist between the split characters can be filtered. Finally, the filtered characters can be connected using the FTS5 OR operator to obtain the target query statement.

[0069] Step S304: According to the preset assembly format, assemble the key memory content into memory prefix text, and then concatenate the memory prefix text into the current user message to generate a new current user message.

[0070] In this embodiment of the disclosure, after assembling the key memory content into a memory prefix text according to a preset assembly format, the memory prefix text can be appended to the current user message to generate a new current user message. Based on this, generating a new current user message can be characterized as follows: [Top K related current user messages] [Category] (Date) Memory Entry [Current User Message] <Current User Message> For example, the current user message is "Recommend a place suitable for travel"; the key memory content related to the current user message includes: (1) "Likes seaside cities", category is preference, date is 2026-07-07; (2) "Allergic to seafood", category is fact, date is 2026-07-08. Then, according to the preset assembly format, the key memory content is assembled into a memory prefix text, and the memory prefix text is concatenated to the current user message to generate a new current user message that can be: [Top 2 related current user messages] -Preference (2026-07-07): I like seaside cities. - Fact (July 7, 2026): Allergic to seafood [Current User Message] Recommend a place suitable for travel Step S305: Based on the new current user message, generate a user message event, and append the user message event to the user message event stream stored in the event stream file through the target system scheduling method.

[0071] In other words, in this embodiment of the disclosure, a new current user message can be encapsulated as a user message event, and the user message event can be appended to the user message event stream stored in the event stream file through the target system scheduling method. It should be noted that in this embodiment of the disclosure, appending the user message event to the user message event stream stored in the event stream file, rather than the system message event stream, ensures that the cached breakpoints prompted by the system in the system message event remain unchanged.

[0072] In this embodiment of the present disclosure, after receiving a current user message, valuable memory content can be extracted from the current user message, and the current user's long-term memory content can be updated based on this valuable memory content. Furthermore, when writing the current user message to the event stream file of the current session, key memory content related to the current user message can be determined from the current user's long-term memory content. A new current user message is then generated based on the current user message and the key memory content, and a user message event is generated based on the new current user message. This user message event is then appended to the user message event stream stored in the event stream file. Therefore, when subsequently entering the processing flow for the current user message based on the event stream file to obtain the current message processing result, the long-term memory context can be effectively relied upon, thereby generating a more personalized and targeted current message processing result.

[0073] Furthermore, in this embodiment of the disclosure, CJK word segmentation is introduced in the writing process of valuable memory content and the retrieval process of key memory content. This can reduce the difficulty of memory retrieval in Japanese and Korean, and improve the recall rate of key memories in Chinese, Japanese and Korean scenarios, so as to further ensure that the generated current message processing results are more personalized and targeted.

[0074] Furthermore, in this embodiment of the disclosure, after performing step S101, the following can be done: If the current user message contains a suggestion function, and the suggestion function is a composite function, obtain the complete description information of the suggestion function from the assembly layer; Based on the complete description information of the suggested function, a lazy loading unload record event is generated to be appended to the lazy loading unload record event stream stored in the event stream file.

[0075] Among these, a composite function, also known as a skill, can be a complex function that involves scheduling multiple target tools sequentially and / or in parallel according to a fixed execution order to complete a corresponding task. Here, the multiple target tools can originate from a preset tool set, which stores multiple candidate tools, such as email sending tools, logistics tracking tools, product inventory tracking tools, food ordering tools, weather query tools, text translation tools, text generation tools, scientific computing tools, etc. For example, there is a composite function: the "Weather Tips" skill, which can first schedule a weather query tool, then schedule a text generation tool, to complete a weather query and provide clothing suggestions—a complex function.

[0076] In this embodiment of the disclosure, when a suggestion function exists in the current user message and the suggestion function is a composite function, complete description information of the suggestion function is obtained from the assembly layer. Based on the complete description information of the suggestion function, a lazy loading expansion record event is generated (that is, the complete description information of the suggestion function is encapsulated as a lazy loading expansion record event), and the lazy loading expansion record event is appended to the lazy loading expansion record event stream stored in the event stream file. The complete description information of the suggestion function may include at least one of the following: Functional metadata: function name, icon, and a brief description, used for system registration and for extracting concise explanatory information.

[0077] Function Description: Explain the purpose, applicable scenarios, and overall execution goals of this function.

[0078] Execution steps: List the multiple target tools that need to be scheduled and their inputs and outputs in a fixed execution order. Conditional branches and error handling logic may be included if necessary.

[0079] Notes: Record the matters that require special attention when scheduling this function (e.g., security constraints, timeout handling, exception degradation strategies, etc.).

[0080] Preferably, in this embodiment of the disclosure, the complete description information of the suggested function may include function metadata, function description, execution steps, and precautions.

[0081] In this embodiment of the disclosure, after performing step S101, it is also possible to: Get the session resource consumption related to the current user's message; If the session resource consumption meets the resource over-limit determination criteria, perform digest processing on the current user message to obtain the current message digest; Based on the current message digest, a message digest event is generated to be appended to the message digest event stream of the event stream file.

[0082] The session resource consumption can include the amount of resources already consumed in the current session, the predicted amount of resources consumed for the current user message, or one of the two. Here, the amount of resources already consumed can be used to represent the minimum number of semantic units consumed in processing the current session; the predicted amount of resources consumed can be used to represent the minimum number of semantic units that may be consumed in processing the current user message.

[0083] Based on this, in this embodiment of the disclosure, when the session resource consumption includes the consumed resources of the current session and the predicted consumed resources for the current user message, "obtaining the session resource consumption related to the current user message" may include: Determine the amount of resources consumed in the current session; Get the predicted resource consumption for the current user message; Based on the amount of resources already consumed and the predicted amount of resources to be consumed, the session resource consumption related to the current user message is obtained.

[0084] In this embodiment of the disclosure, when determining the amount of resources consumed in the current session, the resource usage statistics of all model response events in the model response event stream can be read from the event stream file of the current session, and these resource usage statistics are accumulated to obtain the amount of resources consumed in the current session.

[0085] In this embodiment of the disclosure, when obtaining the predicted resource consumption for the current user message, the predicted resource consumption for the current user message can be obtained based on the event stream file. For example, a fixed part of any system prompt (e.g., safety red line information, operation rule information, and agent personality information) can be extracted from the system message event stream stored in the event stream file. All message summary events in the message summary event stream, all model response events in the model response event stream, and all function execution events in the function execution event stream can be extracted. All extracted content can then be superimposed to obtain the prediction dependency text. Finally, the prediction dependency text is segmented to determine the minimum number of semantic units obtained after segmentation, which is used as the predicted resource consumption for the current user message.

[0086] In this embodiment of the disclosure, after determining the amount of resources consumed in the current session and obtaining the predicted amount of resources consumed for the current user message, the consumed resources and the predicted amount of resources consumed can be used together as the session resource consumption related to the current user message. This allows for digest processing of the current user message to obtain a current message digest when the session resource consumption meets the resource over-limit determination condition. Based on the current message digest, a message digest event is generated (i.e., the current message digest is encapsulated as a message digest event), and the message digest event is appended to the message digest event stream in the event stream file. The resource over-limit determination condition can be that a first part of the session resource consumption (i.e., the consumed resources) is greater than or equal to a first resource threshold, and a second part of the session resource consumption (i.e., the predicted resource consumption) is greater than or equal to a second resource threshold. Here, the first and second resource thresholds can be set based on application requirements, and this embodiment of the disclosure does not impose any limitations on them.

[0087] The above-mentioned "summarizing the current user message to obtain a current message summary" can be achieved by using a main intelligent agent to perform summarizing the current user message to obtain a current message summary within a preset number of characters. The preset number of characters can be set based on application requirements; for example, it can be set to 500, and this embodiment does not impose any limitations on this. Furthermore, it should be noted that in this embodiment, when using the main intelligent agent to perform summarizing the current user message, the main intelligent agent may also fail to process the message (e.g., due to network anomalies, API limits, model errors, etc.). In this case, a summarizing failure event can be appended to the summarizing failure event stream stored in the event stream file of the current session, and a user summary prompt can be generated to prompt the current user to simplify the current user message into a new current user message.

[0088] Through the above methods, in this embodiment of the disclosure, the session resource consumption related to the current user message (including the consumed resources of the current session and the predicted resource consumption for the current user message) can be obtained. When the session resource consumption meets the resource over-limit determination condition, the current user message is digested to obtain a current message digest. Then, based on the current message digest, a message digest event is generated and appended to the message digest event stream in the event stream file. Thus, when constructing session reference information based on the event stream file subsequently, the first state representation information mapped to a certain user message event in the user message event stream can be replaced by the second state representation information mapped to the corresponding message digest event. This effectively reduces the context content used to construct the session reference information, ensuring the continuous and stable operation of long sessions and further improving the reliability of message processing.

[0089] Furthermore, in this embodiment of the disclosure, when executing step S102, that is, entering the processing flow for the current user message based on the event stream file to obtain the current message processing result, step S102-1 in the processing flow, as an optional implementation, may include: Based on the event stream file, identify multiple target event streams; Construct session reference information based on multiple target event streams.

[0090] The multiple target event streams may include at least one of system message event streams, user message event streams, message digest event streams, model response event streams, and function execution event streams, preferably including system message event streams, user message event streams, message digest event streams, model response event streams, and function execution event streams.

[0091] In this embodiment of the disclosure, when multiple target event streams include system message event streams, user message event streams, message digest event streams, model response event streams, and function execution event streams, after determining multiple target event streams based on the event stream files, the `Session.to_messages()` method can be scheduled to iterate through the event stream files, mapping system message events included in the system message event stream to system state information, user message events included in the user message event stream to original user state information, model response events included in the model response event stream to intelligent assistant information, function execution events included in the function execution event stream to function execution information, and message digest events included in the message digest event stream to synthesized user state information. Session reference information is then constructed based on the system state information, original user state information, intelligent assistant information, function execution information, and synthesized user state information. The original user state information may include at least one first state representation information, and each of the at least one first state representation information may be the result mapped from a certain user message event; the synthesized user state information may include at least one second state representation information, and each of the at least one second state representation information may be the result mapped from a certain message digest event. Based on this, in the embodiments of this disclosure, when constructing session reference information based on system state information, original user state information, intelligent assistant information, function execution information and synthesized user state information, for each of the at least one second state representation information, if there is a first state representation information in at least one first state representation information that has the same semantics as the second state representation information, the first state representation information can be ignored. That is, when constructing session reference information, the second state representation information is used to replace the first state representation information.

[0092] In this embodiment of the present disclosure, multiple target event streams (e.g., at least one of system message event streams, user message event streams, message digest event streams, model response event streams, and function execution event streams) can be determined based on an event stream file, and session reference information can be constructed based on these multiple target event streams. That is, in this embodiment of the present disclosure, the construction of session reference information does not rely on maintaining a variable message list in the electronic device's memory, but rather on dynamic projection of related events included in multiple target event streams that are persistently stored in the event stream file. Since the event stream file uses an append-only write method, each related event stream is an immutable historical fact. Therefore, the session reference information obtained by projecting related events from a portion of the target event streams in these related event streams is deterministic and reproducible. In other words, under the same multiple target event streams, performing the operation of constructing session reference information multiple times yields completely consistent results. This not only avoids the problem of inconsistent states caused by improper maintenance of the variable message list, but also makes the construction process of session reference information itself a stateless computational operation, further strengthening the stateless characteristics of the scheduling layer.

[0093] In this embodiment of the disclosure, when executing step S102, that is, entering the processing flow for the current user message based on the event stream file to obtain the current message processing result, step S102-2 in the processing flow can, as an optional implementation, include: Obtain the first functional information from the assembly layer; Obtain the second functional information from the assembly layer; Based on the first and second functional information, construct a complete system prompt; Using the main intelligent agent, following the complete system prompts and based on the session reference information, the model response results are obtained.

[0094] The first functional information can be used to list multiple individual functions. Here, the multiple individual functions can come from a preset set of tools. That is, for each individual function among the multiple individual functions, it can be a candidate tool in the preset set of tools, such as an email sending tool, a logistics tracking tool, a product inventory tracking tool, a food ordering tool, a weather query tool, a text translation tool, a text generation tool, a scientific computing tool, etc.

[0095] The second functional information can be used to list multiple composite functions, and include a brief description of each composite function. This brief description can be functional metadata, namely, the function name, icon, and a one-sentence summary.

[0096] In this embodiment of the disclosure, after obtaining the first functional information from the assembly layer and the second functional information from the assembly layer, the first functional information and the second functional information can be used together as a complete system prompt; alternatively, a complete system prompt can be constructed in the following ways: Obtain all common prompts from the assembly layer; From the assembly layer, all user prompts are loaded. Based on all public and user prompts, a complete system prompt is constructed.

[0097] Please combine Figure 4 In this embodiment of the disclosure, the full set of public prompt information may include at least one of the following: security red line information (stored in the security red line file SAFETY.md), operation rule information (stored in the operation rule file AGENTS.md), and agent personality information (stored in the agent personality file SOUL.md), preferably including security red line information, operation rule information, and agent personality information. Here, security red line information can be used to define mandatory security constraints that the main agent must not violate under any circumstances, such as prohibiting the output of illegal content or the disclosure of user privacy; operation rule information can be used to define the main agent's behavioral norms at the service level, such as the maximum number of dialogue rounds in a single session or the requirement for sensitive questions to be transferred to human agents; agent personality information can be used to define the main agent's identity, tone style, and response preferences, such as setting it as a professional and meticulous customer service assistant or a warm and lively personal assistant.

[0098] The full set of user prompts can include first functional information (stored in the tool list file TOOLS.md) and second functional information (stored in the skill list file SKILLS.md), as well as at least one of the following: current user profile information (stored in the profile file USER.md) and long-term memory content (stored in the memory file MEMORY.md), preferably including both current user profile information and long-term memory content. The current user profile information can be used to represent the current user's static attributes and long-term stable personal characteristics, such as name, age, gender, place of origin, occupation, and city of work. The current user's long-term memory content can be used to represent the current user's historical behavioral records and dynamically accumulated factual information, which is continuously updated with the current user's ongoing interaction with the main intelligent agent, such as user preferences, user background, past experiences, and recent goals.

[0099] Based on this, in this embodiment of the disclosure, when the full amount of user prompt information is loaded from the assembly layer, the current user's profile information and long-term memory content can be loaded from the assembly layer, so that the first function information, the second function information, and the current user's profile information and long-term memory content are used together as the full amount of user prompt information.

[0100] In this embodiment, after obtaining all public prompt information from the assembly layer and loading all user prompt information from the assembly layer, a complete system prompt including all public prompt information and all user prompt information can be generated. That is, a complete system prompt is assembled using the full mode. Subsequently, a system message event can be generated based on the complete system prompt (i.e., the complete system prompt is encapsulated as a system message event), and the system message event is appended to the system message event stream stored in the event stream file. Simultaneously, the main agent, according to the complete system prompt and based on the session reference information, obtains the model response result. That is, the complete system prompt and session reference information are used as inputs to the main agent to obtain the model response result. The model response result can be directly output by the main agent or indirectly output by the main agent through scheduling derived agents; the specific output method can be intelligently decided by the main agent.

[0101] Based on this, in the embodiments of this disclosure, "using the main intelligent agent, following the complete system prompts, and based on the session reference information, to obtain the model response result" may include: Using the main intelligent agent, following the complete system prompts and based on the session reference information, the model response results excluding function scheduling information are obtained.

[0102] As previously stated, in this embodiment of the disclosure, if the model response result does not include function scheduling information, the model response result is taken as the current message processing result.

[0103] In this embodiment of the disclosure, "using the main intelligent agent, following the complete system prompts, and based on the session reference information, to obtain the model response result" may also include at least one of the following: Using the main agent, following the complete system prompts and based on the session reference information, the model response result including function scheduling information is obtained (that is, the complete system prompts and session reference information are used as inputs to the main agent to obtain the model response result including function scheduling information). Using the main agent, following the complete system prompts and based on the session reference information, generate M tasks to be executed and determine the derivative agents corresponding to each of the M tasks to be executed; for each of the M tasks to be executed, use the derivative agents corresponding to the task to be executed to obtain the model response result for the task to be executed, including the function scheduling information.

[0104] Where M ≥ 1 and M is an integer; the M tasks to be executed may include travel planning tasks, travel, food ordering tasks, document generation tasks, scientific computing tasks, etc.; the derived intelligent agent can be an intelligent software system driven by the second major model, which can be an LLM, specifically a pre-trained autoregressive generative model (e.g., an autoregressive generative model based on the Transformer architecture), possessing general language knowledge, world knowledge, and domain-specific expertise. It should be noted that in this embodiment, the second major model and the first major model can be the same major model or two independent major models, and this embodiment does not impose any restrictions on this.

[0105] It should also be noted that, in this embodiment of the disclosure, the selection of the subject (main agent and / or derived agent) for obtaining the model response result, including the function scheduling information, is decided intelligently by the main agent. It should also be noted that, in this embodiment of the disclosure, after obtaining the model response result, a model response event can be generated based on the model response result (that is, the model response result is encapsulated as a model response event), and the model response event can be appended to the model response event stream stored in the event stream file.

[0106] Furthermore, in this embodiment of the disclosure, "obtaining a model response result for the task to be executed, including functional scheduling information, using a derived agent corresponding to the task to be executed" may include: Determine the nature of the task to be performed; Based on the nature of the task, construct concise system prompts; Using the derived agent corresponding to the task to be executed, and following the brief system prompts, the model response result for the task to be executed, including functional scheduling information, is obtained.

[0107] The task to be executed can be either a skill-based task or a tool-based task. Here, a skill-based task can be a composite task that requires multiple target tools to be scheduled sequentially and / or in parallel according to a fixed execution order to complete the corresponding task, usually corresponding to a composite function; a tool-based task can be an atomic task that can complete the corresponding task by calling a single target tool, usually corresponding to a single function.

[0108] Based on this, in this embodiment of the disclosure, "constructing a brief system prompt based on the nature of the task" may include: In the case of a skill-based task, obtain all common prompts from the assembly layer; Obtain the first functional information and the second functional information from the assembly layer; Based on the full set of public prompts, primary function information, and secondary function information, a concise system prompt is constructed.

[0109] As mentioned above, in this embodiment of the disclosure, the full amount of public prompt information includes at least one of safety red line information, operation rule information, and intelligent agent personality information, preferably including safety red line information, operation rule information, and intelligent agent personality information; the first functional information can be used to list multiple single functions; the second functional information can be used to list multiple composite functions and include a brief description of each composite function.

[0110] In this embodiment of the disclosure, after obtaining all the common prompt information from the assembly layer and the first functional information and the second functional information from the assembly layer, a brief system prompt including all the common prompt information, the first functional information, and the second functional information can be generated. That is, a brief system prompt is generated using a minimal mode (e.g., ...). Figure 4 (As shown). Subsequently, system message events can be generated based on the brief system prompts (that is, the brief system prompts are encapsulated as system message events), and the system message events can be appended to the system message event stream stored in the event stream file; at the same time, using the derived agent corresponding to the task to be executed, the model response result for the task to be executed, including function scheduling information, is obtained according to the brief system prompts. That is, the brief system prompts and the task to be executed are used as inputs to the derived agent to obtain the model response result including function scheduling information.

[0111] In this embodiment of the disclosure, "constructing a brief system prompt based on the nature of the task" may include: In the case of a tool-type task, obtain the agent's personality information from the assembly layer; Obtain the first functional information from the assembly layer; Based on the agent's personality information and primary function information, a brief system prompt is constructed.

[0112] In this embodiment of the disclosure, when obtaining agent personality information from the assembly layer, only the first non-title, non-blank line of the agent personality information, such as "You are a customer service assistant" or "You are a personal assistant" can be obtained.

[0113] As previously stated, in this embodiment of the disclosure, the first functional information can be used to list multiple individual functions.

[0114] In this embodiment of the disclosure, after obtaining agent personality information and first functional information from the assembly layer, a brief system prompt including agent personality information and first functional information can be generated. That is, using a bare identity (none) mode, a brief system prompt (such as...) is assembled. Figure 4(As shown). Subsequently, system message events can be generated based on the brief system prompts (that is, the brief system prompts are encapsulated as system message events), and the system message events can be appended to the system message event stream stored in the event stream file; at the same time, using the derived agent corresponding to the task to be executed, the model response result for the task to be executed, including function scheduling information, is obtained according to the brief system prompts. That is, the brief system prompts and the task to be executed are used as inputs to the derived agent to obtain the model response result including function scheduling information.

[0115] In this embodiment, the first functional information (listing multiple single functions) and the second functional information (listing multiple composite functions and including brief descriptions of each composite function) can be obtained from the assembly layer. Based on these two functional information, a complete system prompt is constructed. Then, the main agent, following the complete system prompt and based on the session reference information, obtains the model response result. In other words, in this embodiment, the second functional information, besides listing multiple composite functions, only includes brief descriptions of each composite function (i.e., a "lazy loading" method is used to load the second functional information), rather than injecting all the complete descriptions of each composite function at once to construct the complete system prompt. Since the information density of the brief descriptions is much lower than that of the complete descriptions, the number of minimum semantic units required for the complete system prompt can be significantly reduced. For example, when there are 10 composite functions, using a "lazy loading" approach, loading the information for the second function only requires approximately 300-500 minimum semantic units, while injecting the complete descriptions of all 10 composite functions at once requires approximately 6800 minimum semantic units. This represents a saving of about 88% in minimum semantic unit consumption. Furthermore, this not only allows the main agent to obtain an overview of all available composite functions from the complete system prompts but also preserves sufficient context window space for subsequent dialogue interactions, effectively extending the maximum number of dialogue turns supported by the current session.

[0116] Furthermore, in this embodiment, when constructing a complete system prompt based on the first and second functional information, the full set of public prompt information (including at least one of security red line information, operational rule information, and intelligent agent personality information) can be obtained from the assembly layer, and the full set of user prompt information (including the first and second functional information, and at least one of the current user's profile information and long-term memory content) can be loaded from the assembly layer. Then, the complete system prompt is constructed based on the full set of public and user prompt information. In other words, in this embodiment, the complete system prompt is constructed jointly by the full set of public and user prompt information. The full set of public prompt information is a fixed part at the platform level, shared by all tenants, and its content remains stable throughout the session; the full set of user prompt information is personalized content at the tenant or user level and can be loaded on demand. This layered assembly approach achieves several advantages. First, it enables unified management and reuse of common prompts, avoiding the tedious task of maintaining the same content for each tenant. Second, because the content of common prompts remains stable, the prompt cache can be effectively hit when the main intelligent agent is applied, avoiding the need to retransmit the same common parts for each request, thereby further reducing the application cost and response latency of the main intelligent agent. At the same time, the independent loading mechanism for user prompts allows different tenants and users to have their own personalized system prompt configurations, achieving a good balance between platform uniformity and user personalization.

[0117] Furthermore, in this embodiment of the disclosure, when using the main intelligent agent to obtain the model response result based on the session reference information according to the complete system prompts, the main intelligent agent can be used to obtain the model response result excluding function scheduling information based on the session reference information according to the complete system prompts; alternatively, the main intelligent agent can be used to obtain the model response result including function scheduling information based on the session reference information according to the complete system prompts; and / or the main intelligent agent can be used to generate M tasks to be executed according to the session reference information according to the complete system prompts, and determine the derivative intelligent agent corresponding to each of the M tasks to be executed; for each of the M tasks to be executed, the derivative intelligent agent corresponding to the task to be executed is used to obtain the model response result for the task to be executed, which includes function scheduling information. In other words, in this embodiment, the main agent can adaptively select the most suitable processing path based on the session reference information, following the complete system prompts: outputting a model response result excluding function scheduling information as a reply to the current user message; outputting a model response result including function scheduling information; generating M tasks to be executed, and delegating a corresponding derivative agent to each of the M tasks to be executed, so as to utilize the derivative agent to output a model response result for the task to be executed, including function scheduling information. This not only improves the efficiency and flexibility of message processing, but also avoids the problem of a single agent bearing an excessive burden of inference computation, thus improving the scalability and task processing capabilities of the message processing system.

[0118] Specifically, when using the derived agent corresponding to the task to be executed to obtain the model response result for the task to be executed, including function scheduling information, the nature of the task to be executed can be determined, and a brief system prompt can be constructed based on the task nature (for example, in the case of a skill-type task, all common prompt information is obtained from the assembly layer, as well as the first function information and the second function information are obtained from the assembly layer, and a brief system prompt is constructed based on the all common prompt information, the first function information and the second function information; as another example, in the case of a tool-type task, agent personality information is obtained from the assembly layer, as well as the first function information is obtained from the assembly layer, and a brief system prompt is constructed based on the agent personality information and the first function information). Then, using the derived agent corresponding to the task to be executed, the model response result for the task to be executed, including function scheduling information, is obtained according to the brief system prompt. In other words, in this embodiment of the disclosure, when processing tasks to be executed, the derived agent can dynamically select different system prompt assembly modes based on the nature of the task (skill-based task or tool-based task): For skill-based tasks, since multiple target tools need to be scheduled according to a fixed execution order, the derived agent needs to know common prompt information, single function lists, and composite function lists. Therefore, a simplified mode is adopted to assemble simplified system prompts, ensuring that the derived agent has sufficient decision-making basis while avoiding carrying redundant information unrelated to the current task. For tool-based tasks, since only a single target tool needs to be called to complete the task, the derived agent only needs to know basic personality identity information and single function lists. Therefore, a bare identity mode is adopted to assemble simplified system prompts, compressing the content of the simplified system prompts to the extreme. This on-demand assembly of simplified system prompts allows the derived agent to complete reasoning calculations with the most concise simplified system prompts while meeting application requirements each time a task is executed, maximizing the saving of the smallest semantic unit consumption; at the same time, since the simplified system prompts are shorter, the reasoning speed of the derived agent can also be significantly improved, thereby shortening the overall response time of the current user message.

[0119] In this embodiment of the disclosure, when executing step S102, that is, entering the processing flow for the current user message based on the event stream file to obtain the current message processing result, steps S102-4 in the processing flow can, as an optional implementation, include: Take each of the N functions to be executed indicated by the function scheduling information as the target function and generate a scheduling instruction for the target function. In the execution layer, the target function is executed based on the scheduling instructions to obtain the function execution result corresponding to the target function.

[0120] The execution result corresponding to the target function can be used to generate a function execution event, so that the function execution event can be appended to the function execution event stream stored in the event stream file.

[0121] In this embodiment of the disclosure, "generating scheduling instructions for the target function" may include: Perform a whitelist check on the target function and obtain the check results; If the verification results indicate that the target function is available, a scheduling instruction for the target function is generated.

[0122] In this embodiment of the disclosure, when performing whitelist verification on a target function, a verification result indicating that the target function is available can be generated if the target function exists in the function whitelist; otherwise, a verification result indicating that the target function is unavailable can be generated. The function whitelist can record all registered functions (including single functions and composite functions) when the message processing system starts up, and this embodiment of the disclosure does not impose any limitations on this.

[0123] It should be noted that in this embodiment of the disclosure, if the verification result indicates that the target function is available, a scheduling instruction for the target function is generated; if the verification result indicates that the target function is unavailable, invalid function scheduling information is generated (e.g., including function identifier, function name, whether the scheduling was successful (scheduling failed), function execution result (empty) and error message (whitelist verification failed), and the invalid function scheduling information is encapsulated as a function execution event, so as to append the function execution event to the function execution event stream stored in the event stream file.

[0124] In this embodiment of the disclosure, "generating scheduling instructions for the target function" may include: Determine the target token bucket corresponding to the current tenant; Determine the number of tokens remaining in the target token bucket; If the number of remaining tokens meets the preset requirement, a scheduling instruction for the target function is generated.

[0125] The target token bucket can be a rate-limiting tool built for scheduling target functions for the current tenant. Here, the current tenant is the organizational entity to which the current user belongs, such as an enterprise, unit, or department.

[0126] In other words, in this embodiment of the disclosure, the target token bucket performs rate limiting at the granularity of (tenant identifier, function identifier), meaning that each function of each tenant maintains an independent token bucket. The target token bucket adopts a lazy creation strategy, being created only upon first use. During creation, the token replenishment rate (tokens_per_minute) and burst capacity can be determined based on the target function's configuration information. If the target function is not configured with the above rate limiting parameters, rate limiting is not performed by default. When the rate limiting parameters change, the old token bucket can be cleared (e.g., by using the invalidate() method) to make the new configuration take effect.

[0127] It should be noted that in this embodiment, the `check()` method of the target token bucket returns a check result including the remaining token quantity (`tokens_remaining`), whether the call is allowed (`allowed`), and the suggested waiting time (`retry_after_seconds`). When `allowed=False`, the scheduling layer does not wait but directly generates rate-limited information (`rate_limited`), ensuring that the current tenant's rate exceeding the limit will not block the global scheduling, and other tenants' requests can still be processed normally. Furthermore, the target token bucket's state data is stored in shared memory, and its concurrent read / write operations are protected by a thread lock (`threading.Lock`) to ensure the accuracy and consistency of counting in a multi-threaded scenario.

[0128] Based on the above, in this embodiment of the disclosure, after determining the target token bucket corresponding to the current tenant, the remaining number of tokens in the target token bucket can be determined. If the remaining number of tokens meets the preset quantity requirement (e.g., the remaining number of tokens is greater than or equal to 1), a scheduling instruction for the target function is generated, and the remaining number of tokens is decremented by 1. If the remaining number of tokens does not meet the preset quantity requirement (e.g., the remaining number of tokens is less than 1), no scheduling instruction for the target function is generated. Instead, rate-limited information is generated, and the rate-limited information is encapsulated as a function execution event. The function execution event is then appended to the function execution event stream stored in the event stream file.

[0129] In this embodiment of the disclosure, "generating scheduling instructions for the target function" may include: Determine the access control level for the target function; Based on the access control level, proceed to one of the following instruction generation processes: When the access control level is set to NONE (no authorization required), generate scheduling instructions for the target function; When the access control level is set to CONFIRM, an authorization prompt message is generated; in response to the authorization confirmation operation for the authorization prompt message, a scheduling instruction for the target function is generated. When the access control level is set to the payable level, a payment prompt message is generated; in response to the payment confirmation operation for the payment prompt message, a scheduling instruction for the target function is generated.

[0130] In other words, in this embodiment of the disclosure, after determining the access control level of the target function, the corresponding instruction generation process can be executed based on the access control level.

[0131] When the access control level is set to "no authorization required," it indicates that the target function is a low-risk operation and requires no additional user confirmation. In this case, scheduling instructions for the target function can be generated directly.

[0132] When the access control level is set to "Authorization Required," it indicates that the target function involves a medium-risk operation (e.g., sending emails, deleting files), requiring explicit user authorization. In this case, firstly, an authorization prompt message is generated and displayed on the terminal device; simultaneously, based on the authorization prompt message, a "Waiting for User Authorization" event is generated and appended to the "Waiting for User Authorization" event stream stored in the event stream file. Subsequently, in response to the authorization confirmation operation based on the authorization prompt message, a user authorization decision event can be generated and appended to the "User Authorization Decision" event stream stored in the event stream file. In this embodiment of the present disclosure, the scheduling layer can poll the event stream file of the current session (polling interval can be 0.5 seconds) to detect whether there is a user authorization decision event that matches the target function and has an authorization decision result of "success". When a user authorization decision event that matches the target function and has an authorization decision result of "success" is detected in the event stream file of the current session, a scheduling instruction for the target function is generated. If no user authorization decision event that matches the target function is detected in the event stream file of the current session, or if a user authorization decision event that matches the target function but has an authorization decision result of "deny" is detected, no scheduling instruction is generated.

[0133] When the access control level is set to the paid level, it indicates that the target function involves financial operations (e.g., transfers, order payments), requiring explicit user confirmation of payment. In this case, firstly, a payment prompt message is generated and displayed on the terminal device; simultaneously, based on the payment prompt message, a pending user authorization event is generated and appended to the pending user authorization event stream stored in the event stream file. Subsequently, in response to the payment confirmation operation based on the payment prompt message, a user authorization decision event can be generated and appended to the user authorization decision event stream stored in the event stream file. In this embodiment of the present disclosure, the scheduling layer can poll the event stream file of the current session (polling interval can be 0.5 seconds) to detect whether there is a user authorization decision event that matches the target function and has an authorization decision result of "success". When a user authorization decision event that matches the target function and has an authorization decision result of "success" is detected in the event stream file of the current session, a scheduling instruction for the target function is generated. If no user authorization decision event that matches the target function is detected in the event stream file of the current session, or if a user authorization decision event that matches the target function but has an authorization decision result of "deny" is detected, no scheduling instruction is generated.

[0134] It is understood that, in this embodiment of the disclosure, the above conditions can also be ensured to be met before generating scheduling instructions for the target function. That is, "generating scheduling instructions for the target function" may include: Perform a whitelist check on the target function and obtain the check results; If the verification results indicate that the target function is available, determine the target token bucket corresponding to the current tenant; Determine the number of tokens remaining in the target token bucket; If the number of remaining tokens meets the preset requirement, determine the access control level of the target function; Based on the access control level, proceed to one of the following instruction generation processes: When the access control level is set to "no authorization required", generate scheduling instructions for the target function; When the access control level is set to the authorization-required level, an authorization prompt message is generated; in response to the authorization confirmation operation for the authorization prompt message, a scheduling instruction for the target function is generated. When the access control level is set to the paid level, a payment prompt message is generated; in response to the payment confirmation operation for the payment prompt message, a scheduling instruction for the target function is generated.

[0135] Furthermore, in this embodiment of the disclosure, when actually generating scheduling instructions for the target function, the following can be done: If the target function is a single function, a scheduling instruction for the target function is generated based on the function identifier, function execution parameters, and resource quota; or, a scheduling instruction for the target function is generated based on the function identifier, function execution parameters, resource quota, and execution context.

[0136] The function execution parameters may include parameters required to execute the target function, which can be determined by the main agent based on session reference information. For example, when the target tool is a weather query tool, the function execution parameters may be "date + geographic location" determined based on session reference information. Resource quotas can be set based on application requirements, and this embodiment does not impose any restrictions on this. The execution context may include the identifier of the current session, the tenant identifier, the user identifier, the prior event snapshot, and the number of loops in the processing flow for the current user message, denoted as (session_id, tenant_id, user_id, prior_events snapshot, turn_index). Here, the prior event snapshot is used to record all relevant events stored in the event stream file before scheduling the target function.

[0137] It should be noted that, in the embodiments of this disclosure, whether an execution context is required when generating the scheduling instruction for the target function can be determined based on the settings when registering the target function in the message processing system, and the embodiments of this disclosure do not impose any restrictions on this.

[0138] In this embodiment of the disclosure, when actually generating scheduling instructions for the target function, it is also possible to: If the target function is a composite function, obtain complete description information of the target function; Based on the complete description information of the target function, generate scheduling instructions for the target function.

[0139] As described above, in this embodiment of the present disclosure, after executing step S101, if a suggestion function exists in the current user message and the suggestion function is a composite function, complete description information of the suggestion function can be obtained from the assembly layer. Based on the complete description information of the suggestion function, a lazy loading expansion record event is generated, and the lazy loading expansion record event is appended to the lazy loading expansion record event stream stored in the event stream file. Therefore, in this embodiment of the present disclosure, when obtaining complete description information of a target function, if the target function and the suggestion function are the same function, the complete description information of the suggestion function can be obtained from the event stream file as the complete description information of the target function; if the target function and the suggestion function are not the same function, the complete description information of the target function (stored in the skill list file) is obtained from the assembly layer.

[0140] In this embodiment of the disclosure, when generating a scheduling instruction for a target function based on complete description information of the target function, the scheduling instruction can be generated based on the function identifier, function execution parameters, and resource quota; or, it can be generated based on the function identifier, function execution parameters, resource quota, and execution context. The function execution parameters may carry complete description information of the target function, and may also carry other parameters determined by the main agent based on session reference information; this embodiment of the disclosure does not limit this. The resource quota can be set based on application requirements; this embodiment of the disclosure does not limit this. The execution context may include the identifier of the current session, tenant identifier, user identifier, prior event snapshot, and the number of loops in the processing flow for the current user message, denoted as (session_id, tenant_id, user_id, prior_events snapshot, turn_index). Here, the prior event snapshot is used to record all relevant events stored in the event stream file before scheduling the target function.

[0141] It should be noted that, in the embodiments of this disclosure, whether an execution context is required when generating the scheduling instruction for the target function can be determined based on the settings when registering the target function in the message processing system, and the embodiments of this disclosure do not impose any restrictions on this.

[0142] In this embodiment, each of the N pending functions indicated by the function scheduling information can be taken as a target function. A scheduling instruction for the target function is generated, and in the execution layer, the target function is executed based on the scheduling instruction to obtain the corresponding function execution result. Then, based on the corresponding function execution result, a function execution event is generated (i.e., the function execution result corresponding to the target function is encapsulated as a function execution event), and this function execution event is appended to the function execution event stream stored in the event stream file. Since the event stream file uses an append-only writing method, the function execution result of each round of function calls is completely recorded, forming a traceable and auditable execution trajectory. When the scheduling layer process crashes, the newly started scheduling layer process can replay the function execution events already stored in the event stream file to accurately determine which functions have been successfully executed and which have not, thereby avoiding duplicate or missed executions and further improving the reliability of message processing. Furthermore, when generating scheduling instructions for a target function, a whitelist check can be performed on the target function to obtain a verification result. If the verification result indicates that the target function is available, the target token bucket corresponding to the current tenant and the number of remaining tokens in the target token bucket can be determined. If the number of remaining tokens meets a preset requirement, the access control level of the target function can be determined. Based on the access control level, one of the following instruction generation processes can be initiated: if the access control level is no authorization required, a scheduling instruction for the target function is generated; if the access control level is authorization required, an authorization prompt message is generated; in response to the authorization confirmation operation for the authorization prompt message, a scheduling instruction for the target function is generated; if the access control level is a payment required level, a payment prompt message is generated; in response to the payment confirmation operation for the payment prompt message, a scheduling instruction for the target function is generated. In other words, in this embodiment of the disclosure, before generating a scheduling instruction for a target function, three levels of verification—whitelist check, token bucket rate limit, and access control level—are performed sequentially. Among these mechanisms, whitelist verification ensures that only legitimate functions registered with the message processing system can be scheduled, preventing unauthorized execution; token bucket rate limiting ensures that the frequency of a single tenant's calls to a specific function does not exceed the message processing system's capacity, and the non-blocking design ensures that over-limit tenants will not affect the normal request processing of other tenants; and access control ensures that functions of different risk levels can only be executed after obtaining explicit authorization from the user, especially when financial operations require user payment confirmation. The synergistic effect of these three verification mechanisms effectively guarantees the tool scheduling process in terms of functional legitimacy, resource fairness, and operational security, significantly improving the overall security and robustness of the message processing system.

[0143] Furthermore, in this embodiment of the disclosure, when actually generating a scheduling instruction for a target function, if the target function is a composite function, complete description information of the target function can be obtained, and a scheduling instruction for the target function can be generated based on the complete description information of the target function. Specifically, when obtaining the complete description information of the target function, if the target function and the suggested function are the same function, the complete description information of the suggested function can be obtained from the event stream file and used as the complete description information of the target function, thus avoiding obtaining the complete description information of the target function from the assembly layer. That is, in this embodiment of the disclosure, when the target function is a composite function and a scheduling instruction needs to be generated, if the complete description information of the composite function has already been executed after step S101, and a suggested function exists in the current user message and is a composite function, the complete description information of the suggested function can be obtained from the assembly layer, and a lazy loading expansion record event can be generated based on the complete description information of the suggested function. This lazy loading expansion record event is then appended to the lazy loading expansion record event stream stored in the event stream file, allowing the complete description information to be directly obtained from the event stream file without having to read it again from the assembly layer. This avoids redundant data parsing overhead and improves message processing efficiency.

[0144] Furthermore, it should be noted that in this embodiment of the disclosure, when executing a target function based on scheduling instructions to obtain the corresponding function execution result in the execution layer, the execution layer needs to follow the zero-credential agreement. That is, when scheduling the function corresponding to the target function, the execution layer can only pass the function execution parameters and resource quotas, without passing environment variables, open files, sockets, or any other environment capabilities, to prevent sensitive information from being leaked in the execution environment. Based on this, in this embodiment of the disclosure, the function corresponding to the target function supports two signature forms: the basic form, excluding the execution context, can be written as: async def skill(args, quota) -> function execution event; the context form, including the execution context, can be written as: async def skill(args, quota, context) -> function execution event. When the target function is registered, it can detect (e.g., through the inspect.signature() method) whether its function accepts the execution context parameter, so that the execution context is only passed to functions that accept the execution context parameter during scheduling, to maintain backward compatibility.

[0145] In this embodiment of the disclosure, the execution layer can provide optional multiple levels through a pluggable backend protocol (SandboxBackendProtocol), as shown in Table 2: Based on this, in the embodiments of this disclosure, when executing a target function based on scheduling instructions in the execution layer, available backend protocols suitable for the current operating environment can be automatically detected. Based on the capability comparison results of these backend protocols (as shown in Table 3), the highest priority backend protocol is selected to execute the target function according to the priority order of Firecracker > Opensandbox > Firejail > Bubblewrap > Passthrough, thereby achieving the purpose of isolating function execution (e.g., ...). Figure 5 (As shown). Furthermore, in this embodiment of the disclosure, for the Firecracker backend, the execution layer supports caching microvirtual machine instances on a session basis. Multiple executions of functions corresponding to the same session identifier reuse the same microvirtual machine instance to avoid the time overhead of restarting the microvirtual machine for each execution.

[0146] Furthermore, in this embodiment, the execution layer also provides a multi-tenant key management mechanism to support the secure injection of sensitive credentials (e.g., API keys, database passwords, third-party service tokens, etc.) required for the target function into the execution environment when executing the target function. This mechanism employs a two-layer encryption scheme, specifically including: a Key Encryption Key (KEK), which uses the SecretBox symmetric encryption algorithm and is encrypted and stored as the master key in the runtime environment; and a Data Encryption Key (DEK), a symmetric key independently generated for each tenant (e.g., a Fernet symmetric key), which is encrypted using the KEK and stored in the tenant configuration file. When the execution layer needs to call the target function, it first uses the KEK to decrypt the current tenant's DEK, and then uses the DEK to decrypt the plaintext credentials required by the target function. The plaintext credentials only exist within the lifetime of the execution environment instance.

[0147] In this embodiment of the disclosure, the administrator can list the key metadata of each tenant (e.g., key name, creation time, last update time, etc.) through the management API, but cannot obtain the plaintext key value, so as to ensure that the administrator cannot access the tenant's sensitive information without authorization; the tenant can manage its own keys through the tenant-side key management API (e.g., / api / tenant / secrets), including operations such as adding, updating, deleting and querying keys.

[0148] In this embodiment, regarding key transmission, plaintext credentials can be transmitted to the execution environment of the target function via environment variable injection or written to a temporary file within the sandbox via file injection, for the target function to read during execution. For target functions that support context-based signatures, their execution context also carries the key management interface of the current tenant, enabling the target function to obtain specific credentials as needed during execution. Furthermore, in this embodiment, the lifecycle of the aforementioned environment variables and temporary files is bound to the current execution environment instance. After the execution environment instance is destroyed, the environment variables and temporary files are released, and the credential information will not remain on the host machine.

[0149] Furthermore, it should be noted that in this embodiment, the execution layer supports two function signature forms when calling the target function: the basic form is `async def skill(args, quota)`, and the context form is `async def skill(args, quota, context)`. When registering the target function, the execution layer uses reflection (e.g., Python's `inspect.signature()` method) to detect whether the target function accepts a context parameter. During the call, the execution context (SkillContext) is only passed to functions that accept context parameters to maintain backward compatibility. The execution context includes the current session identifier, tenant identifier, user identifier, prior event snapshot, and the number of iterations in the processing flow for the current user's messages (denoted as `session_id`, `tenant_id`, `user_id`, `prior_events` snapshot, and `turn_index`). After executing the target function, the execution layer obtains the corresponding function execution result.

[0150] The following will be combined with Figure 6 The architecture of a message processing system provided in the embodiments of this disclosure is described.

[0151] In this embodiment, the agent runtime is decoupled into three orthogonal layers with single responsibilities and independent replacement: the tracing layer, the scheduling layer, and the execution layer. The tracing layer manages the event stream file of the current session; the scheduling layer holds zero dialogue state, possessing only configuration information (e.g., the agent's client, function registry, resource quotas, rate limiters, etc.); and the execution layer provides the execution environment for performing specific functions.

[0152] In addition, this embodiment of the disclosure also provides an assembly layer for storing the safety red line file SAFETY.md, the operation rules file AGENTS.md, the agent personality file SOUL.md, the tool list file TOOLS.md, the skill list file SKILLS.md, the profile file USER.md, and the memory file MEMORY.md.

[0153] The responsibilities of each layer can be found in the relevant descriptions in the aforementioned message processing method embodiments, and will not be repeated here.

[0154] The following, combined with Figure 7 The complete flow of a message processing method provided by the embodiments of this disclosure will be described.

[0155] Step S701: In response to the received current user message, write the current user message to the event stream file of the current session.

[0156] The event stream file can be managed by the sourcing layer and persisted in an append-only manner.

[0157] In step S702, if a suggestion function exists in the current user message and the suggestion function is a composite function, obtain the complete description information of the suggestion function from the assembly layer, and generate a lazy loading expansion record event based on the complete description information of the suggestion function, so as to append the lazy loading expansion record event to the lazy loading expansion record event stream stored in the event stream file.

[0158] Step S703: Detect whether there is a user cancellation event generated in response to the user cancellation operation in the event stream file.

[0159] In this embodiment of the disclosure, if a user cancellation event generated in response to a user cancellation operation exists in the event stream file, step S704 is executed; if no user cancellation event generated in response to a user cancellation operation exists in the event stream file, step S705 is executed.

[0160] Step S704: Generate a user cancellation event and append it to the event stream file, then end the processing flow for the current user message.

[0161] Step S705: Obtain the session resource consumption related to the current user message, and if the session resource consumption meets the resource over-limit determination condition, perform digest processing on the current user message to obtain the current message digest, and then generate a message digest event based on the current message digest to append the message digest event to the message digest event stream of the event stream file.

[0162] Step S706: Based on the event stream file, enter the processing flow for the current user message to obtain the current message processing result.

[0163] In this embodiment of the disclosure, the processing flow may include: Step S706-1: Check whether the number of loops in the processing flow for the current user message has reached the maximum number of loops (max_steps).

[0164] In this embodiment of the disclosure, if the number of loops in the processing flow for the current user message reaches the maximum number of loops, step S706-2 is executed; if the number of loops in the processing flow for the current user message does not reach the maximum number of loops, step S706-3 is executed.

[0165] Step S706-2: Generate an event indicating that the maximum number of loops has been reached, append it to the event stream file, and then end the processing flow for the current user message.

[0166] Step S706-3: Check if there is a user cancellation event generated in response to the user cancellation operation in the event stream file.

[0167] In this embodiment of the disclosure, if a user cancellation event generated in response to a user cancellation operation exists in the event stream file, step S706-4 is executed; if no user cancellation event generated in response to a user cancellation operation exists in the event stream file, step S706-5 is executed.

[0168] Step S706-4: Generate a user cancellation event and append it to the event stream file, then end the processing flow for the current user message.

[0169] Step S706-5: Based on the event stream file, determine multiple target event streams, and construct session reference information based on the multiple target event streams.

[0170] The multiple target event streams can include system message event streams, user message event streams, message digest event streams, model response event streams, and function execution event streams; the user message event streams are supplemented with user message events generated based on the current user message.

[0171] Step S706-6: Obtain first functional information and second functional information from the assembly layer, and construct a complete system prompt based on the first and second functional information, and then output the response result through the main intelligent agent intelligent decision model.

[0172] The first functional information can be used to list multiple single functions; the second functional information can be used to list multiple composite functions, and includes a brief description of each composite function.

[0173] In this embodiment of the disclosure, the output method of the model response result can be a first output method or a second output method. The first output method outputs a model response result that does not include function scheduling information; the second output method outputs a model response result that includes function scheduling information. In this embodiment of the disclosure, when the output method of the model response result is the first output method, step S706-7 is executed; when the output method of the model response result is the second output method, step S706-9 is executed.

[0174] Step S706-7: Using the main intelligent agent, following the complete system prompts and based on the session reference information, obtain the model response result excluding function scheduling information.

[0175] Step S706-8: Use the model response result as the current message processing result and end the processing flow for the current user message.

[0176] Steps S706-9: Using the main agent, following the complete system prompts and based on the session reference information, obtain the model response result including function scheduling information; and / or, using the main agent, following the complete system prompts and based on the session reference information, generate M tasks to be executed, and determine the derivative agent corresponding to each of the M tasks to be executed; for each of the M tasks to be executed, use the derivative agent corresponding to the task to be executed to obtain the model response result for the task to be executed, including function scheduling information.

[0177] Where M≥1 and M is an integer.

[0178] Step S706-10: In the execution layer, execute the N functions to be executed as indicated by the function scheduling information to obtain N function execution results corresponding one-to-one with the N functions to be executed, and generate function execution events corresponding one-to-one with the N function execution results, and append them to the event stream file.

[0179] Where N ≥ 1 and N is an integer; the results of N function executions can be used to obtain the current message processing result.

[0180] Furthermore, in this embodiment of the disclosure, "in the execution layer, executing the N functions to be executed as indicated by the function scheduling information to obtain N function execution results corresponding one-to-one with the N functions to be executed" may include: Take each of the N functions to be executed indicated by the function scheduling information as the target function and generate a scheduling instruction for the target function. In the execution layer, the target function is executed based on the scheduling instructions to obtain the function execution result corresponding to the target function.

[0181] Furthermore, in this embodiment of the disclosure, "generating scheduling instructions for a target function" may include: Perform a whitelist check on the target function and obtain the check results; If the verification results indicate that the target function is available, determine the target token bucket corresponding to the current tenant; Determine the number of tokens remaining in the target token bucket; If the number of remaining tokens meets the preset requirement, determine the access control level of the target function; Based on the access control level, proceed to one of the following instruction generation processes: When the access control level is set to "no authorization required", generate scheduling instructions for the target function; When the access control level is set to the authorization-required level, an authorization prompt message is generated; in response to the authorization confirmation operation for the authorization prompt message, a scheduling instruction for the target function is generated. When the access control level is set to the paid level, a payment prompt message is generated; in response to the payment confirmation operation for the payment prompt message, a scheduling instruction for the target function is generated.

[0182] In this embodiment of the disclosure, when actually generating scheduling instructions for the target function, the following can be done: If the target function is a composite function, obtain complete description information of the target function; Based on the complete description information of the target function, generate scheduling instructions for the target function.

[0183] Step S706-11: Increment the number of loops for the current user message processing flow by 1, and return to step S706-1.

[0184] For the specific functions and examples of the above steps, please refer to the relevant descriptions of the corresponding steps in the aforementioned message processing method embodiments, which will not be repeated here.

[0185] Please see Figure 8 This diagram illustrates an application scenario of a message processing method provided in this embodiment. The message processing method can be executed by a scheduling layer, and the scheduling layer can be applied to an electronic device. Here, the electronic device can be a service device, such as a server, workbench, mainframe computer, or other similar computing device.

[0186] In this embodiment of the disclosure, the electronic device is used for: In response to the received current user message, the current user message is written to the event stream file of the current session; the event stream file is managed by the sourcing layer and persisted in an append-only manner; Based on the event stream file, the system enters the processing flow for the current user's message to obtain the processing result. The processing flow includes: Construct session reference information based on event stream files; The model response results are obtained by utilizing the main intelligent agent and based on the session reference information; If the model response result does not include function scheduling information, the model response result will be used as the current message processing result. Alternatively, if the model response result includes function scheduling information, in the execution layer, the N functions to be executed as indicated by the function scheduling information are executed to obtain N function execution results corresponding one-to-one with the N functions to be executed; where N≥1 and N is an integer; the N function execution results are used to obtain the current message processing result.

[0187] It should be noted that, in the embodiments disclosed herein, Figure 8 The application scenario diagrams shown are for illustrative purposes only and are not restrictive. Those skilled in the art can use them as a basis for their own interpretation. Figure 8 The examples may be modified in various obvious ways and / or substitutions, and the resulting technical solutions still fall within the scope of the disclosure of the embodiments of this disclosure.

[0188] To better implement the message processing method, embodiments of this disclosure also provide a message processing apparatus, which can be applied to an electronic device. The electronic device can be a service device, such as a server, workbench, mainframe computer, or other similar computing device. The following will be combined with... Figure 9 The schematic block diagram shown illustrates a message processing apparatus 900 provided in a disclosed embodiment.

[0189] In this embodiment of the disclosure, the message processing device 900 includes: The message receiving unit 901 is used to write the current user message into the event stream file of the current session in response to the received current user message; wherein the event stream file is managed by the sourcing layer and is persistently stored in an append-only manner; The message processing unit 902 is used to enter the processing flow for the current user message based on the event stream file to obtain the current message processing result; wherein the processing flow includes: Construct session reference information based on event stream files; The model response results are obtained by utilizing the main intelligent agent and based on the session reference information; If the model response result does not include function scheduling information, the model response result will be used as the current message processing result. Alternatively, if the model response result includes function scheduling information, in the execution layer, the N functions to be executed as indicated by the function scheduling information are executed to obtain N function execution results corresponding one-to-one with the N functions to be executed; where N≥1 and N is an integer; the N function execution results are used to obtain the current message processing result.

[0190] In some alternative implementations, the message processing unit 902 is used for: Based on the event stream file, multiple target event streams are determined; wherein, the multiple target event streams include at least one of system message event stream, user message event stream, message digest event stream, model response event stream, and function execution event stream; the user message event stream is appended with user message events generated based on the current user message; The session reference information is constructed based on the multiple target event streams.

[0191] In some alternative embodiments, the message processing apparatus 900 further includes a summary processing unit for: Get the session resource consumption related to the current user's message; If the session resource consumption meets the resource over-limit determination criteria, perform digest processing on the current user message to obtain the current message digest; Based on the current message digest, a message digest event is generated to be appended to the message digest event stream of the event stream file.

[0192] In some optional implementations, the summary processing unit is used for: Determine the amount of resources consumed in the current session; Get the predicted resource consumption for the current user message; Based on the amount of resources already consumed and the predicted amount of resources to be consumed, the session resource consumption related to the current user message is obtained.

[0193] In some alternative implementations, the message processing unit 902 is used for: From the assembly layer, obtain the first functional information; wherein, the first functional information is used to list multiple individual functions; From the assembly layer, obtain the second functional information; wherein, the second functional information is used to list multiple composite functions and includes a brief description of each composite function; Based on the first and second functional information, construct a complete system prompt; Using the main intelligent agent, following the complete system prompts and based on the session reference information, the model response results are obtained.

[0194] In some alternative implementations, the message processing unit 902 is used for: From the assembly layer, obtain all public prompt information; among which, the full public prompt information includes at least one of the following: safety red line information, operation rule information, and intelligent agent personality information; From the assembly layer, all user prompts are loaded; the full set of user prompts includes first function information and second function information, as well as at least one of the current user's profile information and long-term memory content; the current user is the user who initiated the current session. Based on all public and user prompts, a complete system prompt is constructed.

[0195] In some alternative implementations, the message processing unit 902 is used for: Using the main intelligent agent, following the complete system prompts and based on the session reference information, we obtain the model response results that do not include function scheduling information; Alternatively, by utilizing the main intelligent agent and following the complete system prompts, based on the session reference information, the model response result can be obtained, including at least one of the following: Using the main intelligent agent, following the complete system prompts and based on the session reference information, the model response results, including function scheduling information, are obtained; Using the main agent, following the complete system prompts and based on the session reference information, generate M tasks to be executed and determine the derivative agents corresponding to each of the M tasks to be executed; for each of the M tasks to be executed, use the derivative agents corresponding to the task to be executed to obtain the model response result for the task to be executed, including the function scheduling information; where M≥1 and M is an integer.

[0196] In some alternative implementations, the message processing unit 902 is used for: Determine the nature of the task to be performed; Based on the nature of the task, construct concise system prompts; Using the derived agent corresponding to the task to be executed, and following the brief system prompts, the model response result for the task to be executed, including functional scheduling information, is obtained.

[0197] In some alternative implementations, the message processing unit 902 is used for: In the case of a skill-based task, obtain all public prompts from the assembly layer; the full set of public prompts includes at least one of the following: safety red line information, operational rule information, and agent personality information. Obtain the first functional information and the second functional information from the assembly layer; Based on the full set of public prompts, primary function information, and secondary function information, a concise system prompt is constructed.

[0198] In some alternative implementations, the message processing unit 902 is used for: In the case of a tool-type task, obtain the agent's personality information from the assembly layer; Obtain the first functional information from the assembly layer; Based on the agent's personality information and primary function information, a brief system prompt is constructed.

[0199] In some alternative implementations, the message processing apparatus 900 further includes an event logging unit for: Based on the complete system prompt, generate system message events to append system message events to the system message event stream stored in the event stream file; Based on brief system prompts, system message events are generated and appended to the system message event stream stored in the event stream file. Based on the model response results, model response events are generated and appended to the model response events stored in the event stream file.

[0200] In some alternative implementations, the message processing unit 902 is used for: Take each of the N functions to be executed indicated by the function scheduling information as the target function and generate a scheduling instruction for the target function. In the execution layer, the target function is executed based on the scheduling instructions to obtain the function execution result corresponding to the target function; Based on the function execution result corresponding to the target function, a function execution event is generated, and the function execution event is appended to the function execution event stream stored in the event stream file.

[0201] In some alternative implementations, the message processing unit 902 is used for: Perform a whitelist check on the target function and obtain the check results; If the verification results indicate that the target function is available, a scheduling instruction for the target function is generated.

[0202] In some alternative implementations, the message processing unit 902 is used for: Determine the target token bucket corresponding to the current tenant; where the target token bucket is a rate limiting tool built for scheduling target functions for the current tenant; the current tenant is the organizational entity to which the current user belongs; the current user is the user who initiated the current session; Determine the number of tokens remaining in the target token bucket; If the number of remaining tokens meets the preset requirement, a scheduling instruction for the target function is generated.

[0203] In some alternative implementations, the message processing unit 902 is used for: Determine the access control level for the target function; Based on the access control level, proceed to one of the following instruction generation processes: When the access control level is set to "no authorization required", generate scheduling instructions for the target function; When the access control level is set to the authorization-required level, an authorization prompt message is generated; in response to the authorization confirmation operation for the authorization prompt message, a scheduling instruction for the target function is generated. When the access control level is set to the paid level, a payment prompt message is generated; in response to the payment confirmation operation for the payment prompt message, a scheduling instruction for the target function is generated.

[0204] In some alternative implementations, the message processing unit 902 is used for: If the target function is a composite function, obtain complete description information of the target function; Based on the complete description information of the target function, generate scheduling instructions for the target function.

[0205] In some optional embodiments, the message processing apparatus 900 further includes an information loading unit for: If the current user message contains a suggestion function, and the suggestion function is a composite function, obtain the complete description information of the suggestion function from the assembly layer; Based on the complete description information of the suggested function, a lazy loading unload record event is generated to be appended to the lazy loading unload record event stream stored in the event stream file.

[0206] Message processing unit 902 is used for: When the target function and the suggested function are the same function, obtain the complete description information of the suggested function from the event stream file and use it as the complete description information of the target function.

[0207] In some alternative implementations, the message receiving unit 901 is used for: From the current user's long-term memory, identify key memory content related to the current user's message; where the current user is the user who initiated the current session. Generate a new current user message based on the current user message and key memory content; Based on the new current user message, a user message event is generated to be appended to the user message event stream stored in the event stream file.

[0208] In some alternative implementations, the message processing apparatus 900 further includes a memory update unit for: Extract valuable memories from current user messages; The system updates the user's long-term memory based on valuable memories.

[0209] In some alternative implementations, the event stream file is persistently stored on the target storage device in an append-only manner; The message processing apparatus 900 also includes a crash response processing unit, used to: before entering the processing flow for the current user message based on the event stream file to obtain the current message processing result: After a process crash occurs at the scheduling layer, in response to the scheduling layer's restart operation, the event stream file is read from the target storage device.

[0210] In this embodiment of the disclosure, the specific functions and examples of each unit in the message processing device 900 can be found in the relevant descriptions of the corresponding steps in the aforementioned message processing method embodiments, and will not be repeated here.

[0211] In this disclosed embodiment, the acquisition, storage, and application of user personal information are all known to the user and have been agreed to by the user, and all comply with the provisions of relevant laws and regulations, and do not violate public order and good morals.

[0212] According to embodiments of this disclosure, this disclosure also provides an electronic device, a readable storage medium, and a computer program product.

[0213] Figure 10 A schematic structural block diagram of an example electronic device 1000 that can be used to implement embodiments of the present disclosure is shown. The electronic device 1000 is intended to represent various forms of digital computers, such as in-vehicle computing devices, laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device 1000 may also represent various forms of mobile devices, such as personal digital assistants, cellular phones, smartphones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely illustrative and are not intended to limit the implementation of the present disclosure described and / or claimed herein.

[0214] like Figure 10As shown, the electronic device 1000 includes a computing unit 1001, which can perform various appropriate actions and processes based on a computer program stored in a read-only memory (ROM) 1002 or a computer program loaded from a storage unit 1008 into a random access memory (RAM) 1003. The RAM 1003 may also store various programs and data required for the operation of the electronic device 1000. The computing unit 1001, ROM 1002, and RAM 1003 are interconnected via a bus 1004. An input / output (I / O) interface 1005 is also connected to the bus 1004.

[0215] Multiple components in electronic device 1000 are connected to I / O interface 1005, including: input unit 1006, such as keyboard, mouse, etc.; output unit 1007, such as various types of renderers, speakers, etc.; storage unit 1008, such as disk, optical disk, etc.; and communication unit 1009, such as network card, modem, wireless transceiver, etc. Communication unit 1009 allows electronic device 1000 to exchange information / data with other devices through computer networks such as the Internet and / or various telecommunications networks.

[0216] The computing unit 1001 can be a variety of general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of the computing unit 1001 include, but are not limited to, a central processing unit (CPU), a GPU, various special-purpose artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, a digital signal processor (DSP), and any suitable processor, controller, microcontroller, etc. The computing unit 1001 performs the methods and processes described above, such as message processing methods. For example, in some embodiments, the message processing method may be implemented as a computer software program tangibly contained in a machine-readable medium, such as storage unit 1008. In some embodiments, part or all of the computer program may be loaded and / or installed on the electronic device 1000 via ROM 1002 and / or communication unit 1009. When the computer program is loaded into RAM 1003 and executed by the computing unit 1001, one or more steps of the message processing methods described above may be performed. Alternatively, in other embodiments, the computing unit 1001 may be configured as a message processing method by any other suitable means (e.g., by means of firmware).

[0217] Various embodiments of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field-programmable gate arrays (FPGAs), application-specific integrated circuits (ASICs), application-specific standard products (ASSPs), systems-on-chip (SOCs), complex programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments may include implementations in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which may be a dedicated or general-purpose programmable processor, capable of receiving data and instructions from a storage system, at least one input device, and at least one output device, and transferring data and instructions to the storage system, the at least one input device, and the at least one output device.

[0218] The program code used to implement the methods of this disclosure may be written in any combination of one or more programming languages. This program code may be provided to a processor or controller of a general-purpose computer, special-purpose computer, or other programmable data optimization device, such that when executed by the processor or controller, the program code causes the functions / operations specified in the flowcharts and / or block diagrams to be implemented. The program code may be executed entirely on a machine, partially on a machine, as a standalone software package partially on a machine and partially on a remote machine, or entirely on a remote machine or server.

[0219] In the context of this disclosure, a machine-readable medium can be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, apparatus, or device. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can be, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, RAM, ROM, erasable programmable read-only memory (EPROM) or flash memory, optical fibers, compact disc read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.

[0220] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a rendering device (e.g., a cathode ray tube (CRT) renderer or a liquid crystal display (LCD)) for rendering information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user provides input to the computer. Other types of devices are also used to provide interaction with the user; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including sound input, voice input, or tactile input).

[0221] The systems and technologies described herein can be implemented in computing systems that include back-end components (e.g., as a data server), or computing systems that include middleware components (e.g., an application server), or computing systems that include front-end components (e.g., a user computer with a graphical user interface or web browser through which a user can interact with implementations of the systems and technologies described herein), or any combination of such back-end, middleware, or front-end components. The components of the system can be interconnected via digital data communication of any form or medium (e.g., a communication network). Examples of communication networks include local area networks (LANs), wide area networks (WANs), and the Internet.

[0222] A computer system can include client and server components. Clients and servers are generally located far apart and typically interact via a communication network. The client-server relationship is created by computer programs running on the respective computers and having a client-server relationship with each other. The server can be a cloud server, a server in a distributed system, or a server incorporating blockchain technology.

[0223] This disclosure also provides a non-transitory computer-readable storage medium storing computer instructions, wherein the computer instructions are used to cause a computer to perform a message processing method.

[0224] This disclosure also provides a computer program product, including a computer program that implements a message processing method when executed by a processor.

[0225] It should be understood that the various forms of processes shown above can be used to rearrange, add, or delete steps. For example, the steps described in this disclosure can be executed in parallel, sequentially, or in different orders, as long as the desired result of the technical solution disclosed in this disclosure is achieved, and this is not limited herein. Furthermore, in this disclosure, relational terms such as "first," "second," and "third" are used merely 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. Additionally, "multiple" in this disclosure can be understood as at least two.

[0226] The specific embodiments described above do not constitute a limitation on the scope of protection of this disclosure. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the principles of this disclosure should be included within the scope of protection of this disclosure.

Claims

1. A message processing method, comprising: In response to a received current user message, the current user message is written to the event stream file of the current session; wherein the event stream file is managed by the tracing layer and persistently stored in an append-only manner; Based on the event stream file, the processing flow for the current user message is entered to obtain the current message processing result; wherein, the processing flow includes: Based on the event stream file, session reference information is constructed; Using the main intelligent agent, the model response result is obtained based on the session reference information; If the model response result does not include function scheduling information, the model response result shall be used as the current message processing result; Alternatively, if the model response result includes function scheduling information, in the execution layer, the N functions to be executed as indicated by the function scheduling information are executed to obtain N function execution results corresponding one-to-one with the N functions to be executed; wherein, N≥1 and N is an integer; the N function execution results are used to obtain the current message processing result.

2. The method according to claim 1, wherein, The process of constructing session reference information based on the event stream file includes: Based on the event stream file, multiple target event streams are determined; wherein, the multiple target event streams include at least one of system message event stream, user message event stream, message digest event stream, model response event stream, and function execution event stream; the user message event stream is appended with user message events generated based on the current user message; The session reference information is constructed based on the multiple target event streams.

3. The method according to claim 2, further comprising: Obtain the session resource consumption related to the current user message; If the session resource consumption meets the resource over-limit determination condition, the current user message is digested to obtain the current message digest; Based on the current message digest, a message digest event is generated to be appended to the message digest event stream of the event stream file.

4. The method according to claim 3, wherein, The step of obtaining the session resource consumption related to the current user message includes: Determine the amount of resources consumed in the current session; Obtain the predicted resource consumption for the current user message; Based on the amount of resources already consumed and the predicted amount of resources consumed, the session resource consumption related to the current user message is obtained.

5. The method according to claim 1, wherein, The process of obtaining the model response result using the main intelligent agent based on the session reference information includes: First functional information is obtained from the assembly layer; wherein, the first functional information is used to list multiple individual functions; Second functional information is obtained from the assembly layer; wherein, the second functional information is used to list multiple composite functions and includes a brief description of each composite function; Based on the first functional information and the second functional information, a complete system prompt is constructed; Using the main intelligent agent, following the complete system prompts, and based on the session reference information, the model response result is obtained.

6. The method according to claim 5, wherein, The construction of a complete system prompt based on the first functional information and the second functional information includes: From the assembly layer, obtain all public prompt information; wherein, the full amount of public prompt information includes at least one of safety red line information, operation rule information, and intelligent agent personality information; From the assembly layer, all user prompt information is loaded; wherein, the full user prompt information includes the first function information and the second function information, as well as at least one of the current user's profile information and long-term memory content; the current user is the user who initiated the current session; Based on the full set of public prompts and the full set of user prompts, the complete system prompts are constructed.

7. The method according to claim 5, wherein, The step of obtaining the model response result by utilizing the main intelligent agent, following the complete system prompts, and based on the session reference information, includes: Using the main intelligent agent, following the complete system prompts, and based on the session reference information, a model response result excluding function scheduling information is obtained; Alternatively, using the main intelligent agent, following the complete system prompts and based on the session reference information, the model response result is obtained, including at least one of the following: Using the main intelligent agent, following the complete system prompts, and based on the session reference information, a model response result including function scheduling information is obtained; Using the main agent, following the complete system prompts and based on the session reference information, generate M tasks to be executed and determine the derivative agents corresponding to each of the M tasks to be executed; for each of the M tasks to be executed, use the derivative agents corresponding to the task to be executed to obtain the model response result for the task to be executed, including function scheduling information; where M≥1 and M is an integer.

8. The method according to claim 7, wherein, The step of utilizing a derived agent corresponding to the task to be executed to obtain a model response result for the task to be executed, including functional scheduling information, includes: Determine the nature of the task to be executed; Based on the nature of the task, a brief system prompt is constructed; Using the derived agent corresponding to the task to be executed, and following the brief system prompts, a model response result for the task to be executed, including functional scheduling information, is obtained.

9. The method according to claim 8, wherein, The construction of a brief system prompt based on the nature of the task includes: When the task is a skill-based task, all public prompt information is obtained from the assembly layer; wherein, the all public prompt information includes at least one of safety red line information, operation rule information, and agent personality information; The first functional information and the second functional information are obtained from the assembly layer; Based on the full set of public prompts, the first functional information, and the second functional information, the brief system prompt is constructed.

10. The method according to claim 8, wherein, The construction of a brief system prompt based on the nature of the task includes: When the task is a tool-type task, the agent's personality information is obtained from the assembly layer; Obtain the first functional information from the assembly layer; Based on the agent's personality information and the first functional information, the brief system prompt is constructed.

11. The method of claim 8, further comprising at least one of the following: Based on the complete system prompt, a system message event is generated, and the system message event is appended to the system message event stream stored in the event stream file; Based on the brief system prompt, a system message event is generated and appended to the system message event stream stored in the event stream file; Based on the model response results, a model response event is generated, and the model response event is appended to the model response event stream stored in the event stream file.

12. The method according to any one of claims 1 to 11, wherein, In the execution layer, the N functions to be executed as indicated by the function scheduling information are executed to obtain N function execution results corresponding one-to-one with the N functions to be executed, including: Take each of the N functions to be executed indicated by the function scheduling information as the target function, and generate a scheduling instruction for the target function; In the execution layer, the target function is executed based on the scheduling instruction to obtain the function execution result corresponding to the target function; The method further includes: Based on the function execution result corresponding to the target function, a function execution event is generated, and the function execution event is appended to the function execution event stream stored in the event stream file.

13. The method according to claim 12, wherein, The generation of scheduling instructions for the target function includes: The target function is then subjected to a whitelist verification to obtain the verification result. If the verification result indicates that the target function is available, a scheduling instruction for the target function is generated.

14. The method according to claim 12, wherein, The generation of scheduling instructions for the target function includes: Determine the target token bucket corresponding to the current tenant; wherein, the target token bucket is a rate limiting tool built for scheduling target functions for the current tenant; the current tenant is the organizational entity to which the current user belongs; the current user is the user who initiated the current session; Determine the number of remaining tokens in the target token bucket; If the number of remaining tokens meets the preset requirement, a scheduling instruction for the target function is generated.

15. The method according to claim 12, wherein, The generation of scheduling instructions for the target function includes: Determine the access control level for the target function; Based on the aforementioned access control level, proceed to one of the following instruction generation processes: When the access control level is set to "no authorization required", a scheduling instruction for the target function is generated. When the access control level is the authorization-required level, an authorization prompt message is generated; in response to the authorization confirmation operation for the authorization prompt message, a scheduling instruction for the target function is generated; When the access control level is a paid level, a payment prompt message is generated; in response to the payment confirmation operation for the payment prompt message, a scheduling instruction for the target function is generated.

16. The method according to claim 12, wherein, The generation of scheduling instructions for the target function includes: If the target function is a composite function, obtain complete description information of the target function; Based on the complete description information of the target function, a scheduling instruction for the target function is generated.

17. The method of claim 16, further comprising: If a suggestion function exists in the current user message and the suggestion function is a composite function, obtain the complete description information of the suggestion function from the assembly layer; Based on the complete description information of the suggested function, a lazy loading expand record event is generated, and the lazy loading expand record event is appended to the lazy loading expand record event stream stored in the event stream file; The acquisition of complete descriptive information for the target function includes: If the target function and the suggested function are the same function, the complete description information of the suggested function is obtained from the event stream file and used as the complete description information of the target function.

18. The method according to claim 1, wherein, The step of writing the current user message to the event stream file of the current session includes: From the current user's long-term memory, determine key memory content related to the current user's message; wherein, the current user is the user who initiated the current session; Based on the current user message and the key memory content, generate a new current user message; Based on the new current user message, a user message event is generated to be appended to the user message event stream stored in the event stream file.

19. The method of claim 18, further comprising: Extract valuable memory content from the current user messages; Based on the valuable memory content, the long-term memory content of the current user is updated.

20. The method according to claim 1, wherein, The method is executed by the scheduling layer; the event stream file is persistently stored in the target storage device in an append-only manner; Before proceeding with the processing flow for the current user message based on the event stream file to obtain the current message processing result, the method further includes: After a process crash occurs in the scheduling layer, the event stream file is read from the target storage device in response to the restart operation of the scheduling layer.

21. A message processing apparatus, comprising: The message receiving unit is used to respond to a received current user message by writing the current user message into the event stream file of the current session; wherein the event stream file is managed by the tracing layer and persistently stored in an append-only manner; A message processing unit is configured to, based on the event stream file, enter a processing flow for the current user message to obtain the current message processing result; wherein, the processing flow includes: Based on the event stream file, session reference information is constructed; Using the main intelligent agent, the model response result is obtained based on the session reference information; If the model response result does not include function scheduling information, the model response result shall be used as the current message processing result; Alternatively, if the model response result includes function scheduling information, in the execution layer, the N functions to be executed as indicated by the function scheduling information are executed to obtain N function execution results corresponding one-to-one with the N functions to be executed; wherein, N≥1 and N is an integer; the N function execution results are used to obtain the current message processing result.

22. An electronic device, comprising: At least one processor; A memory that is communicatively connected to the at least one processor; The memory stores instructions that can be executed by the at least one processor, which, when executed by the at least one processor, enables the at least one processor to perform the method according to any one of claims 1 to 20.

23. A non-transitory computer-readable storage medium storing computer instructions, wherein, The computer instructions are used to cause the computer to perform the method according to any one of claims 1 to 20.

24. A computer program product comprising a computer program; wherein, When the computer program is executed by a processor, it can implement the method of any one of claims 1 to 20.