Event-driven artificial intelligence context protocol service registration and discovery method

By constructing a service registry and performing health checks based on an event-driven AI context protocol, monitoring state changes, and establishing long connections for real-time push and automatic reconnection, the system solves the problems of delayed state change perception and insufficient semantic matching capabilities in existing technologies, and achieves efficient and continuous service registration and discovery.

CN120751002BActive Publication Date: 2026-02-27BEIJING CAPITEK
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202511220734.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-08-29
Publication Date
2026-02-27
Estimated Expiration
2045-08-29

AI Technical Summary

Technical Problem

Existing service registration and discovery solutions suffer from issues such as delayed state change awareness, high network overhead due to frequent polling, and a lack of semantic matching capabilities.

Method used

It adopts an event-driven artificial intelligence context protocol, which builds an MCP service registry by receiving service instance registration requests, performs health checks, monitors status changes and generates events, establishes long connections for real-time push, realizes automatic reconnection and session recovery, and performs service capability matching based on semantic understanding.

Benefits of technology

It achieves millisecond-level state change awareness, avoids the latency and resource overhead caused by polling, ensures service continuity and accurate matching, and is suitable for high real-time intelligent agent application scenarios.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120751002B_ABST
    Figure CN120751002B_ABST
Patent Text Reader

Abstract

The application relates to the technical field of protocol services, in particular to an event-driven artificial intelligence context protocol service registration and discovery method. The application first receives a service instance registration request and constructs a service registration table, records a service address and capability description, acquires an instance health state through heartbeat detection, monitors state changes and converts the state changes into standard events, adopts an SSE technology to establish a long connection to push filtered events in real time, maintains a client connection and realizes automatic reconnection and session recovery in an exception, analyzes service capability based on semantic understanding, realizes accurate demand matching, realizes millisecond-level state sensing, avoids polling overhead, ensures service continuity through intelligent matching and session recovery, and is suitable for high real-time intelligent agent application scenarios.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of protocol services, and in particular to an event-driven artificial intelligence context protocol service registration and discovery method. BACKGROUND

[0002] With the rapid development of artificial intelligence technology, intelligent agent applications based on large language models are increasingly popular. In order to standardize the interaction process between intelligent agents and external tools and ensure interoperability between systems, a unified communication standard and service governance mechanism need to be established. In this context, service registration and discovery have become the core infrastructure of intelligent agent systems.

[0003] The currently widely used service registration and discovery scheme is mainly based on a polling mechanism, in which service instances periodically send heartbeat packets to the registration center to report their status. Clients obtain a list of available services by periodically querying the registration center and select service instances according to a load balancing strategy.

[0004] However, the existing technology has the problems of delayed state change perception, large polling overhead, and lack of semantic matching capability, which need to be further improved. SUMMARY

[0005] To solve the problems of delayed state change perception, large polling overhead, and lack of semantic matching capability in the existing service registration and discovery scheme, the present application provides an event-driven artificial intelligence context protocol service registration and discovery method, which adopts the following technical solution:

[0006] In a first aspect, the present application provides an event-driven artificial intelligence context protocol service registration and discovery method, comprising the following steps:

[0007] Receiving a registration request of a service instance, constructing an artificial intelligence context protocol service registration table, and obtaining service instance information;

[0008] According to the service instance information, performing health detection to obtain health status information of the service instance;

[0009] According to the health status information, monitoring the state changes of the service instance and generating corresponding events to obtain state change information;

[0010] According to the state change information, establishing a long connection with the client using the server-sent events technology and performing event filtering to obtain real-time push events related to the client's subscription services;

[0011] According to the real-time push events, maintaining the connection state of the client and realizing automatic reconnection and session recovery to obtain client connection management information;

[0012] According to the client connection management information, a capability description of a service instance is analyzed and matched based on semantic understanding, and service instance information meeting a client function requirement is obtained.

[0013] By adopting the technical solution, the application first receives a service instance registration request and constructs an MCP service registration table, records instance information including a service address, a capability description, etc.; then performs health detection on the registered service instance, and obtains a health state in real time through heartbeat detection, etc.; then monitors service instance state changes and converts the changes into a standard event format; then adopts an SSE technology to establish a long connection with a client subscribing to a related service, and pushes events in real time after filtering; on this basis, a client connection state is maintained, and when a connection exception is detected, the application automatically reconnects and restores a session; finally, based on semantic understanding technology, a capability description of a service instance is analyzed, and precise matching of a client requirement and a service capability is realized; through an event-driven mechanism, millisecond-level state change perception is realized, and delay and resource overhead caused by polling are avoided; through semantic understanding, intelligent matching of a service capability is realized; through automatic reconnection and session restoration, service continuity is ensured, and the application is particularly suitable for intelligent agent application scenarios with high real-time requirements.

[0014] Optionally, according to the health state information, service instance state changes are monitored, and corresponding events are generated, to obtain state change information, specifically including the following steps:

[0015] According to the health state information, service instance state changes are monitored.

[0016] Multiple state change events of the same type and the same service in a preset time window are accumulated as batch events.

[0017] Multiple service instance state change events of the same physical location identifier are aggregated as regional-level events.

[0018] Continuous state change events with time sequence correlation are identified as service instance fluctuation events.

[0019] The batch events, the regional-level events, and the service instance fluctuation events are merged, to obtain compressed state change information.

[0020] By adopting the technical scheme, the application first continuously monitors the state change of the service instance through health detection; then sets a sliding window in the time dimension, accumulates multiple state changes of the same type and service occurring in the window period into a batch event, aggregates the state changes of multiple service instances into a regional level event according to the physical location identifier in the space dimension, and analyzes the time sequence correlation of the event in the semantic dimension to identify the continuous state change reflecting the repeated fluctuation of the same service instance as a fluctuation event; finally, the compression results of the three dimensions are merged to generate the final state change information; through multi-dimensional event compression, the system overhead of event processing and pushing is significantly reduced, the core semantic information of the event is retained, the information loss caused by excessive compression is avoided, and an efficient and reliable technical scheme is provided for the state management of a large-scale service cluster.

[0021] Optionally, according to the service instance information, health detection is performed to obtain health state information of the service instance, and the health detection specifically includes the following steps:

[0022] A heartbeat request periodically sent by the service instance is received, and active detection is performed on the instance that does not send the heartbeat in time to obtain health detection data of the service instance;

[0023] According to the health detection data, a stability index of the service instance is calculated, and the stability index is determined based on a health detection success rate and a recent failure weight factor;

[0024] According to the stability index, the health detection frequency of the service instance is dynamically adjusted to obtain a health detection strategy of the service instance;

[0025] Based on the health detection data and the health detection strategy, the health state of the service instance is divided into multiple levels to obtain the health state information of the service instance.

[0026] By adopting the technical scheme, the application first acquires basic health data by receiving a heartbeat request periodically sent by a service instance, initiates an active detection mechanism immediately for an instance that does not send a heartbeat on time, and detects the instance state through various network protocols; then, based on the collected health detection data, a stability index of the service instance is calculated, the index comprehensively considers the historical detection success rate and the influence weight of recent failures, so that more attention can be paid to recent failures; then, the detection frequency is dynamically adjusted according to the stability index, the detection frequency is increased for an instance with poor stability so as to discover problems faster, and the detection frequency is appropriately reduced for an instance with good stability so as to reduce system overhead; finally, the health state of the service instance is subdivided into multiple levels, and a finer basis is provided for subsequent load balancing and fault transfer decisions; the intelligent health detection mechanism significantly improves the accuracy of health state determination, avoids service switching shock caused by misjudgment, and simultaneously realizes optimal utilization of system resources by dynamically adjusting the detection strategy, thereby providing reliable guarantee for stable operation of the MCP service.

[0027] Optionally, according to the state change information, a server-sent event technology is adopted to establish a long connection with the client and perform event filtering, to obtain real-time push events related to the service subscribed by the client, and the specific steps include the following steps.

[0028] A version vector is associated with each service instance state, and the version vector contains modification counts of corresponding instance states by each node;

[0029] The causal relationship of state change events is determined by comparing the version vectors, and state conflicts caused by concurrent events are identified;

[0030] The predefined resolution rules are applied to the state conflicts, and the resolution rules include: when a state availability conflict occurs, the unavailable state is adopted preferentially; when a metadata change conflict occurs, field-level merging is adopted; and when a configuration conflict occurs, the configuration with a higher version number is adopted preferentially;

[0031] According to the resolved state change information, real-time events are pushed to the client subscribing to the corresponding service.

[0032] By adopting the technical scheme, the application firstly associates a version vector with the state of each service instance, which records the modification times of the instance state by various management nodes; then determines the causal relationship between different events by comparing their version vectors, thereby identifying the state conflicts caused by concurrent operations; then applies predefined conflict resolution rules, including giving priority to the unavailable state when the availability state conflicts to ensure system safety, adopting a field-level merging strategy to retain the modifications of both parties when the service metadata conflicts, and giving priority to the configuration with a higher version number when the configuration information conflicts to ensure the forward compatibility of the configuration; finally, the state change information after conflict resolution is pushed to the client that subscribes to the corresponding service through the SSE long connection; the version vector mechanism realizes the eventual consistency of the service state in a distributed environment, the fine-grained conflict resolution strategy ensures the reliability and correctness of the state update, and provides strong consistency guarantee for distributed service governance.

[0033] Optionally, according to the client connection management information, the capability description of the service instance is analyzed and matched based on semantic understanding to obtain service instance information meeting the functional requirements of the client, specifically including the following steps:

[0034] According to the client connection management information, the functional requirement description of the client is received, and the functional requirement description is converted into a standardized capability matching condition based on semantic understanding;

[0035] According to the capability matching condition, the service instance with matching capability is retrieved from the service registry;

[0036] Verify the interface compatibility of the service instance and the client request, and filter out the available candidate service instance;

[0037] Monitor the capability change event of the candidate service instance, dynamically update the matching result, and obtain the service instance information meeting the functional requirements of the client.

[0038] By adopting the technical scheme, the application firstly receives the function requirement description sent by the client, uses the natural language processing technology to perform semantic analysis on the requirement, extracts key capability elements and converts them into standardized matching conditions; then, according to the matching conditions, the service instances with corresponding capabilities are searched in the service registry, and potential matching instances are found out through semantic similarity calculation; then, the interface compatibility of the matched service instances is verified to ensure that the client can normally call the service interface; finally, the capability change events of the candidate service instances are continuously monitored, and when the capability of the service instance changes, the matching relationship is automatically re-evaluated to ensure that the client can always obtain the service instance most suitable for the requirement; through the deep understanding at the semantic level, the accuracy of service matching is significantly improved, and through the dynamic monitoring and updating mechanism, the real-time effectiveness of the matching result is ensured, and more accurate service discovery capability is provided for the intelligent agent application.

[0039] Optionally, according to the real-time push event, the client connection state is maintained and automatic reconnection and session recovery are realized, and client connection management information is obtained, specifically including the following steps:

[0040] Record the running state of the current session, and the running state includes the dialogue context, model parameters and intermediate calculation results;

[0041] Detect the service instance availability information in the real-time push event, and trigger automatic reconnection when the service instance is unavailable;

[0042] Select available instances with the same capability from the service registry for reconnection, and migrate the running state to the new instance;

[0043] Cache the client requests during the session migration, and process the cached requests in time sequence after the migration is completed to ensure service continuity.

[0044] By adopting the technical scheme, the application firstly records the complete running state of the current session, including dialogue history, interaction context, model configuration parameters, and intermediate calculation results not returned to the client, and other key information; then monitors the availability state of the service instance in real time, and triggers an automatic reconnection mechanism when detecting that the current service instance is unavailable; then finds available instances with the same capability description from the service registry, preferentially selects an instance with the closest configuration as the reconnection target, and migrates the previously saved complete running state to the new instance, ensuring that the new instance can seamlessly continue the previous session; during the state migration process, the system temporarily caches new requests from the client, and processes these requests according to the original time sequence after the migration is completed, thereby ensuring the continuity and correctness of request processing; the intelligent state migration mechanism realizes seamless switching when switching service instances, and the request caching and replay ensure the integrity of the business process, thereby providing a high-availability service guarantee mechanism for intelligent agent applications.

[0045] In a second aspect, the application provides an event-driven artificial intelligence context protocol service registration and discovery device, which comprises:

[0046] A service registration module is configured to receive a registration request of a service instance, construct an artificial intelligence context protocol service registry, and obtain service instance information.

[0047] A health detection module is configured to perform health detection according to the service instance information, and obtain health state information of the service instance.

[0048] An event monitoring module is configured to monitor the state change of the service instance and generate corresponding events according to the health state information, and obtain state change information.

[0049] An event pushing module is configured to establish a long connection with the client and perform event filtering according to the state change information by using the server-sent event technology, and obtain real-time push events related to the subscription service of the client.

[0050] A connection management module is configured to maintain the connection state of the client and realize automatic reconnection and session recovery according to the real-time push events, and obtain client connection management information.

[0051] A capability matching module is configured to analyze and match the capability description of the service instance based on semantic understanding according to the client connection management information, and obtain service instance information that meets the functional requirements of the client.

[0052] In a third aspect, the present application provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the event-driven artificial intelligence context protocol service registration and discovery method described above when executing the computer program.

[0053] In a fourth aspect, the present application provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program is executable on a processor to implement the steps of the event-driven artificial intelligence context protocol service registration and discovery method described above.

[0054] In summary, the present application includes at least one of the following beneficial technical effects:

[0055] The present application first receives a service instance registration request and constructs a service registration table, records service addresses and capability descriptions, obtains instance health states through heartbeat detection, monitors state changes and converts them into standard events, establishes a long connection in real time using SSE technology to push filtered events, maintains client connections and implements automatic reconnection and session recovery in the event of an exception, analyzes service capabilities based on semantic understanding to achieve accurate matching of requirements, achieves millisecond-level state awareness to avoid polling overhead, ensures service continuity through intelligent matching and session recovery, and is suitable for high real-time intelligent agent application scenarios.

[0056] The present application monitors service instance states through health detection, accumulates similar state changes into batch events using a sliding window in the time dimension, aggregates them into regional-level events based on physical location in the space dimension, and identifies continuous fluctuation states in the semantic dimension. Finally, it combines the three-dimensional compression results to generate state change information, reduces system overhead while preserving core semantics, avoids information loss, and provides an efficient state management solution for large-scale service clusters.

[0057] The present application obtains instance health data by receiving heartbeat requests and active detection, calculates a stability index based on historical success rates and recent failure weights, dynamically adjusts the detection frequency according to the index, increases the detection frequency for unstable instances and reduces the frequency for stable instances, subdivides the health state into multiple levels for load balancing decisions, improves the accuracy of health state determination, avoids service switching shocks caused by misjudgment, optimizes resource utilization through dynamic detection strategies, and ensures stable operation of services. BRIEF DESCRIPTION OF DRAWINGS

[0058] Figure 1 is a flowchart of the event-driven artificial intelligence context protocol service registration and discovery method based on the embodiments of the present application;

[0059] Figure 2 is a system architecture diagram of the MCP server registration center in the embodiments of the present application;

[0060] Figure 3is a flowchart of step S200 in the event-driven artificial intelligence context protocol service registration and discovery method of the embodiment of the present application;

[0061] Figure 4 is a flowchart of step S300 in the event-driven artificial intelligence context protocol service registration and discovery method of the embodiment of the present application;

[0062] Figure 5 is a flowchart of step S400 in the event-driven artificial intelligence context protocol service registration and discovery method of the embodiment of the present application;

[0063] Figure 6 is a flowchart of step S500 in the event-driven artificial intelligence context protocol service registration and discovery method of the embodiment of the present application;

[0064] Figure 7 is a flowchart of step S600 in the event-driven artificial intelligence context protocol service registration and discovery method of the embodiment of the present application;

[0065] Figure 8 is a module schematic diagram of the event-driven artificial intelligence context protocol service registration and discovery device of the embodiment of the present application;

[0066] Figure 9 is an internal structure diagram of an electronic device of the embodiment of the present application. DETAILED DESCRIPTION

[0067] The terms used in the following embodiments of the present application are only for the purpose of describing specific embodiments and are not intended to be limiting of the present application. As used in the specification and the appended claims of the present application, the singular forms "a," "an" and "the" are intended to include both singular and plural forms, unless the context clearly indicates otherwise. It will be further understood that the terms "and / or" as used herein refers to any or all possible combinations of one or more of the associated listed items.

[0068] Hereinafter, the terms "first" and "second" are only for the purpose of description, and cannot be understood as implying or suggesting relative importance or implicitly indicating the number of indicated technical features. Therefore, the features defined with "first" and "second" can explicitly or implicitly include one or more of the features, and in the description of the embodiments of the present application, the meaning of "a plurality of" is two or more, unless otherwise specified.

[0069] The embodiments of the present application will be further described in detail below with reference to the accompanying drawings of the specification.

[0070] In a first aspect, the application provides an event-driven artificial intelligence context protocol service registration and discovery method, which comprises the following steps: Figure 1

[0071] S100, receive a registration request of a service instance, build an artificial intelligence context protocol service registry, and obtain service instance information.

[0072] In this embodiment, the artificial intelligence context protocol (MCP) service registry is a distributed data storage structure for recording basic information of service instances. After the MCP service instance is started, a registration request is sent to the registration center, including service name, network address, capability description, and metadata. The registration center verifies the validity of the request, generates a globally unique instance ID, and stores the service instance information in the service registry. The registration center generates an INSTANCE_ADDED event and pushes the event to all clients subscribed to the corresponding service through an event push engine. The service instance starts to send a heartbeat request regularly to maintain an active state in the registration center.

[0073] S200, according to the service instance information, perform health detection to obtain health status information of the service instance.

[0074] In this embodiment, the registered service instance is health detected to obtain the health status in real time through heartbeat detection and other means. This embodiment adopts a bidirectional health check mechanism, including sending a heartbeat to the registration center by the service instance regularly (default 5 seconds) and actively detecting the service health status by the registration center regularly (default 10 seconds), and marking the instance as unavailable when the continuous three checks fail.

[0075] S300, according to the health status information, monitor the service instance state change and generate corresponding events to obtain state change information.

[0076] In this embodiment, when the service state changes (such as new instance registration, instance offline, etc.), the registration center generates corresponding events. For example, when all instances of a service are unavailable, a SERVICE_EMPTY event is generated; when a service with all instances unavailable has a new instance online, a SERVICE_RESTORED event is generated.

[0077] S400, according to the state change information, establish a long connection with the client using the server-sent event technology and perform event filtering to obtain real-time push events related to the service subscribed by the client.

[0078] ​In this embodiment, the server-sent events (SSE) technology is a unidirectional communication protocol based on HTTP, which is used for the server to push data stream to the client. The event push engine pushes events to the related client through the established SSE connection according to the subscription relationship.

[0079] S500, according to the real-time push event, the client connection state is maintained and automatic reconnection and session recovery are realized, and client connection management information is obtained.

[0080] In this embodiment, according to the real-time push event, the client connection state is maintained, and the management, monitoring and recovery mechanism of the client connection are realized, including heartbeat detection, automatic reconnection and session recovery.

[0081] S600, according to the client connection management information, the ability description of the service instance is analyzed and matched based on semantic understanding, and the service instance information meeting the functional requirements of the client is obtained.

[0082] In this embodiment, the system adopts a service capability matching algorithm based on semantic understanding, supports fuzzy query and similarity matching, and the client only needs to describe the required function without accurately specifying the service name. Then, the ability description of the service instance can be analyzed and matched to obtain the service instance information meeting the functional requirements of the client.

[0083] Specifically, referring to Figure 2 , Figure 2 is a system architecture diagram of the MCP server registration center, which is built around service registration and discovery, health management and client interaction, and is divided into three main parts: service consumer (client), service registration center and service provider (server). The consumer obtains and updates the service list from the registration center in real time through "initial service discovery" and "SSE event subscription", relies on "local service cache", "dynamic list update", "load balancer" and "failover logic" to realize efficient calling and fault tolerance. The registration center manages the instance lifecycle through "service instance registry" and "health check manager", provides registration query and event notification through "REST API interface" and "SSE push engine", and guarantees security and accurate matching through "security authentication module" and "capability mapping engine". The provider maintains the service active state through "automatic registration mechanism", "heartbeat sender" and "health check endpoint", supports service delivery with "capability declaration metadata", "service function implementation" and "graceful shutdown processing", and cooperates through HTTP / HTTPS and SSE protocol to realize dynamic service governance, real-time communication and high-availability calling.

[0084] In one embodiment, referring to Figure 3 , in step S200, according to the service instance information, health detection is performed to obtain the health state information of the service instance, including the following steps:

[0085] S210, receive the heartbeat request periodically sent by the service instance, and actively probe the instance which does not send the heartbeat in time to obtain health detection data of the service instance.

[0086] In the embodiment, the health detection data includes four dimensions of heartbeat record, probe record, response index and resource state. The heartbeat record includes a receiving timestamp and a sequence number, the probe record includes a probe result and a response time, the response index includes a request success rate and an average delay, and the resource state includes a CPU load and a memory usage.

[0087] Specifically, a double-channel detection system is constructed. The first channel is a heartbeat receiving service, Redis is used as a heartbeat data cache, and the expiration time of the heartbeat record is set to 15 seconds. The system writes the received heartbeat data into a heartbeat record table, and quickly judges whether the service instance is alive through a Bloom filter. The second channel is an active probe service, which maintains a probe task priority queue, and when it is found that a service instance has not sent a heartbeat for 3 times in succession, the instance is added to the probe queue. The active probe adopts a HTTP health check interface, and records the probe result and the response time. For example, when the sentiment analysis service instance has not sent a heartbeat for more than 15 seconds, the system will actively initiate a health check request to verify the service state.

[0088] S220, according to the health detection data, calculate the stability index of the service instance, and the stability index is determined based on the health detection success rate and the recent failure weight factor.

[0089] In the embodiment, the stability index is calculated in percentage, and is composed of a basic score and a penalty factor. The basic score is calculated according to the number of successful checks, and the value range is 0 to 100. The penalty factor is calculated based on the recent failure time, for example, it is divided into four time intervals: 0.8 within one hour, 0.5 within four hours, 0.2 within one day, and 0 beyond one day.

[0090] Specifically, the stability calculator is implemented in this step. First, a detection result storage table is established, and a time series database is used to record the latest 100 detection data. The system calculates the basic score by using a sliding window to count the number of successful detections. At the same time, a failure record index table is maintained to record the specific time of the last failure. The calculation formula of the stability index is: basic score x (1-penalty factor). For example, a service instance has successfully detected 90 times in the last 100 times, and the last failure occurred 2 hours ago, so its stability index is 90 x (1-0.5) = 45 points.

[0091] S230, according to the stability index, dynamically adjust the health detection frequency of the service instance to obtain the health detection strategy of the service instance.

[0092] In this embodiment, the health detection strategy includes four configuration items: detection interval time, timeout threshold, retry mechanism, and detection method. The detection interval time defines the time difference between two detections, the timeout threshold specifies the maximum waiting time for a single detection, the retry mechanism sets the retry rules after failure, and the detection method selects heartbeat reception or active probing.

[0093] Specifically, this step establishes a policy adjuster to determine the detection parameters through a mapping table. The system presets four stability intervals: 0-25 points use a 2-second detection interval, 26-50 points use a 5-second interval, 51-75 points use a 10-second interval, and 76-100 points use a 20-second interval. At the same time, a system load table is maintained to record the current resource usage, and the detection frequency is globally reduced moderately when the system load is high. For example, when a service instance stability index is 45 points, the basic detection interval is 5 seconds, and it is adjusted to 7.5 seconds under high system load conditions.

[0094] S240, based on the health detection data and the health detection strategy, dividing the health status of the service instance into multiple levels to obtain the health status information of the service instance.

[0095] In this embodiment, the health status is divided into four levels: healthy (response normal, resources sufficient), sub-healthy (response delay, resources tight), abnormal (response unstable), and offline (completely unavailable). Each state level has clear determination criteria and conversion rules.

[0096] Specifically, this step constructs a state evaluation engine to determine the state through a rule engine. The system maintains a state determination rule table, including response time threshold, resource usage threshold, and failure rate threshold. At the same time, a state conversion matrix is established to specify the conversion conditions and cooling periods between states. For example, when the response time of a service instance exceeds 500 ms but does not reach 1000 ms, it is determined to be in a sub-healthy state, and a performance optimization process is started.

[0097] In one embodiment, referring to Figure 4 , in step S300, according to the health status information, the service instance state change is monitored and the corresponding event is generated to obtain state change information, which specifically includes the following steps:

[0098] S310, according to the health status information, monitoring the service instance state change.

[0099] Specifically, a state change listener is constructed to realize real-time monitoring. The system maintains a state change record table and uses a time series database to store state change history. When a state change is detected, the system generates a state change event and writes the event to a message queue. To improve processing efficiency, a multi-level cache is used to store recent state data, and the difference between new and old states is detected by comparison. For example, in a large-scale MCP service environment, an event storm problem may occur, that is, a large number of events are generated in a short time in scenarios such as cluster rolling upgrade and network partition recovery.

[0100] Further, different monitoring strategies are adopted according to different health status levels. For service instances in a healthy state, regular monitoring with low frequency is adopted, mainly focusing on the stability of core indicators; for instances in a sub-healthy state, the system increases the monitoring frequency, focuses on tracking the specific indicator change trend that leads to state decline, and starts performance bottleneck analysis; for instances entering an abnormal state, the system starts all-round deep monitoring, including system log analysis, call chain tracking and resource usage details, and maintains a short sampling interval; for instances in an offline state, the system will monitor the state recovery of its dependent services in addition to maintaining basic availability detection. This differentiated monitoring mechanism based on health status level not only ensures the accuracy of monitoring, but also avoids excessive consumption of resources. Especially in a large-scale service environment, it can automatically adjust the monitoring resource allocation of each state instance to ensure efficient system operation.

[0101] S320, accumulate multiple state change events of the same type and the same service in a preset time window into batch events.

[0102] Specifically, a sliding window algorithm is used to process the event stream. The system establishes an event buffer to temporarily store events received within 500 milliseconds. Events are classified by a hash table, with the key being the combination of service identifier and event type, and the value being the event list. When the time window ends, the system traverses the hash table to combine events of the same type into batch events. For example, multiple INSTANCE_ADDED events are combined into one BATCH_INSTANCE_ADDED event, containing information of all new instances.

[0103] S330, aggregate multiple service instance state change events with the same physical location identifier into regional level events.

[0104] Specifically, service instances are grouped and aggregated according to their physical location (data center, availability zone, etc.). When multiple instances in the same region change state at the same time, a regional level aggregation event is generated.

[0105] S340, identify continuous state change events with time sequence correlation as service instance fluctuation events.

[0106] Specifically, the semantic patterns of the event sequences are analyzed, and the event sequences with specific patterns are identified and merged. For example, the sequence of the same instance being offline and then online within a short time is identified as a service instance fluctuation event, reducing unnecessary state switching notifications.

[0107] S350, merging the batch events, the regional level events and the service instance fluctuation events to obtain compressed state change information.

[0108] Specifically, this step constructs an event merging processor to manage different types of aggregated events through a priority queue. The system maintains an event priority table to determine the processing order according to the event impact range and the urgency. When receiving batch events, regional level events and fluctuation events, the system merges them according to the predetermined rules, ensuring the integrity of the information while maximizing the compression effect.

[0109] In one embodiment, with reference to Figure 5 In step S400, according to the state change information, a long connection with the client is established using the server-sent event technology and event filtering is performed to obtain real-time push events related to the service subscribed by the client, which includes the following steps:

[0110] S410, associating a version vector with each service instance state, the version vector containing the modification count of the corresponding instance state by each node.

[0111] Specifically, a version manager is constructed to maintain version information using a distributed key-value store. The system establishes a version vector table and stores the modification count of each node using a multi-dimensional array structure. When a node modifies the state of a service instance, it first obtains the current version vector, increments the counter at the corresponding position, and updates the timestamp and update type. For example, when node A marks a certain service instance as unavailable, the count of node A in its version vector is incremented by one, and the update time and state change type are recorded.

[0112] S420, determining the causal relationship of state change events by comparing version vectors to identify state conflicts caused by concurrent events.

[0113] In this embodiment, version vector comparison is performed through matrix operations. The system maintains a causal relationship diagram to record the dependency between events. When a new state change event is received, its version vector is compared with the existing version, and the causal order is determined according to the size relationship of the counters. If the version vectors do not overlap each other, they are marked as concurrent events. For example, when two nodes simultaneously modify the configuration information of a certain service instance, the system discovers through version vector comparison that this is a concurrent update and needs to be resolved.

[0114] S430, apply a predefined resolution rule to the state conflict, the resolution rule including: giving priority to the unavailable state when the state availability conflicts, adopting field-level merging when the metadata change conflicts, and giving priority to the configuration with the higher version number when the configuration conflicts.

[0115] S440, push a real-time event to a client subscribing to the corresponding service according to the resolved state change information.

[0116] In this embodiment, the real-time event is pushed to the client subscribing to the corresponding service according to the resolved state change information, ensuring that the client can finally obtain a consistent MCP service view even in a complex network environment, while avoiding the performance bottleneck caused by the traditional lock mechanism.

[0117] In one embodiment, referring to Figure 6 , in step S500, the client connection state is maintained and automatic reconnection and session recovery are implemented according to the real-time push event, obtaining client connection management information, specifically including the following steps:

[0118] S510, record the running state of the current session, the running state including the conversation context, model parameters and intermediate calculation results.

[0119] S520, detect the service instance availability information in the real-time push event, and trigger automatic reconnection when the service instance is unavailable;

[0120] S530, select an available instance with the same capability from the service registry for reconnection, and migrate the running state to the new instance;

[0121] S540, cache the client requests during session migration, and process the cached requests in time sequence after the migration is completed, ensuring service continuity.

[0122] In one embodiment, referring to Figure 7 , in step S600, the capability description of the service instance is analyzed and matched based on semantic understanding according to the client connection management information, obtaining service instance information meeting the functional requirements of the client, specifically including the following steps:

[0123] S610, receive the functional requirement description of the client according to the client connection management information, and convert the functional requirement description into a standardized capability matching condition based on semantic understanding.

[0124] In this embodiment, when the client is started for the first time, the complete list of registered services and instance information are obtained through an HTTP request, the client establishes a local cache to store the service instance information, and the cache is kept updated in real time through subscription events.

[0125] S620, retrieving service instances with matched capabilities from the service registry according to the capability matching condition.

[0126] In the embodiment, when the MCP service needs to be invoked, the client can select a healthy instance from the local cache by directly specifying the service name, provide a function description to select the most suitable service instance by the capability matching engine, or specify specific filtering conditions (such as version, region, etc.) to screen the instances meeting the conditions.

[0127] S630, verifying the interface compatibility of the service instance with the client request to screen the available candidate service instances.

[0128] In the embodiment, the client obtains the network address and interface information of the selected instance, establishes a connection and initiates an invocation. If the invocation fails, the client automatically performs failover, selects other healthy instances for retry, and notifies the registration center of possible instance failure.

[0129] S640, monitoring the capability change event of the candidate service instance, dynamically updating the matching result, and obtaining the service instance information meeting the function requirement of the client.

[0130] It should be understood that the size of the serial number of each step in the above embodiment does not mean the order of execution, and the execution order of each process should be determined according to its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the application.

[0131] In a second aspect, the application provides an event-driven artificial intelligence context protocol service registration and discovery device, which is described below in combination with the above-mentioned event-driven artificial intelligence context protocol service registration and discovery method.

[0132] Reference Figure 8 An event-driven artificial intelligence context protocol service registration and discovery device, the device comprising:

[0133] A service registration module for receiving a registration request of a service instance, constructing an artificial intelligence context protocol service registry, and obtaining service instance information;

[0134] A health detection module for performing health detection according to the service instance information to obtain health state information of the service instance;

[0135] An event monitoring module for monitoring the state change of the service instance and generating corresponding events according to the health state information to obtain state change information;

[0136] The event pushing module is configured to establish a long connection with the client by using a server-sent event technology and perform event filtering according to the state change information, so as to obtain a real-time pushing event related to the service subscribed by the client.

[0137] The connection management module is configured to maintain a client connection state and implement automatic reconnection and session recovery according to the real-time pushing event, so as to obtain client connection management information.

[0138] The capability matching module is configured to analyze and match a capability description of a service instance based on semantic understanding according to the client connection management information, so as to obtain service instance information meeting a functional requirement of the client.

[0139] In one embodiment, the present application provides an electronic device, which can be a server, and an internal structure diagram of the electronic device can be as shown in Figure 9 The electronic device includes a processor, a memory and a network interface connected through a system bus. The processor of the electronic device is configured to provide computing and control capabilities. The memory of the electronic device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for running the operating system and the computer program in the non-volatile storage medium. The database of the electronic device is configured to store data. The network interface of the electronic device is configured to communicate with an external terminal through a network connection. The computer program is executed by the processor to implement an event-driven artificial intelligence context protocol service registration and discovery method.

[0140] Those skilled in the art can understand that Figure 9 The structure shown in the figure is only a block diagram of part of the structure related to the scheme of the present application, and does not constitute a limitation on the electronic device to which the scheme of the present application is applied. The specific electronic device can include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.

[0141] In one embodiment, an electronic device is also provided, which includes a memory and a processor. The memory stores a computer program, and the processor implements the steps in each of the above method embodiments when executing the computer program.

[0142] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program. The above-mentioned computer program can be stored in a non-volatile computer readable storage medium, and when the computer program is executed, the computer program can include the processes of the above-mentioned embodiments of each method. Wherein, any reference to memory, storage, database or other medium used in each embodiment provided by the present application can include at least one of non-volatile and volatile memory. The non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory or optical memory, etc. The volatile memory can include random access memory (RAM) or external cache memory. As an illustration but not as a limitation, the RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM), etc.

[0143] The above are preferred embodiments of the present application, not to limit the protection scope of the present application, therefore: all equivalent changes made according to the structure, shape, principle of the present application should be covered within the protection scope of the present application.

Claims

1. An event-driven based artificial intelligence context protocol service registration and discovery method, characterized in that, The method comprises the following steps: receiving a registration request of a service instance, constructing an artificial intelligence context protocol service registry, and obtaining service instance information; performing health detection according to the service instance information, and obtaining health state information of the service instance; monitoring service instance state changes and generating corresponding events according to the health state information, and obtaining state change information; establishing a long connection with a client and performing event filtering by using a server-sent event technology according to the state change information, and obtaining real-time push events related to a subscription service of the client; maintaining a client connection state and realizing automatic reconnection and session recovery according to the real-time push events, and obtaining client connection management information; analyzing and matching a capability description of the service instance based on semantic understanding according to the client connection management information, and obtaining service instance information meeting a functional requirement of the client; wherein the analyzing and matching of the capability description of the service instance based on semantic understanding according to the client connection management information to obtain the service instance information meeting the functional requirement of the client comprises the following steps: receiving a functional requirement description of the client according to the client connection management information, and converting the functional requirement description into a standardized capability matching condition based on semantic understanding; retrieving service instances with matching capabilities from the service registry according to the capability matching condition; verifying interface compatibility of the service instances with a client request, and screening out available candidate service instances; monitoring capability change events of the candidate service instances, and dynamically updating a matching result to obtain the service instance information meeting the functional requirement of the client.

2. The event-driven artificial intelligence context protocol service registration and discovery method according to claim 1, characterized in that, The monitoring of service instance state changes and the generation of corresponding events according to the health state information to obtain state change information comprises the following steps: monitoring service instance state changes according to the health state information; accumulating multiple state change events of the same type and the same service within a preset time window into batch events; aggregating multiple service instance state change events of the same physical location identifier into regional-level events; identifying continuous state change events with time sequence correlation as service instance fluctuation events; merging the batch events, the regional-level events and the service instance fluctuation events to obtain compressed state change information.

3. The event-driven artificial intelligence context protocol service registration and discovery method of claim 1, wherein, The health detection according to the service instance information to obtain health state information of the service instance comprises the following steps: receiving a heartbeat request periodically sent by a service instance, and simultaneously actively detecting instances that do not send heartbeats in time to obtain health detection data of the service instance; calculating a stability index of the service instance according to the health detection data, wherein the stability index is determined based on a health detection success rate and a recent failure weight factor; dynamically adjusting a health detection frequency of the service instance according to the stability index to obtain a health detection strategy of the service instance; dividing a health state of the service instance into multiple levels based on the health detection data and the health detection strategy to obtain the health state information of the service instance.

4. The event-driven artificial intelligence context protocol service registration and discovery method of claim 1, wherein, According to the state change information, a long connection with the client is established by using a server-sent event technology and event filtering is performed to obtain real-time push events related to the service subscribed by the client, and the method specifically comprises the following steps: A version vector is associated with each service instance state, and the version vector contains a modification count of each node on the corresponding instance state; The causal relationship of state change events is determined by comparing the version vectors, and state conflicts caused by concurrent events are identified; A predefined resolution rule is applied to the state conflicts, and the resolution rule includes: when there is a state availability conflict, the unavailable state is preferred; when there is a metadata change conflict, field-level merging is adopted; and when there is a configuration conflict, the configuration with a higher version number is preferred; According to the resolved state change information, real-time events are pushed to the client subscribing to the corresponding service.

5. The event-driven artificial intelligence context protocol service registration and discovery method of claim 1, wherein, According to the real-time push events, the client connection state is maintained and automatic reconnection and session recovery are implemented to obtain client connection management information, and the method specifically comprises the following steps: The running state of the current session is recorded, and the running state includes the dialogue context, model parameters and intermediate calculation results; Service instance availability information in the real-time push events is detected, and automatic reconnection is triggered when the service instance is unavailable; An available instance with the same capability is selected from a service registry for reconnection, and the running state is migrated to the new instance; During session migration, client requests are cached, and after migration is completed, the cached requests are processed in chronological order to ensure service continuity.

6. An event-driven based artificial intelligence context protocol service registration and discovery apparatus, characterized in that, The event-driven artificial intelligence context protocol service registration and discovery method according to any one of claims 1-5, the device comprises: A service registration module for receiving a registration request of a service instance, constructing an artificial intelligence context protocol service registry, and obtaining service instance information; A health detection module for performing health detection according to the service instance information to obtain health state information of the service instance; An event monitoring module for monitoring state changes of the service instance and generating corresponding events according to the health state information to obtain state change information; An event push module for establishing a long connection with the client by using a server-sent event technology and performing event filtering according to the state change information to obtain real-time push events related to the service subscribed by the client; A connection management module for maintaining the client connection state and implementing automatic reconnection and session recovery according to the real-time push events to obtain client connection management information; A capability matching module for analyzing and matching the capability description of the service instance based on semantic understanding according to the client connection management information to obtain service instance information meeting the functional requirements of the client.

7. An electronic device, comprising: A computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the event-driven artificial intelligence context protocol service registration and discovery method according to any one of claims 1-5 when executing the computer program.

8. A computer-readable storage medium having stored thereon a computer program, characterized in that, The computer program is executed by the processor to implement the steps of the event-driven artificial intelligence context protocol service registration and discovery method according to any one of claims 1-5.

Citation Information

Patent Citations

  • Optimized registration method and system based on micro-service architecture

    CN120499260A

  • Automatic guarantee method and device for high-guarantee link, electronic equipment and storage medium

    CN120512354A