Multi-agent shared memory collaborative knowledge retrieval system, method, device and medium
Patent Information
- Application Number
- CN202611133344.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-07-29
- Publication Date
- 2026-10-27
AI Technical Summary
[0003]本申请提供了一种多智能体共享记忆协作知识检索系统、方法、设备及介质,以至少解决相关技术中多智能体知识检索场景下智能体间信息传递低效、记忆无分层管理且无法自动实现跨任务知识复用的问题
[0035]通过本申请,智能体完成任务步骤后自动将任务结果发布到共享记忆模块,其他智能体通过通配符订阅或主动查询获取所需信息。为各智能体配置三级联动记忆结构,三级联动记忆结构之间通过提升流、压缩流、归并流和注入流实现数据联动,其中注入流在新任务开始时从长期记忆语义检索相关历史经验并注入工作记忆,使智能体具备从经验中学习的能力,实现分层存储管控与跨任务语义知识自主复用,有效解决多智能体信息传递低效、记忆管理缺失分层、无法自动复用历史经验的架构缺陷。
Smart Images

Figure CN122985449A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and in particular to a multi-agent shared memory collaborative knowledge retrieval system, method, device and medium. Background Technology
[0002] Currently, the mainstream implementation methods for multi-agent collaborative knowledge retrieval include sequential transmission mode, group chat interaction mode, and centralized scheduling mode. Sequential transmission mode relies on a predefined fixed data stream to complete information exchange between agents, and cannot adaptively adjust the information transmission path when the task flow changes dynamically. Group chat interaction mode relies on a large language model dialogue context to complete information exchange; each agent needs to completely read the entire dialogue history, and the token consumption for information exchange increases linearly with the number of agents, resulting in low transmission efficiency. Centralized scheduling mode uses orchestration nodes to uniformly forward all interaction data, which easily creates single-point performance bottlenecks and increases interaction latency. At the memory management level, existing single-agent memory management solutions can only serve independent agents and cannot achieve memory data sharing between multiple agents. Furthermore, existing memory systems only divide memory into two layers or have no hierarchical distinction, lacking a layered memory structure adapted to three different access scenarios: high-frequency reading and writing, semantic retrieval, and temporal dialogue backtracking. The memory storage granularity is coarse, making it difficult to achieve fine-grained semantic similarity retrieval. Existing memory mechanisms only support temporary context storage within a task, unable to complete cross-task knowledge accumulation and reuse, and lack automated memory flow logic to migrate historical experience to new tasks. Existing memory-sharing frameworks rely solely on passive methods of retrieving and enhancing context to supplement information. They cannot enable agents to actively publish or query memories on demand, lack wildcard routing and historical memory backtracking capabilities, rely on large model reasoning for information transmission, and the transmission results are not deterministic, resulting in high interaction latency. Summary of the Invention
[0003] This application provides a multi-agent shared memory collaborative knowledge retrieval system, method, device, and medium to at least solve the problems of inefficient information transfer between agents, lack of hierarchical memory management, and inability to automatically achieve cross-task knowledge reuse in multi-agent knowledge retrieval scenarios in related technologies.
[0004] This application provides a multi-agent collaborative knowledge retrieval system with shared memory, including:
[0005] The agent management module includes multiple agents, each with an independent reasoning-action loop, responsible for executing assigned task steps;
[0006] The shared memory module is used for passing in-process messages for collaboration between agents;
[0007] The orchestration and execution module is used to receive user query tasks, decompose the user query tasks into task steps with dependencies, perform topological sorting of the task steps based on a directed acyclic graph, schedule each agent to execute each task step in parallel according to the step dependencies, synthesize the task results of all task steps into the final answer and output it.
[0008] A three-level linked memory unit is used to maintain a three-level linked memory structure in each intelligent entity. The three-level linked memory structure realizes data linkage through a boosting stream, a compression stream, a merging stream, and an injection stream. The three-level linked memory structure includes a working memory subunit, a long-term memory subunit, and a dialogue memory subunit. The working memory subunit is used to cache the temporary intermediate state of the current task. The long-term memory subunit is used to persistently store cross-task reused knowledge. The dialogue memory subunit is used to store the dialogue temporal context of the current session. The boosting stream is used to migrate and write the high-value entries marked by the working memory subunit along with their embedding vectors into the long-term memory subunit. The compression stream is used to compress entries and generate summary text when the dialogue memory subunit exceeds a threshold, and write the summary text along with the embedding vectors into the long-term memory subunit. The merging stream is used to automatically merge low-access frequency and long-term unaccessed entries in the long-term memory subunit at a preset period to release storage resources. The injection stream is used to retrieve matching reused knowledge from the long-term memory subunit according to the current query semantics at the beginning of a new task step, and inject the reused knowledge into the working memory subunit.
[0009] Furthermore, the multiple intelligent agents in the intelligent agent management module include:
[0010] Research intelligent agents for performing knowledge base retrieval and web search;
[0011] A writing agent used to generate structured documents based on research findings;
[0012] A review agent is used to evaluate the quality of generated content and provide suggestions for improvement.
[0013] An orchestration agent is used to synthesize the results of subtasks and generate the final output.
[0014] Furthermore, the shared memory module includes:
[0015] The publishing interface is used to publish the task result to the shared memory module in key-value pairs after the agent completes the task, and to mark the source agent identifier and step context.
[0016] The subscription interface is used by the agent to subscribe to specific keys or wildcard patterns, and triggers a callback when a new message is published for the matching key; the wildcard patterns include key exact match, prefix wildcard match, and global wildcard match; the subscription interface also supports filtering by source agent type, enabling agents to filter messages based on the semantics of collaborative roles;
[0017] The active query interface is used by the agent to actively query all published memories from a specified source or prefix, so that agents that join later can obtain historical messages.
[0018] Furthermore, each memory entry in the shared memory module includes an optional lifetime parameter, and expired memory entries are automatically removed; the publishing interface supports setting lifetime parameter values.
[0019] Furthermore, the multi-agent shared memory collaborative knowledge retrieval system also includes:
[0020] The session concurrency control module is used to limit the maximum number of concurrent sessions through semaphores, and queue session requests that exceed the concurrency limit in an asynchronous queue. Each session is assigned a unique identifier and its status is tracked from creation, planning, execution to completion or failure, and the states between sessions are isolated.
[0021] Furthermore, the multi-agent shared memory collaborative knowledge retrieval system also includes:
[0022] The human-machine collaborative approval module is used to classify all tools available to the intelligent agent into safe tools and dangerous tools according to their risk levels. When the execution of a task step by the intelligent agent includes the use of a dangerous tool, the execution is paused before reaching that task step, and a structured approval request is generated. The task step is continued or skipped after human approval or rejection. The approval result is recorded in the long-term memory subunit for reference in subsequent task steps.
[0023] Furthermore, the multi-agent shared memory collaborative knowledge retrieval system also includes:
[0024] The structured execution tracing module records the input summary, output summary, execution time, and responsible agent type for each task step, with the smallest tracing granularity as the individual task step. It links the trajectories of all task steps in the same session to form an execution network using a unified identifier. The tracing data for each task step is stored in a lightweight data exchange format, supporting multi-dimensional querying and aggregation analysis by agent type, time range, and session identifier.
[0025] This application also provides a multi-agent collaborative knowledge retrieval method with shared memory, including:
[0026] The system receives user query tasks, decomposes the user query tasks into task steps containing dependencies, performs topological sorting of the task steps based on a directed acyclic graph, and schedules each agent to execute each task step in parallel according to the step dependencies.
[0027] After the agent completes the task steps, the task result is published to the shared memory module in the form of key-value pairs, and the source agent identifier and step context are marked.
[0028] Obtain the task results of previous task steps by actively querying or subscribing to callbacks;
[0029] When a new task step begins, the reusable knowledge that matches the current query semantics is retrieved from the long-term memory subunit and the reusable knowledge is injected into the working memory subunit.
[0030] When the task step is completed, the high-value entries marked in the working memory subunit are written into the long-term memory subunit along with their embedded vectors.
[0031] When the dialogue memory subunit exceeds the threshold, the entries are compressed to generate summary text, and the summary text carrying the embedding vector is written into the long-term memory subunit.
[0032] Once all task steps are completed, combine the results of all task steps into the final answer and output it.
[0033] This application also provides an electronic device, including: a memory for storing a computer program; and a processor for executing the computer program to implement the steps of any of the above-described multi-agent shared memory collaborative knowledge retrieval methods.
[0034] This application also provides a computer-readable storage medium storing a computer program, wherein when the computer program is executed by a processor, it implements the steps of any of the above-described multi-agent shared memory collaborative knowledge retrieval methods.
[0035] Through this application, after an agent completes a task step, it automatically publishes the task result to the shared memory module. Other agents can obtain the required information by subscribing using wildcards or actively querying. A three-level linked memory structure is configured for each agent. Data linkage between the three levels of linked memory structures is achieved through boosting streams, compressing streams, merging streams, and injection streams. The injection stream, at the start of a new task, retrieves relevant historical experience from long-term memory semantics and injects it into working memory, enabling the agent to learn from experience. This achieves hierarchical storage management and autonomous reuse of semantic knowledge across tasks, effectively solving architectural defects such as inefficient information transmission among multiple agents, lack of hierarchical memory management, and inability to automatically reuse historical experience. Attached Figure Description
[0036] To more clearly illustrate the embodiments of this application, the accompanying drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0037] Figure 1 This is a structural block diagram of a multi-agent shared memory collaborative knowledge retrieval system in one embodiment of this application;
[0038] Figure 2 This is a flowchart illustrating a multi-agent shared memory collaborative knowledge retrieval method in one embodiment of this application;
[0039] Figure 3 This is an internal structural diagram of a computer device in one embodiment of this application. Detailed Implementation
[0040] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the protection scope of this application.
[0041] It should be noted that, in the description of this application, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. The terms "first," "second," etc., in this application are used to distinguish similar objects and are not used to describe a specific order or sequence.
[0042] To enable those skilled in the art to better understand the present application, the present application will be further described in detail below with reference to the accompanying drawings and specific embodiments.
[0043] like Figure 1 As shown, embodiments of this application provide a multi-agent shared memory collaborative knowledge retrieval system, including:
[0044] The agent management module includes multiple agents, each with an independent reasoning-action loop, responsible for executing assigned task steps;
[0045] The shared memory module is used for passing in-process messages for collaboration between agents;
[0046] The orchestration and execution module is used to receive user query tasks, decompose the user query tasks into task steps with dependencies, perform topological sorting of the task steps based on a directed acyclic graph, schedule each agent to execute each task step in parallel according to the step dependencies, synthesize the task results of all task steps into the final answer and output it.
[0047] A three-level linked memory unit is used to maintain a three-level linked memory structure in each intelligent entity. The three-level linked memory structure realizes data linkage through a boosting stream, a compression stream, a merging stream, and an injection stream. The three-level linked memory structure includes a working memory subunit, a long-term memory subunit, and a dialogue memory subunit. The working memory subunit is used to cache the temporary intermediate state of the current task. The long-term memory subunit is used to persistently store cross-task reused knowledge. The dialogue memory subunit is used to store the dialogue temporal context of the current session. The boosting stream is used to migrate and write the high-value entries marked by the working memory subunit along with their embedding vectors into the long-term memory subunit. The compression stream is used to compress entries and generate summary text when the dialogue memory subunit exceeds a threshold, and write the summary text along with the embedding vectors into the long-term memory subunit. The merging stream is used to automatically merge low-access frequency and long-term unaccessed entries in the long-term memory subunit at a preset period to release storage resources. The injection stream is used to retrieve matching reused knowledge from the long-term memory subunit according to the current query semantics at the beginning of a new task step, and inject the reused knowledge into the working memory subunit.
[0048] The three-level linkage memory unit maintains a three-level linkage memory structure in each intelligent body, and each level is specially optimized for different access modes, as shown in Table 1.
[0049] Table 1
[0050] Memory hierarchy Capacity limit Elimination strategy Search methods Application scenarios Working memory 200 items Time-to-Live (TTL) Expiration + Priority Elimination Key-value direct reading Current task intermediate state Long-term memory 2000 items Access frequency merging + Time to Live (TTL) Embedded Vector Semantic Search Cross-task knowledge reuse Conversation memory 50 items Automatic Threshold Compression Time series traversal Current session context
[0051] Specifically, Promotion Flow: When a task is completed, entries marked as "high value" (such as important information marked by AI reviewers) in working memory are automatically written into long-term memory, along with embedding vectors for subsequent semantic retrieval.
[0052] Compression Flow: When the dialogue memory exceeds 30 entries, the first half of the dialogue is automatically compressed into a summary text, which is simultaneously stored in long-term memory (carrying an embedding vector), so that the semantic information of the dialogue can be retrieved in subsequent tasks.
[0053] Consolidation Flow: Long-term memory performs automatic merging after every 100 rounds of tasks. Entries that have been accessed less than twice and have not been accessed for more than 30 days are merged into a summary to free up storage space.
[0054] Injection Flow: When a new task begins, the system automatically retrieves the Top-5 relevant memories from long-term memory according to the current query semantics and injects them into working memory with the [relevant historical experience] label prefix, so that the agent's initial decision-making benefits from historical learning.
[0055] Furthermore, the multiple intelligent agents in the intelligent agent management module include:
[0056] Research agents are used to perform knowledge base retrieval and web searches.
[0057] WriterAgent is used to generate structured documents based on research findings.
[0058] The CriticAgent is used to evaluate the quality of generated content and provide suggestions for improvement.
[0059] The OrchestratorAgent is used to synthesize the results of subtasks and generate the final output.
[0060] Furthermore, the shared memory module includes:
[0061] The publishing interface is used to publish the task results to the shared memory module in key-value pairs after the agent completes the task, and to mark the source agent identifier (source) and step context (step_context).
[0062] The subscription interface is used by the agent to subscribe to specific keys or wildcard patterns, and triggers a callback when a new message is published for the matching key; the wildcard patterns include key exact match, prefix wildcard match (prefix:*) and global wildcard match (*); the subscription interface also supports filtering by source agent type, so that the agent can filter messages according to the semantics of the collaborating role;
[0063] The active query interface is used by the agent to actively query all published memories from a specified source or prefix, so that agents that join later can obtain historical messages.
[0064] The shared memory module enables publish-subscribe decoupling: publishers do not need to know the identities of subscribers, subscribers can join or leave at any time, and dynamic agent collaboration topology is supported.
[0065] Furthermore, each memory entry in the shared memory module includes an optional Time-to-Live (TTL) parameter, and expired memory entries are automatically removed; the publishing interface supports setting the TTL parameter value.
[0066] Furthermore, the multi-agent shared memory collaborative knowledge retrieval system also includes:
[0067] The session concurrency control module is used to limit the maximum number of concurrent sessions through semaphores, and queue session requests that exceed the concurrency limit in an asynchronous queue. Each session is assigned a unique identifier and its status is tracked from creation, planning, execution to completion or failure, and the states between sessions are isolated.
[0068] In multi-user concurrent scenarios, the session concurrency control module uses a semaphore mechanism to limit the maximum number of concurrent sessions (default 100), and requests exceeding the concurrency limit are queued—ensuring service quality while preventing system crashes due to overload. Each session is assigned a unique identifier (session_id), tracking its complete lifecycle from creation to completion.
[0069] Furthermore, the multi-agent shared memory collaborative knowledge retrieval system also includes:
[0070] The human-machine collaborative approval module is used to classify all tools available to the intelligent agent into safe tools and dangerous tools according to their risk levels. When the execution of a task step by the intelligent agent includes the use of a dangerous tool, the execution is paused before reaching that task step, and a structured approval request is generated. The task step is continued or skipped after human approval or rejection. The approval result is recorded in the long-term memory subunit for reference in subsequent task steps.
[0071] The Human-in-the-Loop collaborative approval module categorizes read-only query tools as safe tools and write / modify / deploy tools as high-risk tools, setting approval checkpoints for high-risk tool operations (involving external system writing, code deployment, database modification, etc.). When the agent's execution plan needs to call a tool marked as high-risk, the system automatically pauses execution, generates an approval request, and awaits human approval or rejection. The approval request includes an operation description, risk assessment, and optional alternatives. This mechanism ensures the safety and controllability of critical operations while maintaining automation efficiency.
[0072] Furthermore, the multi-agent shared memory collaborative knowledge retrieval system also includes:
[0073] The structured execution tracing module records the input summary, output summary, execution time, and responsible agent type for each task step, with the smallest tracing granularity as the individual task step. It links the trajectories of all task steps in the same session to form an execution network using a unified identifier (trace_id). The tracing data for each task step is stored in a lightweight data exchange format (JSON) structure, supporting multi-dimensional querying and aggregation analysis by agent type, time range, and session identifier.
[0074] The structured execution tracing module generates a structured execution trace for each agent session, recording the input, output, time consumption, and agent type for each task step. The trace data is stored in JSON format and supports querying and statistical analysis by session, agent type, and time range, providing a data foundation for agent behavior auditing, performance bottleneck diagnosis, and experience extraction.
[0075] In the aforementioned multi-agent shared memory collaborative knowledge retrieval system, after an agent completes a task step, it automatically publishes the task results to the shared memory module. Other agents can then subscribe using wildcards or actively query to obtain the required information. A three-level linked memory structure is configured for each agent. Data linkage between these three levels is achieved through boosting streams, compression streams, merging streams, and injection streams. The injection stream, at the start of a new task, retrieves relevant historical experience from long-term memory and injects it into working memory, enabling agents to learn from experience. This achieves hierarchical storage management and autonomous reuse of semantic knowledge across tasks, effectively addressing architectural shortcomings such as inefficient information transmission among multi-agent agents, lack of hierarchical memory management, and inability to automatically reuse historical experience.
[0076] like Figure 2 As shown, this application also provides a multi-agent shared memory collaborative knowledge retrieval method, including:
[0077] S1. Receive user query task, decompose the user query task into task steps containing dependencies, and perform topological sorting of the task steps based on a directed acyclic graph, and schedule each agent to execute each task step in parallel according to the step dependencies.
[0078] S2. After the agent completes the task steps, the task results are published to the shared memory module in the form of key-value pairs, and the source agent identifier and step context are marked.
[0079] S3. Obtain the task results of the preceding task steps by actively querying or subscribing to callbacks;
[0080] S4. When a new task step begins, retrieve the reusable knowledge that matches the current query semantics from the long-term memory sub-unit and inject the reusable knowledge into the working memory sub-unit (injection stream).
[0081] S5. When the task step is completed, the high-value entries marked in the working memory sub-unit are written to the long-term memory sub-unit along with their embedded vectors (lifting flow).
[0082] S6. When the dialogue memory subunit exceeds the threshold, the entry is compressed to generate summary text, and the summary text carrying the embedding vector is written into the long-term memory subunit (compressed stream).
[0083] S7. After all task steps are completed, combine the results of all task steps into the final answer and output it.
[0084] In the aforementioned multi-agent shared memory collaborative knowledge retrieval method, after an agent completes a task step, it automatically publishes the task result to the shared memory module. Other agents can obtain the required information by subscribing using wildcards or actively querying. A three-level linked memory structure is configured for each agent. Data linkage between the three levels of linked memory structures is achieved through boosting streams, compression streams, merging streams, and injection streams. The injection stream, at the start of a new task, retrieves relevant historical experience from long-term memory semantics and injects it into working memory, enabling agents to learn from experience. This achieves hierarchical storage management and autonomous reuse of semantic knowledge across tasks, effectively solving the architectural defects of inefficient multi-agent information transmission, lack of hierarchical memory management, and inability to automatically reuse historical experience.
[0085] For a description of the features in the embodiment of the multi-agent shared memory collaborative knowledge retrieval method, please refer to the relevant description of the embodiment of the multi-agent shared memory collaborative knowledge retrieval system, which will not be repeated here.
[0086] The following examples illustrate various application scenarios.
[0087] Example 1: Technical Document Writing Scenario
[0088] Task: Write a technical white paper on "FPGA deep learning accelerators".
[0089] The workflow is as follows: Step 1 (research): Collect technical information on FPGA deep learning accelerators; Step 2 (research): Investigate the performance parameters of mainstream FPGA acceleration solutions on the market; Step 3 (writer): Write the first draft based on the research results of Steps 1-2; Step 4 (critic): Evaluate the quality of the first draft and make suggestions for improvement; Step 5 (writer): Revise the white paper according to the suggestions; Step 6 (orchestrator): Synthesize the final output.
[0090] Shared memory interaction:
[0091] 1. ResearchAgent completes Step1: publish("step:research_1", fpga_basics_data, source="research");
[0092] 2. ResearchAgent completes Step2: publish("step:research_2", benchmark_data, source="research");
[0093] 3. WriterAgent Startup Step 3: Retrieve all data from the two research steps using get_all_from("research");
[0094] 4. WriterAgent completes the first draft: publish("step:writer_3", draft_content,source="writer");
[0095] 5. CriticAgent Startup Step 4: Obtain the initial draft for evaluation using get_all_from("writer").
[0096] Three-level memory linkage: Upon task completion, WriterAgent marks "FPGA accelerator white paper writing experience" (including structural templates and sources of key performance parameters) as high-value and writes it into long-term memory. The next time a similar task is performed, the injection stream automatically injects this experience into working memory.
[0097] Example 2: Multi-round code review scenario
[0098] Task: Conduct multiple rounds of review and fixes on a piece of asynchronous Python code.
[0099] Orchestration Plan: Step 1 (research): Search for best practices and safe coding standards for asyncio; Step 2 (critic): Review the code based on the standards and make suggestions for improvement; Step 3 (writer): Modify the code according to the suggestions; Step 4 (critic): Conduct a second review of the modified code; Step 5 (writer): Make the final modifications based on the suggestions from the second review.
[0100] The value of Level 3 memory is reflected in:
[0101] When the task begins: the injection stream retrieves relevant experience from the last "code review" from long memory. The problem found last time was "concurrency was not controlled by asyncio.Semaphore", and working memory is automatically injected.
[0102] Review phase: CriticAgent's working memory already contains the experience from last time. Prioritize checking semaphore usage to find that the code has fixed the issue, and continue checking other aspects;
[0103] Task complete: New review experiences (such as "exception handling patterns in asyncio.gather") are written to long-term memory via a boosted stream.
[0104] Comparison of results: The version without memory requires 5 rounds of interaction (an average of 4 issues were reviewed each time, 2 of which had already been resolved in the previous instance); this implementation only requires 3 rounds (the previous experience has been injected, so there is no need to re-check the fixed issues).
[0105] Example 3: Customer Support Knowledge Base Query Scenario
[0106] Task: Multiple customer service agents process customer queries in parallel, and need to share a real-time updated knowledge base.
[0107] Production schedule: Step 1 (research_1): Agent-A queries the return policy knowledge base → publish("kb:returns", policy); Step 2 (research_2): Agent-B queries the refund process knowledge base → publish("kb:refunds", process); Step 3 (writer_1): Agent-A writes a response based on the return policy; Step 4 (writer_2): Agent-B writes a response based on the refund process.
[0108] The value of publish / subscribe (Pub / Sub) lies in:
[0109] Agent-C (the newly connected intelligent agent) is added in Step 3, and subscribes to all knowledge base updates via subscribe("kb:*");
[0110] When Agent-A's Step 3 requires additional refund process information, it can directly use `get_all_from(source="research_2")` to retrieve the search results from Agent-B.
[0111] Key difference: In group chat mode, Agent-C needs to read the complete dialogue history (including all interactions between Agent-A and Agent-B) to find the required information; in Pub / Sub mode, the target information can be obtained by simply using get_all_for("kb:").
[0112] Quantitative results: When 10 agents process 20 queries in parallel, the token consumption for publish / subscribe (Pub / Sub) is 22% of that in group chat mode, and the message transmission latency is 0.8ms vs 2.3s.
[0113] This application presents an agent-level Pub / Sub shared memory (type-aware + wildcard subscription), which differs from the publish / subscribe (Pub / Sub) or group chat mode information exchange of general message queues (Kafka / RabbitMQ). This embodiment designs a publish / subscribe (Pub / Sub) mechanism specifically tailored for agent collaboration: messages carry agent type-aware metadata (source, step_context), allowing subscribers to perform semantic-level message filtering based on the role of the source agent; wildcard subscription allows agents to dynamically adjust their scope of attention (e.g., subscribing to research:* during the research phase and switching to step:* during the review phase); and an active query interface allows late-joining agents to obtain historical messages without continuous listening.
[0114] Compared to group chat mode, Pub / Sub consumes a constant token for transmitting a single message (only the key and value need to be retrieved), while the token consumption in group chat mode increases linearly with the number of agents (each agent needs to read the complete conversation history).
[0115] The essential difference between this application and the Memory Sharing (MS) framework is that although the MS framework (2024) conceptually involves "multi-agent memory sharing", its communication mode is fundamentally different from that of this embodiment, as shown in Table 2.
[0116] Table 2
[0117] Comparison Dimensions MS Framework (2024) This embodiment (Pub / Sub) Communication mode Passive retrieval pipeline (retrieval → enhancement → inference) Active publish / subscribe + Active query Certainty in information transmission LLM-dependent reasoning (non-deterministic) Deterministic key-value passing (O(1) query) Message routing No routing mechanism (full search) Wildcard subscription + source filtering Delayed addition of support Not supported (can only retrieve stored memories) Supports (actively querying historical messages) Token consumption Injecting search results into context (O(k) tokens) Constant values (key-value pairs only) Application scenarios Contextual Enhancement (Assisting LLM Reasoning) Agent runtime communication (independent of LLM)
[0118] The memory sharing mechanism in the MS framework is essentially an LLM context enhancement, where memory serves as part of the input prompts, and information transmission still requires LLM inference. The Pub / Sub mechanism in this embodiment is the agent runtime communication infrastructure; information transmission is independent of LLM inference, exhibiting determinism, auditability, and low latency (0.8ms vs. second-level latency relying on LLM inference).
[0119] This application employs a three-tiered memory architecture adapted to different access modes. Unlike MemGPT's "virtual memory swapping in and out" and Reflexion's "full-text reflection storage," this embodiment designs specialized memory levels for three different access modes: Working memory is optimized for high-frequency read / write operations (each operation requires dozens of read / write operations): constant value key-value access with automatic TTL expiration; Long-term memory is optimized for low-frequency semantic retrieval (retrieval once at the start of each task): embedding vector + cosine similarity Top-K search; Dialogue memory is optimized for linear backtracking (requires complete dialogue context): time-series storage + automatic compression when exceeding a threshold.
[0120] The four interconnected flows in this application (lifting flow, compression flow, merging flow, and injection flow) constitute a complete memory lifecycle. In particular, the injection flow retrieves relevant historical experience from long-term memory semantics and injects it into working memory at the start of a new task, enabling the agent to achieve the ability to "learn from experience" without human intervention.
[0121] The key difference from existing technologies is that the injection stream enables semantic-level knowledge transfer across tasks, rather than simple context management, as shown in Table 3.
[0122] Table 3
[0123] Comparison Dimensions MemGPT Reflexion This embodiment (injection stream) Memory triggering method Passive (page swapping when the context window is full) Single closed loop (reflection at the end of the task) Proactive (semantic retrieval at the start of a new task) Scope of knowledge reuse Within a single task Within a single task cross-task Search methods None (In and out in chronological order) Full text matching Embedded Vector Semantic Search Knowledge reuse rate 15% 8% 42%
[0124] The core technological contribution of this application lies in upgrading "memory" from passive storage management to an active knowledge injection mechanism. Specifically, this is reflected in semantic relevance-driven mechanisms, cross-task knowledge transfer, and non-additive synergistic effects.
[0125] Semantic relevance-driven: The injection stream uses the current query as a semantic vector to retrieve the most relevant historical experiences from long-term memory, rather than simply replaying them in chronological order. This allows the agent's initial decisions to accurately benefit from historical learning, rather than being interfered with by irrelevant historical information.
[0126] Cross-task knowledge transfer: MemGPT and Reflexion's memory mechanisms are both limited to a single task, making it impossible to achieve knowledge transfer where "experience from task A helps task B". Injection Stream achieves a cross-task knowledge loop by writing high-value information upon task completion into long-term memory (lifting stream) and semantically retrieving and injecting it at the start of a new task (injection stream).
[0127] Non-additive synergistic effect: Ablation experiments show that the injection stream increases cross-task knowledge reuse rate from 18% to 42% (+133%, illustrative data), and task completion rate from 84% to 89%. This leap is not something that can be expected by simply "adding a layer of memory," but rather stems from the synergistic effect of semantic retrieval injection and working memory—the initial decision quality of the agent is significantly improved by the injection of historical experience, reducing the number of rounds of subsequent iterative correction.
[0128] This application features session-level concurrency control and resource isolation, which differs from traditional "unlimited concurrency" or "simple request queues". This embodiment designs fine-grained concurrency control at the agent session level: semaphore control, session lifecycle isolation, and resource-aware session scheduling.
[0129] Semaphore control: By limiting the maximum number of concurrent sessions (default 100) using semaphores, requests exceeding the concurrency limit are queued in an asynchronous queue instead of failing immediately. This mechanism ensures service quality while preventing system overload due to sudden traffic surges.
[0130] Session lifecycle isolation: Each session is assigned a unique identifier (session_id), and the entire state transition is tracked from creation, planning, execution to completion / failure. Sessions are isolated from each other; resource consumption or anomalies in one session do not affect the normal execution of other sessions.
[0131] Resource-aware session scheduling: Unlike the simple "first-come, first-served" approach, session scheduling considers the current resource usage status of the system (number of active agents, LLM API concurrency), and automatically delays the start of new sessions rather than rejects them when under high load.
[0132] The test results of the concurrency control verification are shown in Table 4.
[0133] Table 4
[0134] index Test Results Concurrent request count 50 Success Count 50 Success rate 100% Minimum success rate requirement 99% Error count 0
[0135] In a stress test with 50 concurrent requests, the system's session concurrency control module successfully achieved a 100% request success rate with zero errors. Semaphore rate limiting (default 100) and session lifecycle isolation ensured service quality under high load.
[0136] The human-machine collaborative approval mechanism for high-risk operations in this application differs from the two extreme solutions of "complete prohibition" (reducing functional integrity) or "unconditional execution" (bringing security risks). This embodiment designs a human-machine collaborative mechanism based on checkpoints: tool risk classification, approval insertion during execution, and feedback learning of approval results.
[0137] Tool Risk Classification: All tools available to agents are classified into safe tools (read-only query type) and dangerous tools (write / modify / deploy type) according to their risk level. Dangerous tools are registered with a risk description and approval requirements.
[0138] In-process approval insertion: When an agent's execution plan contains a dangerous tool call, the system automatically pauses before reaching that step, generates an approval request (including an operation description, risk assessment, and alternative solutions), and awaits manual approval or rejection. The approval request is sent as a structured message, supporting three response types: approval, rejection, and parameter modification.
[0139] Approval result feedback learning: Approval results (approval / rejection and reasons) are recorded in long-term memory, allowing the agent to refer to historical approval results to optimize tool selection strategies in subsequent similar tasks.
[0140] The structured agent execution tracing in this application differs from the traditional "log-level tracing" (which only records text logs and is not conducive to structured analysis). This embodiment designs a structured tracing mechanism specifically tailored for multi-agent collaboration: step-level tracing granularity, session-level tracing association, and cross-session experience extraction.
[0141] Step-level tracking granularity: Tracking is based on individual task steps as the smallest unit, recording the input summary, output summary, execution time, and responsible agent type for each step. Trajectory data is stored in JSON structure, supporting multi-dimensional querying and aggregation analysis.
[0142] Session-level tracing association: The traces of all steps within the same session are associated through a unified trace_id, forming a complete execution timeline. This allows for the reconstruction of the entire execution process without overlooking the context during problem diagnosis.
[0143] Cross-session experience extraction: Tracking data, after aggregation and analysis, can extract agent collaboration patterns, such as typical steps in research, writing, review, and revision, and the time distribution of each step, providing data-driven basis for orchestration strategy optimization.
[0144] Embodiments of this application also provide an electronic device, including a memory and a processor, wherein the memory stores a computer program, and the processor is configured to run the computer program to perform the steps in any of the above embodiments of the multi-agent shared memory collaborative knowledge retrieval method.
[0145] In one embodiment, the electronic device may be a server, and its internal structure diagram may be as follows: Figure 3As shown, the electronic device includes a processor, memory, network interface, and database connected via a system bus. The processor provides computational and control capabilities. The memory includes a non-volatile storage medium and internal memory. The non-volatile storage medium stores the operating system, computer programs, and the database. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage medium. The database stores multi-agent shared memory collaborative knowledge retrieval data. The network interface communicates with external terminals via a network connection. When the computer program is executed by the processor, it implements a multi-agent shared memory collaborative knowledge retrieval method.
[0146] Embodiments of this application also provide a computer-readable storage medium storing a computer program, wherein the computer program is configured to execute the steps in any of the above embodiments of the multi-agent shared memory collaborative knowledge retrieval method when running.
[0147] In one exemplary embodiment, the aforementioned computer-readable storage medium may include, but is not limited to, various media capable of storing computer programs, such as a USB flash drive, read-only memory (ROM), random access memory (RAM), portable hard disk, magnetic disk, or optical disk.
[0148] The embodiments of this application also provide a computer program product, which includes a computer program that, when executed by a processor, implements the steps in any of the above embodiments of the multi-agent shared memory collaborative knowledge retrieval method.
[0149] Embodiments of this application also provide another computer program product, including a non-volatile computer-readable storage medium storing a computer program, which, when executed by a processor, implements the steps in any of the above embodiments of the multi-agent shared memory collaborative knowledge retrieval method.
[0150] Those skilled in the art will further recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of the various examples have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0151] The foregoing has provided a detailed description of a multi-agent shared memory collaborative knowledge retrieval system, method, device, and medium provided in this application. Specific examples have been used to illustrate the principles and implementation methods of this application. The descriptions of the embodiments above are only intended to aid in understanding the method and core ideas of this application. It should be noted that those skilled in the art can make various improvements and modifications to this application without departing from its principles, and these improvements and modifications also fall within the protection scope of the claims of this application.
Claims
1. A multi-agent collaborative knowledge retrieval system with shared memory, characterized in that, include: The agent management module includes multiple agents, each with an independent reasoning-action loop, responsible for executing assigned task steps; The shared memory module is used for passing in-process messages for collaboration between agents; The orchestration and execution module is used to receive user query tasks, decompose the user query tasks into task steps with dependencies, perform topological sorting of the task steps based on a directed acyclic graph, schedule each agent to execute each task step in parallel according to the step dependencies, synthesize the task results of all task steps into the final answer and output it. A three-level linkage memory unit is used to maintain a three-level linkage memory structure in each intelligent entity. The three-level linkage memory structure realizes data linkage through boosting stream, compressing stream, merging stream, and injection stream. The three-level linkage memory structure includes a working memory subunit, a long-term memory subunit, and a dialogue memory subunit. The working memory subunit is used to cache the temporary intermediate state of the current task. The long-term memory subunit is used to persistently store cross-task reused knowledge. The dialogue memory subunit is used to store the dialogue temporal context of the current session. The boosting flow involves transferring high-value entries marked in the working memory subunit along with their embedding vectors to the long-term memory subunit; the compression flow involves compressing entries to generate summary text when the dialogue memory subunit exceeds a threshold, and then writing the summary text along with the embedding vectors into the long-term memory subunit; the merging flow involves the long-term memory subunit automatically merging low-access-frequency and long-term unaccessed entries at a preset period to release storage resources; and the injection flow involves retrieving matching reusable knowledge from the long-term memory subunit according to the current query semantics at the start of a new task step, and injecting the reusable knowledge into the working memory subunit.
2. The multi-agent shared memory collaborative knowledge retrieval system according to claim 1, characterized in that, The intelligent agents in the intelligent agent management module include: Research intelligent agents for performing knowledge base retrieval and web search; A writing agent used to generate structured documents based on research findings; A review agent is used to evaluate the quality of generated content and provide suggestions for improvement. An orchestration agent is used to synthesize the results of subtasks and generate the final output.
3. The multi-agent shared memory collaborative knowledge retrieval system according to claim 1, characterized in that, The shared memory module includes: The publishing interface is used to publish the task result to the shared memory module in key-value pairs after the agent completes the task, and to mark the source agent identifier and step context. The subscription interface is used by the agent to subscribe to specific keys or wildcard patterns, and triggers a callback when a new message is published for the matching key; the wildcard patterns include key exact match, prefix wildcard match, and global wildcard match; the subscription interface also supports filtering by source agent type, enabling agents to filter messages based on the semantics of collaborative roles; The active query interface is used by the agent to actively query all published memories from a specified source or prefix, so that agents that join later can obtain historical messages.
4. The multi-agent shared memory collaborative knowledge retrieval system according to claim 3, characterized in that, Each memory entry in the shared memory module includes an optional time-to-live parameter; expired memory entries are automatically removed. The publishing interface supports setting the time-to-live parameter value.
5. The multi-agent shared memory collaborative knowledge retrieval system according to claim 1, characterized in that, Also includes: The session concurrency control module is used to limit the maximum number of concurrent sessions through semaphores, and queue session requests that exceed the concurrency limit in an asynchronous queue. Each session is assigned a unique identifier and its status is tracked from creation, planning, execution to completion or failure, and the states between sessions are isolated.
6. The multi-agent shared memory collaborative knowledge retrieval system according to claim 1, characterized in that, Also includes: The human-machine collaborative approval module is used to classify all tools available to the intelligent agent into safe tools and dangerous tools according to their risk levels. When the execution of a task step by the intelligent agent includes the use of a dangerous tool, the execution is paused before reaching that task step, and a structured approval request is generated. The task step is continued or skipped after human approval or rejection. The approval result is recorded in the long-term memory subunit for reference in subsequent task steps.
7. The multi-agent shared memory collaborative knowledge retrieval system according to claim 1, characterized in that, Also includes: The structured execution tracing module is used to record the input summary, output summary, execution time, and responsible agent type for each task step, with the smallest tracing granularity being a single task step. The trajectories of all task steps in the same session are linked together using a unified identifier to form an execution context; the tracking data of each task step is stored in a lightweight data exchange format structure, which supports multi-dimensional querying and aggregation analysis by agent type, time range and session identifier.
8. A multi-agent collaborative knowledge retrieval method with shared memory, characterized in that, include: The system receives user query tasks, decomposes the user query tasks into task steps containing dependencies, performs topological sorting of the task steps based on a directed acyclic graph, and schedules each agent to execute each task step in parallel according to the step dependencies. After the agent completes the task steps, the task result is published to the shared memory module in the form of key-value pairs, and the source agent identifier and step context are marked. Obtain the task results of previous task steps by actively querying or subscribing to callbacks; When a new task step begins, the reusable knowledge that matches the current query semantics is retrieved from the long-term memory subunit and the reusable knowledge is injected into the working memory subunit. When the task step is completed, the high-value entries marked in the working memory subunit are written into the long-term memory subunit along with their embedded vectors. When the dialogue memory subunit exceeds the threshold, the entries are compressed to generate summary text, and the summary text carrying the embedding vector is written into the long-term memory subunit. Once all task steps are completed, combine the results of all task steps into the final answer and output it.
9. An electronic device, characterized in that, include: Memory, used to store computer programs; A processor, configured to implement the steps of the multi-agent shared memory collaborative knowledge retrieval method as described in claim 8 when executing the computer program.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program, wherein when the computer program is executed by a processor, it implements the steps of the multi-agent shared memory collaborative knowledge retrieval method as described in claim 8.