An agent coordination method and system based on a dedicated message queue
Patent Information
- Application Number
- CN202610498037.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2026-04-15
- Publication Date
- 2026-10-09
- Estimated Expiration
- 2046-04-15
AI Technical Summary
[0005]为此,本发明提供一种基于专用消息队列的智能体协同方法及系统,解决传统智能体依赖主动轮询导致效率低、上下文易失步、事件缺少完整语义、异构环境集成复杂,进而在人机与多智能体协同中出现感知滞后、决策失误、冲突频发等问题
[0029] First, a dedicated message queue is used to realize event-driven environmental perception, replacing the traditional active polling method. This significantly reduces invalid I/O and computational resource consumption, enabling intelligent agents to quickly perceive changes in environmental status and adapt to the real-time response requirements of human-machine hybrid collaboration.
Smart Images

Figure CN122363956B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the fields of computer software and artificial intelligence, specifically to an intelligent agent collaboration method and system based on a dedicated message queue. Background Technology
[0002] With the rapid evolution of Large Language Models (LLM) and agent technologies, agents have been widely deployed in human-machine hybrid collaborative scenarios such as operating systems, development environments, operation and maintenance systems, and data platforms for practical tasks such as code development, automated operation and maintenance, intelligent data analysis, and business process automation. In these human-machine and multi-agent collaborative environments, agents need to continuously perceive real-time changes in stateful modules such as file systems, databases, configuration centers, and business services to maintain consistency between their own context and the external environment, thereby making correct decisions and executing actions. Current mainstream implementations mostly use active polling, system native event notifications, or general event sourcing frameworks to synchronize environmental information, without specifically designing for the context awareness and collaborative characteristics of agents.
[0003] Existing intelligent agent environmental perception and collaboration technologies suffer from numerous shortcomings: traditional active polling methods generate a large amount of invalid I / O and computational overhead, and the perception latency is determined by the polling interval, making it impossible to achieve millisecond-level real-time response; in scenarios involving multiple users, multiple tools, and multiple intelligent agents operating concurrently, intelligent agents struggle to perceive external changes in a timely manner, easily leading to contextual synchronization issues, which in turn cause problems such as operation conflicts, overriding modifications, and decision-making errors; at the same time, existing event mechanisms can only inform that a change has occurred, lacking key information such as the event source and change semantics, making it impossible for intelligent agents to distinguish between the subject of the change and its business meaning; furthermore, the event mechanisms of heterogeneous modules such as file systems, databases, and configuration centers are independent of each other, lacking a unified event abstraction and standardized format, resulting in high intelligent agent adaptation costs, complex system integration, and insufficient scalability, severely restricting the stability and efficiency of multi-agent collaborative systems.
[0004] Therefore, there is an urgent need for an intelligent agent collaboration method based on a dedicated message queue to solve the problems of perception lag, decision-making errors, and frequent conflicts in existing technologies. Summary of the Invention
[0005] To address these issues, this invention provides an intelligent agent collaboration method and system based on a dedicated message queue. This solves the problems of low efficiency, easy loss of context synchronization, lack of complete semantics for events, and complex integration of heterogeneous environments caused by the reliance of traditional intelligent agents on active polling, which leads to problems such as perception lag, decision-making errors, and frequent conflicts in human-machine and multi-agent collaboration.
[0006] To achieve the above objectives, the present invention provides the following technical solution: an intelligent agent collaboration method based on a dedicated message queue, characterized in that it includes:
[0007] Deploy a dedicated message queue in the system environment; the dedicated message queue predefines a standard message structure including an event source identifier and event content;
[0008] Based on the dedicated message queue and the standard message structure, the stateful modules in the system write their own state change events into the dedicated message queue, so that the state change events conform to the standard message structure specification.
[0009] Based on the current real-time state of the system environment, the agent scans the stateful modules in the system and reads the state data, or directly uses the empty state as the initial state data; based on the state data, it constructs an initial context aligned with the system environment and determines the synchronization reference point corresponding to the initial context.
[0010] The intelligent agent subscribes to the event stream through the open interface of the dedicated message queue, receives the state change event from the synchronization reference point and parses the event semantics; updates its own context according to the event semantic increment or executes the corresponding business action according to the event semantics.
[0011] As a preferred embodiment of an agent collaboration method based on a dedicated message queue, the dedicated message queue assigns a globally unique sequence number to each state change event and provides an interface for subscription starting from the set sequence number; based on the globally unique sequence number, the event stream is sorted in linear ascending order; after the agent subscribes from the set sequence number, it can accurately track causal dependencies.
[0012] As a preferred embodiment of an agent collaboration method based on a dedicated message queue, the stateful module in the system is equipped with a consistent snapshot mechanism; the snapshot uses the logical time of the target state change event in the message queue as the version benchmark; after the agent constructs a context based on the snapshot read-only interface, it sets the sequence number corresponding to the snapshot as the synchronization benchmark point to achieve the alignment of the context with the state of the stateful module in the system.
[0013] As a preferred solution for an agent collaboration method based on a dedicated message queue, the agent incorporates a conflict detection and resolution algorithm. Before performing an environment modification operation, it obtains the local context version and the latest event version of the corresponding entity in the message queue. If the latest event version of the entity is greater than the local context version, it is determined that the context is out of sync, and the conflict resolution strategy is followed. The conflict resolution strategy includes: pausing the operation and prompting the user for confirmation, automatically regenerating the operation plan based on the latest version, or automatically arbitrating based on the event content.
[0014] As a preferred solution for an agent collaboration method based on a dedicated message queue, agents can configure subscription filters based on event source identifiers or event types to selectively receive specified events, and the filtering rules are independent of the write configuration of the stateful modules in the system. The stateful modules in the system include a file system, a database, a configuration center, and a business application service module. The file system captures file operations through event monitoring, and the database captures data row changes through a CDC mechanism.
[0015] As a preferred scheme for an agent collaboration method based on a dedicated message queue, a registration and discovery mechanism is constructed based on a declaration area and the dedicated message queue. The declaration area supports random reading and retrieval functions, and is used by stateful modules, tool modules, and agents in the system to complete identity registration and capability declaration respectively. The declaration area writes registration change events into the dedicated message queue according to the standard message structure, and distinguishes the registration change events from the state change events by setting message type identifiers. When an agent initializes, it reads the declaration area to obtain the complete system topology and constructs the initial context. During runtime, it receives the registration change events by subscribing to the dedicated message queue, realizing dynamic perception of the system topology and real-time updates of collaborative relationships.
[0016] The dedicated message queue supports concurrent subscription by several agents; the agents maintain a consistent event processing order through a global sequence number; the agents serialize the intermediate states, decision bases, and execution results of their internal inference process into standard messages and write them into the dedicated message queue for decision auditing, fault backtracking, and model data construction; the unified tool management module encapsulates tool call requests, execution process information, and execution results into events and writes them into the dedicated message queue, and the agents asynchronously track the entire process of tool calls based on the dedicated message queue.
[0017] This invention also provides an intelligent agent collaboration system based on a dedicated message queue, employing the above-mentioned intelligent agent collaboration method based on a dedicated message queue, including:
[0018] A dedicated message queue deployment unit is used to deploy a dedicated message queue in the system environment; the dedicated message queue predefines a standard message structure including an event source identifier and event content;
[0019] The state change event writing unit is used to write the state change events of the stateful modules in the system into the dedicated message queue based on the dedicated message queue and the standard message structure, so that the state change events conform to the standard message structure specification.
[0020] The initial context construction unit is used to scan the stateful modules in the system and read the state data based on the current real-time state of the system environment, or directly use empty states as initial state data; construct an initial context aligned with the system environment based on the state data, and determine the synchronization reference point corresponding to the initial context;
[0021] The self-context update and business action execution unit is used by the agent to subscribe to the event stream through the open interface of the dedicated message queue, receive the state change event from the synchronization reference point and parse the event semantics; update its own context according to the event semantic increment or execute the corresponding business action according to the event semantics.
[0022] As a preferred embodiment of an intelligent agent collaborative system based on a dedicated message queue, in the dedicated message queue deployment unit, the dedicated message queue assigns a globally unique sequence number to each state change event and provides an interface for subscription starting from the set sequence number; based on the globally unique sequence number, the event stream is sorted in linear ascending order; after the intelligent agent subscribes from the set sequence number, it can accurately track causal dependencies.
[0023] As a preferred solution for an intelligent agent collaborative system based on a dedicated message queue, the state change event writing unit includes a consistent snapshot mechanism for the stateful modules in the system. The snapshot uses the logical time of the target state change event in the message queue as the version reference. After the intelligent agent constructs a context based on the snapshot read-only interface, it sets the sequence number corresponding to the snapshot as the synchronization reference point to achieve alignment between the context and the state of the stateful modules in the system.
[0024] As a preferred solution for an intelligent agent collaborative system based on a dedicated message queue, the intelligent agent has a built-in conflict detection and resolution algorithm in its own context update and business action execution unit. Before performing an environment modification operation, it obtains the local context version and the latest event version of the corresponding entity in the message queue. If the latest event version of the entity is greater than the local context version, it is determined that the context is out of sync and is handled according to the conflict resolution strategy. The conflict resolution strategy includes: pausing the operation and prompting the user for confirmation, automatically regenerating the operation plan based on the latest version, or automatically arbitrating according to the event content.
[0025] As a preferred solution for an intelligent agent collaborative system based on a dedicated message queue, in the self-context update and business action execution unit, the intelligent agent can configure a subscription filter based on the event source identifier or event type to selectively receive specified events, and the filtering rules are independent of the write configuration of the stateful modules in the system; the stateful modules in the system include a file system, a database, a configuration center, and a business application service module, the file system captures file operations through event monitoring, and the database captures data row changes through a CDC mechanism.
[0026] As a preferred solution for an intelligent agent collaborative system based on a dedicated message queue, the initial context construction unit constructs a registration discovery mechanism based on a declaration area and the dedicated message queue. The declaration area supports random reading and retrieval functions, allowing stateful modules, tool modules, and intelligent agents in the system to complete identity registration and capability declarations respectively. The declaration area writes registration change events into the dedicated message queue according to the standard message structure, and semantically distinguishes the registration change events from the state change events by setting message type identifiers. During intelligent agent initialization, the agent obtains the complete system topology by reading the declaration area and constructs the initial context. During runtime, the agent receives registration change events by subscribing to the dedicated message queue, realizing dynamic perception of the system topology and real-time updates of collaborative relationships.
[0027] The dedicated message queue supports concurrent subscription by several agents; the agents maintain a consistent event processing order through a global sequence number; the agents serialize the intermediate states, decision bases, and execution results of their internal inference process into standard messages and write them into the dedicated message queue for decision auditing, fault backtracking, and model data construction; the unified tool management module encapsulates tool call requests, execution process information, and execution results into events and writes them into the dedicated message queue, and the agents asynchronously track the entire process of tool calls based on the dedicated message queue.
[0028] The present invention has the following advantages:
[0029] First, a dedicated message queue is used to realize event-driven environmental perception, replacing the traditional active polling method. This significantly reduces invalid I / O and computational resource consumption, enabling intelligent agents to quickly perceive changes in environmental status and adapt to the real-time response requirements of human-machine hybrid collaboration.
[0030] Second, by using a unified standard message structure to fully record the source of events and the semantics of changes, the core information of events is preserved, which helps intelligent agents to clearly identify the change logic and reduce the risk of operational conflicts and decision-making errors in multi-agent collaboration.
[0031] Third, by using snapshots to build the initial context and combining it with incremental event synchronization, the agent's context can be continuously aligned with the system environment, thus alleviating the problem of context disconnection under concurrent operations by multiple users and multiple agents.
[0032] Fourth, a unified event abstraction is implemented for heterogeneous stateful modules such as file systems and databases. A loosely coupled architecture is adopted, allowing each module to independently access the message queue, reducing system integration and adaptation costs and improving system scalability.
[0033] Fifth, it supports concurrent and orderly collaboration among multiple agents, and can record the agent's reasoning process and tool call information, which facilitates subsequent process verification and problem tracing, and improves the stability and controllability of the collaborative system. Attached Figure Description
[0034] To more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings in the following description are merely exemplary, and those skilled in the art can derive other embodiments based on the provided drawings without creative effort.
[0035] The structures, proportions, sizes, etc. illustrated in this specification are only for the purpose of assisting those skilled in the art in understanding and reading the content disclosed herein, and are not intended to limit the conditions under which the present invention can be implemented. Therefore, they have no substantial technical significance. Any modifications to the structure, changes in the proportions, or adjustments to the size, without affecting the effects and objectives that the present invention can produce, should still fall within the scope of the technical content disclosed in the present invention.
[0036] Figure 1 This is a flowchart illustrating an intelligent agent collaboration method based on a dedicated message queue, as provided in Embodiment 1 of the present invention.
[0037] Figure 2 This is a schematic diagram illustrating the specific implementation process of an intelligent agent collaboration method based on a dedicated message queue provided in Embodiment 1 of the present invention;
[0038] Figure 3 This is a schematic diagram of the architecture between specific modules in an intelligent agent collaboration method based on a dedicated message queue provided in Embodiment 1 of the present invention;
[0039] Figure 4 This is a schematic diagram of the architecture of an intelligent agent collaborative system based on a dedicated message queue, as provided in Embodiment 2 of the present invention. Detailed Implementation
[0040] The following specific embodiments illustrate the implementation of the present invention. Those skilled in the art can easily understand other advantages and effects of the present invention from the content disclosed in this specification. Obviously, the described embodiments are only some, not all, of the embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0041] Example 1
[0042] See Figure 1 and Figure 2 Embodiment 1 of the present invention provides an agent collaboration method based on a dedicated message queue, comprising the following steps:
[0043] S1. Deploy a dedicated message queue in the system environment; the dedicated message queue predefines a standard message structure including an event source identifier and event content;
[0044] S2. Based on the dedicated message queue and the standard message structure, the stateful module in the system writes its own state change event into the dedicated message queue, so that the state change event conforms to the standard message structure specification.
[0045] S3. Based on the current real-time state of the system environment, the agent scans the stateful modules in the system and reads the state data, or directly uses the empty state as the initial state data; based on the state data, it constructs an initial context aligned with the system environment and determines the synchronization reference point corresponding to the initial context.
[0046] S4. The agent subscribes to the event stream through the open interface of the dedicated message queue, receives the state change event from the synchronization reference point and parses the event semantics; updates its own context according to the event semantic increment or executes the corresponding business action according to the event semantics.
[0047] In this embodiment, in step S1, a dedicated message queue is deployed in the system environment; the dedicated message queue predefines a standard message structure including an event source identifier and event content.
[0048] Specifically, such as Figure 3As shown, a dedicated message queue is the underlying foundation for the entire system's event flow, module interconnection, and agent collaboration. As the system's nerve center, the dedicated message queue must possess core capabilities such as high-throughput persistent message storage, global sequence number allocation, breakpoint resumption from a specified point, and high-concurrency publish-subscribe. This can be implemented using mature middleware such as Apache Kafka, RabbitMQ, and RocketMQ, or through a self-developed message middleware. The dedicated message queue assigns a globally unique sequence number to each written event and provides an open interface for subscribing starting from a set sequence number. Based on this globally unique sequence number, the event stream is sorted in linear ascending order. After an agent subscribes from the set sequence number, it can accurately track causal dependencies.
[0049] In this embodiment, a standard message structure is predefined and enforced across the entire system. The core fields include: event source identifier (source_id, used to clarify the stateful module type and instance to which the change belongs) and event content (payload, which provides a structured description of the complete semantics of the change). It can also be expanded with supplementary fields such as nanosecond-level event timestamp, event type, and globally unique sequence number.
[0050] The event type field can be configured with specific identifiers to distinguish between registration change events and state change events, achieving semantic isolation of different events within the same queue and providing a unified standard for subsequent agent classification, filtering, and subscription. This step also simultaneously deploys the system's core components, including a declaration area for implementing the registration discovery mechanism and a tool management module for unified control of tool calls, thus completing the system setup. Figure 3 The system infrastructure shown.
[0051] In this embodiment, in step S2, based on the dedicated message queue and the standard message structure, the stateful module in the system writes its own state change event into the dedicated message queue, so that the state change event conforms to the standard message structure specification.
[0052] Specifically, the stateful modules in the system include one or more of the following: file system module, database module, configuration center module, and business application service module. Each stateful module in the system has a built-in lightweight message queue producer client. Through self-configured connection parameters, target topics, and serialization formats, it can independently establish a connection with a dedicated message queue without the need for intelligent agents or external coordinators to intervene in configuration and management, thus achieving loosely coupled plug-and-play access.
[0053] The file system module captures all file creation, modification, deletion, and renaming operations through a file system event monitoring mechanism, generating events conforming to a standard message structure and writing them to a queue. The database module uses CDC change data capture components such as Debezium and Canal to capture data table row insertion, update, and deletion operations, parsing them into structured content containing before-and-after images of field-level changes and writing them to a queue. The configuration center module and business application service module write configuration item changes and business status transition events to queues according to a standard structure, respectively. All status change events written to the dedicated message queue are sorted in linear ascending order based on a globally unique sequence number, ensuring global consistency of event order across modules, ultimately forming a globally unified, traceable, and parsable environment status event stream for the system.
[0054] In this embodiment, in step S3, based on the current real-time state of the system environment, the agent scans the stateful modules in the system and reads the state data; based on the state data, an initial context aligned with the system environment is constructed, and the synchronization reference point corresponding to the initial context is determined.
[0055] Specifically, after the agent starts, it obtains the complete topology of the current system by reading the system declaration area, identifies all registered stateful modules, tool modules, and collaborative agents, and constructs an initial global view of the system. Based on the preset task scope and the boundaries of the environment of interest, it calls the snapshot read-only interface of the stateful modules to autonomously scan the corresponding stateful modules and read complete consistent state data. Based on the read full state data and the system topology information obtained from the declaration area, the agent constructs an environmental cognitive mirror in memory, i.e., an initial context that is completely aligned with the current real-time state of the system environment. Simultaneously, the agent determines the globally unique sequence number of the dedicated message queue corresponding to this snapshot as the synchronization reference point for this initial context, providing a clear starting position for subsequent incremental event subscriptions. This ensures seamless connection between the initial context construction and subsequent incremental event reception, without missing any state changes, and achieves precise alignment between the context and the state of the stateful modules.
[0056] The stateful modules in the system are equipped with a consistent snapshot mechanism; the snapshot uses the logical time of the target state change event in the message queue as the version benchmark; after the agent constructs the context based on the snapshot read-only interface, it sets the sequence number corresponding to the snapshot as the synchronization benchmark point to achieve the alignment of the context with the state of the stateful modules in the system.
[0057] In this embodiment, in step S4, the agent subscribes to the event stream through the open interface of the dedicated message queue, receives the state change event from the synchronization reference point and parses the event semantics; updates its own context according to the event semantic increment or executes the corresponding business action according to the event semantics.
[0058] Specifically, the agent subscribes to the event stream through the consumer open interface of the dedicated message queue. When subscribing, it explicitly specifies that it will start receiving events from the synchronization reference point determined in step S3 to ensure that the event stream is free of duplication and omission. Based on the linear ascending order rule of the globally unique sequence number, the event stream received by the agent strictly follows the causal order of the events, realizing accurate tracking of the causal dependencies of the events.
[0059] The agent can configure subscription filters based on event source identifiers or event types to selectively receive events from specified sources or of specified types. The filtering rules are independent of the write configuration of stateful modules, allowing for adjustments to the subscription scope without modifying the module's write logic, thus improving collaborative flexibility. Upon receiving an event, the agent parses the event semantics based on a standard message structure, identifying core information such as event type, source, triggering entity, and changed content. If it is a state change event within the scope of interest, the agent incrementally updates its own context based on the event content, maintaining continuous alignment between the context and the system environment without requiring a full environment rescan. If it is a registration change event, the agent updates the system topology view and collaboration relationships based on the event content, achieving dynamic perception of the system topology and real-time updates of collaboration relationships.
[0060] The intelligent agent can execute corresponding business actions according to event semantics and preset business rules. Before initiating an environment modification operation, the built-in conflict detection and resolution algorithm automatically performs verification: obtain the local context version and the latest event version of the corresponding entity in the dedicated message queue. If the latest event version is greater than the local context version, it is determined that the context is out of sync, and the processing is completed according to the preset strategy. The strategy includes pausing the operation and prompting the user for confirmation, automatically regenerating the operation plan based on the latest version, and automatically arbitrating according to the event content to avoid executing erroneous operations based on outdated context.
[0061] In this embodiment, the dedicated message queue supports concurrent subscription by multiple agents. Each agent can maintain its own independent context based on the same event stream, ensuring consistency in event processing order through a globally unique sequence number. Alternatively, agents can subscribe to different event content based on different subscription rules, enabling collaborative task allocation among multiple agents. Simultaneously, agents serialize their intermediate reasoning states, decision-making basis, and final execution results into a standard message format and write them to the dedicated message queue. This data can be used for subsequent decision auditing, fault backtracking, and model training data construction. The system uses a unified tool management module to encapsulate agents' tool call requests, execution process information, and final execution results into events and write them to the dedicated message queue. Agents do not need to block and wait for tools to complete execution; they can asynchronously trace the entire tool call process based on the message queue.
[0062] In one possible embodiment, an example of collaboration within the OpenClaw intelligent agent development environment based on a dedicated message queue is provided as follows:
[0063] This embodiment is applied to a collaborative software development scenario. The system is deployed in a Linux development environment and includes three types of collaborative entities: human developers, OpenClaw intelligent agents, and code formatting automation tools. The project root directory is ` / work`, used to enable OpenClaw to achieve real-time awareness of the development environment's file system status, automatic context alignment, and avoidance of collaborative operation conflicts. In this embodiment, the dedicated message queue is implemented using an Apache Kafka cluster. Figure 3 The core central component of the overall system architecture.
[0064] I. System Deployment Architecture
[0065] Dedicated message queue (Kafka cluster): Deploy a 3-node Kafka cluster, create a topic dev-env-events, configure 3 replicas and 6 partitions, and have a built-in globally unique sequence number allocator to assign a 64-bit monotonically increasing globally unique sequence number Seq to each event, and provide an interface to subscribe from a specified Seq.
[0066] Dedicated file system module: A lightweight file system event monitoring component based on the inotify mechanism, mounted to the / work path, with a built-in Kafka producer client that automatically connects to the Kafka cluster upon startup;
[0067] Declaration section: A lightweight registration and discovery component implemented based on Redis, supporting random reads and retrieval;
[0068] OpenClaw Agent: A development aid agent based on a large language model, with built-in Kafka consumer client, event parser, context manager, and conflict detection engine;
[0069] Unified Tool Management Module: Used to encapsulate the call requests and results of code formatting tools.
[0070] II. Initialization Process
[0071] System topology acquisition: After OpenClaw starts, it reads the contents of the declaration area, obtains the information of the currently registered filesystem: / work module, and constructs an initial system topology view;
[0072] Consistent snapshot reading: OpenClaw calls the snapshot read-only interface of the filesystem: / work module to obtain a consistent snapshot of the / work directory at sequence number Seq=1024. The snapshot contains the path, hash value, modification time and metadata of all files at that time.
[0073] Initial context construction: OpenClaw traverses the / work directory based on snapshot data, reads the contents of key files (such as readme.md, src / main.py), and builds an in-memory file tree cache and project cognition, that is, an initial context aligned with the environment;
[0074] Synchronization baseline determination and event subscription: OpenClaw determines the sequence number Seq=1024 corresponding to the snapshot as the synchronization baseline, subscribes to the topic dev-env-events through the Kafka consumer interface, specifies that it will start receiving event streams from Seq=1025, and enters the listening state.
[0075] III. Specific Scenario Flow During Runtime
[0076] Scenario 1: Human developers modify files
[0077] M1, External Change Trigger: Human developers modify / work / readme.md via Vim and add the "Project A v1.0 Release Notes" paragraph.
[0078] M2, Event Generation and Writing: The dedicated file system module captures changes through inotify and generates state change events that conform to a standard structure, which are then written to Kafka.
[0079] M3. Event Consumption and Parsing: OpenClaw consumes the event from Seq=1025 and parses it based on the standard structure to find that the source of the change is filesystem: / work and the content of the change is user:developer modified readme.md.
[0080] M4, Incremental Context Update: OpenClaw updates the metadata of / work / readme.md in the internal file tree cache, autonomously determines that the file content needs to be read, and then reads the updated readme.md and parses the newly added paragraphs, incrementally updating the project's cognitive context.
[0081] M5. Inference Log Writing: OpenClaw serializes the intermediate inference state and decision basis of "noticing that user:developer has modified readme.md and updated the context" into a standard message and writes it to Kafka for subsequent auditing.
[0082] M6. Adaptation of Subsequent Behaviors: OpenClaw's subsequent code completion and documentation update behaviors are automatically executed based on the new context.
[0083] Scenario 2: Collaborative Operation Conflict Detection
[0084] N1. OpenClaw initiates an operation: OpenClaw prepares to modify line 5 of the code in / work / src / main.py based on the initial context.
[0085] N2. Conflict detection trigger: Before executing the modification, OpenClaw starts the conflict detection engine, obtains the Seq=1024 corresponding to the local context version, and queries the latest event Seq=1026 in src / main.py corresponding to filesystem: / work in Kafka.
[0086] N3. Detection and Handling of Context Out of Context: Since 1026 > 1024, it is determined that the context is out of context. OpenClaw suspends the operation according to the preset strategy and sends a prompt to human developers: "It has been detected that src / main.py has been updated. Do you need to regenerate the modification plan based on the latest content?".
[0087] N4. Context Synchronization: After user confirmation, OpenClaw consumes the event Seq=1026, incrementally updates the context of src / main.py, and regenerates the modified scheme.
[0088] In this embodiment, OpenClaw replaces traditional active polling with an event-driven mode using a dedicated message queue, reducing invalid file scanning overhead by more than 90%; it achieves stable alignment of context and environment through a standard message structure and snapshot mechanism; it avoids overwriting modification problems in collaborative operations through a conflict detection algorithm; and it achieves traceability of the decision-making process through inference log writing, fully verifying the effectiveness of the technical solution of this invention.
[0089] The application scenarios of this invention are as follows:
[0090] In collaborative software development scenarios, this invention enables collaboration between development aids such as OpenClaw and human developers and automated tools through a dedicated message queue. This allows the agents to perceive changes in code files and configuration files in real time, automatically update the context, avoid performing code completion, document updates, and other operations based on outdated information, and reduce the probability of collaborative operation conflicts.
[0091] In automated operation and maintenance scenarios, this invention aggregates state change events from server file systems, databases, and configuration centers through a dedicated message queue, enabling the operation and maintenance intelligent agent to perceive environmental changes in real time without actively polling. Based on event semantics, it automatically executes operation and maintenance scripts, troubleshoots anomalies, reduces unnecessary resource overhead, and improves operation and maintenance efficiency.
[0092] In multi-agent distributed collaboration scenarios, this invention achieves orderly collaboration among multiple agents through a unified standard message structure and registration discovery mechanism. Each agent maintains its context based on the same event stream, and the global sequence number ensures consistent processing order, adapting to the needs of multi-agent collaboration to complete complex tasks.
[0093] In collaborative data analysis scenarios, this invention enables data analysis agents to receive data change events from databases and business systems in real time through a dedicated message queue, incrementally update the data cognitive context, and respond promptly to data changes without having to reread all the data, thereby improving the real-time performance and efficiency of data analysis.
[0094] In human-machine collaborative office scenarios, this invention enables intelligent agents to perceive the status of office systems, file servers, and business applications through a dedicated message queue, allowing intelligent agents to collaborate with human office workers on tasks such as document editing and workflow approval, automatically synchronizing context, reducing manual synchronization costs, and avoiding operational disconnect.
[0095] It should be noted that the method of this disclosure embodiment can be executed by a single device, such as a computer or server. The method of this embodiment can also be applied to a distributed scenario, where multiple devices cooperate to complete the task. In such a distributed scenario, one of these devices may execute only one or more steps of the method of this disclosure embodiment, and the multiple devices will interact with each other to complete the method described.
[0096] It should be noted that the above description describes some embodiments of this disclosure. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in a different order than that shown in the above embodiments and still achieve the desired result. Furthermore, the processes depicted in the drawings do not necessarily require a specific or sequential order to achieve the desired result. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0097] Example 2
[0098] See Figure 4 Embodiment 2 of the present invention also provides an intelligent agent collaborative system based on a dedicated message queue, comprising:
[0099] A dedicated message queue deployment unit 001 is used to deploy a dedicated message queue in the system environment; the dedicated message queue has a predefined standard message structure including an event source identifier and event content;
[0100] The state change event writing unit 002 is used to write the state change event of the state module in the system into the dedicated message queue based on the dedicated message queue and the standard message structure, so that the state change event conforms to the standard message structure specification.
[0101] The initial context construction unit 003 is used to scan the stateful modules in the system and read the state data based on the current real-time state of the system environment, or directly use empty states as initial state data; construct an initial context aligned with the system environment based on the state data, and determine the synchronization reference point corresponding to the initial context;
[0102] The self-context update and business action execution unit 004 is used for the intelligent agent to subscribe to the event stream through the open interface of the dedicated message queue, receive the state change event from the synchronization reference point and parse the event semantics; update its own context according to the event semantic increment or execute the corresponding business action according to the event semantics.
[0103] In this embodiment, in the dedicated message queue deployment unit 001, the dedicated message queue assigns a globally unique sequence number to each state change event and provides an interface for subscription starting from the set sequence number; based on the globally unique sequence number, the event stream is sorted in linear ascending order; after the agent subscribes from the set sequence number, it can accurately track causal dependencies.
[0104] In this embodiment, in the state change event writing unit 002, the stateful module in the system is equipped with a consistent snapshot mechanism; the snapshot uses the logical time of the target state change event in the message queue as the version base; after the agent constructs the context based on the snapshot read-only interface, it sets the sequence number corresponding to the snapshot as the synchronization base point to realize the alignment of the context with the state of the stateful module in the system.
[0105] In this embodiment, the intelligent agent in the context update and business action execution unit 004 has a built-in conflict detection and resolution algorithm. Before performing an environment modification operation, it obtains the local context version and the latest event version of the corresponding entity in the message queue. If the latest event version of the entity is greater than the local context version, it is determined that the context is out of sync and is handled according to the conflict resolution strategy. The conflict resolution strategy includes: pausing the operation and prompting the user for confirmation, automatically regenerating the operation plan based on the latest version, or automatically arbitrating according to the event content.
[0106] In this embodiment, in the self-context update and business action execution unit 004, the intelligent agent can configure a subscription filter based on the event source identifier or event type to selectively receive specified events, and the filtering rules are independent of the write configuration of the stateful modules in the system; the stateful modules in the system include a file system, a database, a configuration center, and a business application service module, the file system captures file operations through event monitoring, and the database captures data row changes through the CDC mechanism.
[0107] In this embodiment, the initial context construction unit 003 constructs a registration discovery mechanism based on the declaration area and the dedicated message queue. The declaration area supports random reading and retrieval functions, and is used by the stateful modules, tool modules, and agents in the system to complete identity registration and capability declaration respectively. The declaration area writes registration change events into the dedicated message queue according to the standard message structure, and distinguishes the registration change events from the state change events by setting a message type identifier. When the agent is initialized, it obtains the complete system topology by reading the declaration area to construct the initial context. During runtime, it receives the registration change events by subscribing to the dedicated message queue, realizing dynamic perception of the system topology and real-time updates of cooperative relationships.
[0108] The dedicated message queue supports concurrent subscription by several agents; the agents maintain a consistent event processing order through a global sequence number; the agents serialize the intermediate states, decision bases, and execution results of their internal inference process into standard messages and write them into the dedicated message queue for decision auditing, fault backtracking, and model data construction; the unified tool management module encapsulates tool call requests, execution process information, and execution results into events and writes them into the dedicated message queue, and the agents asynchronously track the entire process of tool calls based on the dedicated message queue.
[0109] It should be noted that the information interaction and execution process between the modules of the above system are based on the same concept as the method embodiment in Embodiment 1 of this application, and the resulting technical effects are the same as those in the method embodiment of this application. For details, please refer to the description in the method embodiment shown above in this application, and it will not be repeated here.
[0110] Example 3
[0111] Embodiment 3 of the present invention provides a non-transitory computer-readable storage medium storing program code of an agent cooperation method based on a dedicated message queue. The program code includes instructions for executing the agent cooperation method based on a dedicated message queue of Embodiment 1 or any possible implementation thereof.
[0112] Computer-readable storage media can be any available medium that a computer can access, or a data storage device such as a server or data center that integrates one or more available media. The available medium can be magnetic media (e.g., floppy disks, hard disks, magnetic tapes), optical media (e.g., DVDs), or semiconductor media (e.g., solid-state drives (SSDs)).
[0113] Example 4
[0114] Embodiment 4 of the present invention provides an electronic device, including: a memory and a processor;
[0115] The processor and the memory communicate with each other via a bus; the memory stores program instructions that can be executed by the processor, and the processor can execute an agent collaboration method based on a dedicated message queue according to Embodiment 1 or any possible implementation thereof by calling the program instructions.
[0116] Specifically, a processor can be implemented in hardware or software. When implemented in hardware, the processor can be a logic circuit, an integrated circuit, etc. When implemented in software, the processor can be a general-purpose processor that reads software code stored in memory. This memory can be integrated into the processor or located outside the processor and exist independently.
[0117] In the above embodiments, implementation can be achieved, in whole or in part, through software, hardware, firmware, or any combination thereof. When implemented in software, it can be implemented, in whole or in part, as a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of the present invention are generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable system. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions can be transmitted from one website, computer, server, or data center to another via wired (e.g., coaxial cable, fiber optic, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means.
[0118] It is obvious to those skilled in the art that the modules or steps of the present invention described above can be implemented using general-purpose computing systems. They can be centralized on a single computing system or distributed across a network of multiple computing systems. Optionally, they can be implemented using program code executable by a computing system, thereby storing them in a storage system for execution by the computing system. In some cases, the steps shown or described can be performed in a different order than those presented herein, or they can be fabricated as separate integrated circuit modules, or multiple modules or steps can be fabricated as a single integrated circuit module. Thus, the present invention is not limited to any particular combination of hardware and software.
[0119] Although the present invention has been described in detail above with general descriptions and specific embodiments, modifications or improvements can be made to it, which will be obvious to those skilled in the art. Therefore, all such modifications or improvements made without departing from the spirit of the present invention fall within the scope of protection claimed by the present invention.
Claims
1. A method for intelligent agent collaboration based on a dedicated message queue, characterized in that, include: Deploy a dedicated message queue in the system environment; The dedicated message queue predefines a standard message structure that includes an event source identifier and event content. Based on the dedicated message queue and the standard message structure, the stateful modules in the system write their own state change events into the dedicated message queue, so that the state change events conform to the standard message structure specification. Based on the current real-time state of the system environment, the intelligent agent scans the stateful modules in the system and reads the state data, or directly uses the empty state as the initial state data. An initial context aligned with the system environment is constructed based on the state data, and a synchronization reference point corresponding to the initial context is determined. The intelligent agent subscribes to the event stream through the open interface of the dedicated message queue, receives the state change event from the synchronization reference point and parses the event semantics; updates its own context according to the event semantic increment or executes the corresponding business action according to the event semantics.
2. The agent collaboration method based on a dedicated message queue according to claim 1, characterized in that, The dedicated message queue assigns a globally unique sequence number to each state change event and provides an interface for subscribing starting from a set sequence number; Based on the globally unique sequence number, the event stream is sorted in linear ascending order; after the agent subscribes from the set sequence number, it can accurately track causal dependencies.
3. The agent collaboration method based on a dedicated message queue according to claim 2, characterized in that, The stateful modules in the system are equipped with a consistent snapshot mechanism; the snapshot uses the logical time of the target state change event in the message queue as the version benchmark; after the agent constructs the context based on the snapshot read-only interface, it sets the sequence number corresponding to the snapshot as the synchronization benchmark point to achieve the alignment of the context with the state of the stateful modules in the system.
4. The agent collaboration method based on a dedicated message queue according to claim 3, characterized in that, The intelligent agent has a built-in conflict detection and resolution algorithm; before performing environment modification operations, it obtains the local context version and the latest event version of the corresponding entity in the message queue; If the latest event version of the entity is greater than the local context version, then the context is determined to be out of sync, and the conflict resolution strategy is followed. The conflict resolution strategies include: pausing the operation and prompting the user for confirmation, automatically regenerating the operation plan based on the latest version, or automatically arbitrating based on the event content.
5. The agent collaboration method based on a dedicated message queue according to claim 4, characterized in that, The intelligent agent configures subscription filters based on event source identifiers or event types to selectively receive specified events, and the filtering rules are independent of the write configuration of the stateful modules in the system. The stateful modules in the system include a file system, a database, a configuration center, and a business application service module. The file system captures file operations through event monitoring, and the database captures data row changes through a CDC mechanism.
6. The agent collaboration method based on a dedicated message queue according to claim 5, characterized in that, A registration discovery mechanism is constructed based on the declaration area and the dedicated message queue. The declaration area supports random reading and retrieval functions, which are used by the stateful modules, tool modules, and agents in the system to complete identity registration and capability declaration respectively. The declaration area writes registration change events into the dedicated message queue according to the standard message structure, and distinguishes the registration change events from the state change events by setting message type identifiers. When an agent initializes, it obtains the complete system topology by reading the declaration area and constructs the initial context. During runtime, the system receives registration change events by subscribing to the dedicated message queue, thereby enabling dynamic awareness of the system topology and real-time updates of collaborative relationships. The dedicated message queue supports concurrent subscription by several agents; the agents maintain a consistent event processing order through a global sequence number; the agents serialize the intermediate states, decision bases, and execution results of their internal inference process into standard messages and write them into the dedicated message queue for decision auditing, fault backtracking, and model data construction; the unified tool management module encapsulates tool call requests, execution process information, and execution results into events and writes them into the dedicated message queue, and the agents asynchronously track the entire process of tool calls based on the dedicated message queue.
7. An agent-cooperative system based on a dedicated message queue, employing the agent-cooperative method based on a dedicated message queue as described in any one of claims 1-6, characterized in that, include: A dedicated message queue deployment unit is used to deploy dedicated message queues in the system environment; The dedicated message queue predefines a standard message structure that includes an event source identifier and event content. The state change event writing unit is used to write the state change events of the stateful modules in the system into the dedicated message queue based on the dedicated message queue and the standard message structure, so that the state change events conform to the standard message structure specification. The initial context construction unit is used to scan the stateful modules in the system and read the state data based on the current real-time state of the system environment, or to directly use the empty state as the initial state data. An initial context aligned with the system environment is constructed based on the state data, and a synchronization reference point corresponding to the initial context is determined. The self-context update and business action execution unit is used by the agent to subscribe to the event stream through the open interface of the dedicated message queue, receive the state change event from the synchronization reference point and parse the event semantics; update its own context according to the event semantic increment or execute the corresponding business action according to the event semantics.
8. The intelligent agent collaborative system based on a dedicated message queue according to claim 7, characterized in that, In the dedicated message queue deployment unit, the dedicated message queue assigns a globally unique sequence number to each state change event and provides an interface for subscription starting from the set sequence number; Based on the globally unique sequence number, the event stream is sorted in linear ascending order; after the agent subscribes from the set sequence number, it can accurately track causal dependencies.
9. The intelligent agent collaborative system based on a dedicated message queue according to claim 8, characterized in that, In the state change event writing unit, the stateful module in the system is equipped with a consistent snapshot mechanism; the snapshot uses the logical time of the target state change event in the message queue as the version base; after the agent constructs the context based on the snapshot read-only interface, it sets the sequence number corresponding to the snapshot as the synchronization base point to achieve the alignment of the context with the state of the stateful module in the system.
10. The intelligent agent collaborative system based on a dedicated message queue according to claim 9, characterized in that, In the self-context update and business action execution unit, the agent has a built-in conflict detection and resolution algorithm; before performing environment modification operations, it obtains the local context version and the latest event version of the corresponding entity in the message queue; If the latest event version of the entity is greater than the local context version, the context is determined to be out of sync, and the conflict resolution strategy is followed. The conflict resolution strategy includes: pausing the operation and prompting the user for confirmation, automatically regenerating the operation plan based on the latest version, or automatically arbitrating based on the event content. In the self-context update and business action execution unit, the agent configures a subscription filter based on the event source identifier or event type to selectively receive specified events, and the filtering rules are independent of the write configuration of the stateful modules in the system; the stateful modules in the system include a file system, a database, a configuration center, and a business application service module, the file system captures file operations through event monitoring, and the database captures data row changes through a CDC mechanism; In the initial context construction unit, a registration discovery mechanism is built based on the declaration area and the dedicated message queue. The declaration area supports random reading and retrieval functions, which are used by the stateful modules, tool modules, and agents in the system to complete identity registration and capability declaration respectively. The declaration area writes registration change events into the dedicated message queue according to the standard message structure, and distinguishes the registration change events from the state change events by setting a message type identifier. When the agent is initialized, it obtains the complete system topology by reading the declaration area to construct the initial context. During runtime, it receives the registration change events by subscribing to the dedicated message queue, realizing dynamic perception of the system topology and real-time updates of cooperative relationships. The dedicated message queue supports concurrent subscription by several agents; the agents maintain a consistent event processing order through a global sequence number; the agents serialize the intermediate states, decision bases, and execution results of their internal inference process into standard messages and write them into the dedicated message queue for decision auditing, fault backtracking, and model data construction; the unified tool management module encapsulates tool call requests, execution process information, and execution results into events and writes them into the dedicated message queue, and the agents asynchronously track the entire process of tool calls based on the dedicated message queue.
Citation Information
Patent Citations
Multi-agent cooperative task planning method, system and device and storage medium
CN119917319A
Distributed agent system, request processing method and device and storage medium
CN120429081A