Class-shared predictive residual correction learning method, system, device, and storage medium

CN122946837APending Publication Date: 2026-10-20CTRIP COMP TECH SHANGHAI
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611192962.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-08-06
Publication Date
2026-10-20

AI Technical Summary

Benefits of technology

[0023]本发明的目的在于提供类共享预测残差校正学习方法、系统、设备及存储介质,能够实现条目级别的TTL动态预测,融合工具静态特征、条目漂移历史、上游变化信号和Agent请求上下文四族特征,通过类共享预测器与个体化残差校正联合建模,输出剩余有效时长分位数分布并具备在线闭环学习能力。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure FT_1
    Figure FT_1
  • Figure FT_2
    Figure FT_2
  • Figure FT_3
    Figure FT_3
Patent Text Reader

Abstract

This invention provides a class-shared prediction residual correction learning method, system, device, and storage medium. The method includes: classifying and distributing MCP tools and selecting target tool categories to enter the TTL learning pipeline; collecting runtime features from four families; training a class-shared GBDT backbone model to output quantile distributions on a tool category-by-tool basis; training individualized residual GBDT sub-models for high-frequency tools to correct biases; continuously deriving training labels and updating the model in a closed loop using four methods: adjacent real call comparison, ε-probe, upstream counterfactual, and rejection-based backfilling; and jointly deciding the TTL based on quantile distribution and agent sensitivity before cache hits. This invention achieves item-level dynamic TTL prediction, balancing high hit rate and low false hit rate, with negligible inference overhead and smooth cold start transition capability.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of AI, and more specifically, to a method, system, device, and storage medium for learning class-shared prediction residual correction. Background Technology

[0002] With the development of Large Language Model (LLM) technology, LLM-based intelligent agents have been widely used in enterprise scenarios such as customer service, data analysis, and automated operations and maintenance. Agents frequently need to interact with external tools and data sources to complete complex tasks. The Model Context Protocol (MCP), as the de facto standard between LLM agents and external systems, provides standardized specifications for operations such as tool invocation.

[0003] Within the MCP framework, a single agent task often triggers dozens to hundreds of tool calls, which vary greatly in cost, repetition rate, and timeliness: some results remain unchanged for a long time (such as documents), some drift within minutes (such as exchange rates), and some drift within seconds (such as inventory and quotes). This diversity poses a fundamental challenge to caching strategies.

[0004] Caching the results of tool calls is a key technology for improving throughput, reducing costs, and shortening response times. The core parameter of caching is the Time To Live (TTL), which is the maximum time a cached entry can be reused. TTL directly determines the cache hit rate and false hit rate: an excessively long TTL returns stale results, leading to incorrect decisions; an excessively short TTL results in a low hit rate and negates the purpose of caching.

[0005] Existing MCP tools have the following drawbacks in handling cached TTL: 1. Hard-coded TTL. This method uses the same fixed TTL for all tools and parameters, ignoring parameter-level and context-level differences. For example, different currency pairs of the same exchange rate tool may have update frequencies that differ by several times. Hard-coded TTL cannot distinguish between these differences and can only offer a compromise, failing to maximize the benefits of stable entries or guarantee the timeliness of volatile entries.

[0006] 2. Coarse-grained bucketing. Bucketing based on request type and table lookup to obtain TTL is essentially a configuration quantity rather than a predicted quantity. The granularity is coarse and cannot adapt to the timeliness differences caused by different internal parameters of the same type, nor can it respond to the dynamic changes of drift patterns.

[0007] 3. Prefix token caching only. It only caches the entire context prefix, does not recognize the semantic boundaries of single tool calls, and uses a platform-level constant for TTL, making it impossible to differentiate between different tools and parameters.

[0008] Fourth, ignoring upstream changes. The existing TTL is based entirely on "time since the last call," which is decoupled from whether the upstream data source has changed. When the upstream has just been updated, the TTL should be reset to zero; when the upstream has not changed for a long time, it should be extended to the hour level. The existing solution cannot achieve this, resulting in the return of outdated results when the data has changed, or premature failure when the upstream is stable.

[0009] 5. Ignoring Agent Intent. For the same entry, if it's used for critical decisions (such as payment invocation), the TTL should be tightened; if it's only used for text summarization, it can be relaxed. Existing solutions are not aware of the agent's planning layer and cannot adjust strategies based on contextual risk sensitivity.

[0010] The aforementioned shortcomings lead to a dilemma: a TTL that is too short results in low hit rate and high cost; a TTL that is too long leads to frequent false hits and decision-making contaminated by outdated results. Therefore, there is an urgent need for a dynamic TTL prediction method that is item-level oriented, integrates multi-dimensional features, and possesses adaptive and context-aware capabilities.

[0011] In view of this, the present invention provides a shared prediction residual correction learning method, system, device and storage medium. Summary of the Invention

[0012] To address the problems in existing technologies, the present invention aims to provide a shared prediction residual correction learning method, system, device, and storage medium that overcomes the difficulties of existing technologies. It can achieve item-level TTL dynamic prediction, integrate four families of features: tool static features, item drift history, upstream change signals, and agent request context, and jointly model the remaining effective time quantile distribution through a shared predictor and individualized residual correction, and has online closed-loop learning capabilities.

[0013] Embodiments of the present invention provide a shared prediction residual correction learning method, comprising the following steps: S110. Classify and distribute MCP tools according to the dimensions of side effects and timeliness, select the target tool categories to enter the effective duration learning pipeline, and perform static permanent caching, event registration and compensation, or direct bypass without caching on non-target categories respectively. S120. For each cached entry that enters the effective duration learning pipeline, continuously collect four sets of features at the MCP gateway side: tool static feature family, entry drift history feature family, upstream driving signal feature family, and request context feature family. Write the collected features into the feature warehouse for sharing between online inference and offline training. S130. Using MCP tool categories as units, a shared gradient boosting decision tree predictor is trained as the backbone model. Multiple quantile prediction outputs are trained in parallel using quantile regression loss. The backbone model outputs the quantile distribution of the remaining valid duration of cache entries based on the four family features. S140. For high-frequency tools or high-frequency parameter clusters whose cumulative sample count exceeds a preset threshold, independently train individualized residual gradient boosting decision tree sub-models. The residual sub-models are trained with the four family features as input and the difference between the actual remaining effective duration and the predicted value of the backbone model as the target. The final predicted value is the sum of the output of the backbone model and the output of the residual sub-model. S150. Training labels including drift positive labels, right deletion negative labels and precise drift time labels are derived through four methods: adjacent real call comparison, ε-probe, upstream counterfactual and rejection of backfilling. The backbone model and the residual sub-model are incrementally updated and fully retrained according to the preset scheduling strategy. S160. Before each cache entry is hit, read the current four-family features of the entry, call the backbone model and the residual sub-model to infer the remaining effective duration quantile distribution, and make a joint decision based on the quantile distribution and the sensitivity level of the current Agent request, and output one of the three effective duration decision results: directly return to the cache, background asynchronous refresh, or bypass forced re-tune.

[0014] Preferably, step S110 includes: S111. When registering MCP tools, tools are classified into four categories according to the side effect dimension: read-only, idempotent write, rollback write, and external non-rollback. At the same time, tools are classified into four categories according to the timeliness dimension: static, slow-changing, fast-changing, and event-driven, thus constructing a two-dimensional classification matrix. S112. Mark the tools belonging to the combination of read-only-slow change, read-only-fast change and idempotent write in the two-dimensional classification matrix as the target tool category to enter the effective duration learning pipeline. Mark the read-only-static class tools as adopting the static permanent caching strategy. Mark the rollback write class tools as adopting the event registration and compensation processing strategy. Mark the external non-rollback class tools as directly bypassed and not cached. S113. For the target tool category entering the effective duration learning pipeline, further extract the protocol method type, parameter pattern structure fingerprint, and parameter cardinality estimate of the tool as static metadata of the tool, which will be used for tool category identification in subsequent feature construction and model training.

[0015] Preferably, in step S120, the tool static feature family includes MCP tool category encoding, refresh energy level identifier, protocol method type, parameter pattern structure fingerprint, parameter cardinality estimation, tool historical average latency, result average byte count, and tool category average drift interval. The indicator set of the entry drift history feature family includes: the number of seconds that have passed since the cached entry was cached, i.e. the current age of the entry, the number of times the entry has drifted in the past specified time window, the mean and variance of the K most recent drift intervals, the time since the most recent drift, the similarity sequence of the K most recent result fingerprints, and the sliding window aggregation statistics based on the indicator set. The upstream driving signal feature family includes the time since the most recent change for each upstream object in the set of upstream objects on which the tool depends, the minimum, mean and maximum times of the most recent upstream change, short-window and long-window estimates of the upstream change frequency, and a Boolean flag indicating whether the upstream is in an active change burst state. The request context feature family includes the coarse category of the current Agent request, the relative position of this call in the plan graph, whether there are write operations in the subsequent plan steps, whether there are payment-related highly sensitive calls, the tenant service level agreement level, the user's historical tolerance for timeliness, and the time zone and business period of the request side.

[0016] Preferably, step S130 includes: S131. For each of the three categories of MCP tools—read-only-slow change, read-only-fast change, and idempotent write—construct an independent gradient boosting decision tree regressor as the class-shared backbone model for that category. The backbone model uses the quantile regression loss function as the training objective. S132. For each of the backbone models, train in parallel the prediction output of multiple quantiles including the 0.1 quantile, 0.5 quantile and 0.9 quantile, where the 0.1 quantile is used as a conservative estimate, the 0.9 quantile as an aggressive estimate and the 0.5 quantile as a median estimate; S133. In the training sample processing, the drift samples derived from the comparison of adjacent real calls are given complete label values, the consistent samples derived from the ε-probe are treated as right-censored samples and given survival analysis weights, the precise drift moment samples derived from upstream counterfactual sources are given the highest sample weights, and the sensitive scene samples that refuse to be backfilled are given the second highest sample weights. S134. For new tools or parameters with no historical data, use the hierarchical Bayesian prior distribution corresponding to the refresh level declared by the tool author as the initial prediction, and increase the ε-probe probability to a preset high value to accelerate sample accumulation.

[0017] Preferably, step S140 includes: S141. For each tool identifier or a combination of tool identifier and parameter cluster, maintain its cumulative sample count. When the cumulative sample count reaches a preset threshold, automatically trigger the training of a residual gradient boosting decision tree sub-model for that tool or parameter cluster. S142. The input of the residual sub-model is the four-family features of the complete four-family runtime, and the output target is set as the difference between the actual remaining effective duration and the corresponding trunk model prediction value. The tree depth and the number of leaf nodes of the residual sub-model are both smaller than those of the trunk model. S143. During inference, the output of the backbone model and the output of the residual sub-model are added and fused for each quantile to obtain the corrected quantile prediction value. S144. When a tool still exhibits residual variance higher than the preset variance threshold on the residual sub-model, the residual sub-model is further drilled down to the parameter cluster level for subdivision modeling, and refined level by level until the residual variance converges to the preset range.

[0018] Preferably, step S150 includes: S151. Derive training samples from call logs continuously recorded by the MCP gateway: perform result hash comparison on two adjacent real calls with the same tool identifier, parameter fingerprint and environment dependency fingerprint. If the result hash changes, register a drift event between the two call times. The time interval between two adjacent real calls is used as a conservative upper bound for the drift time. S152. Execute a real call probe on the cache hit entry with a preset ε probability, compare the probe result with the cache result, and if the result is consistent, generate a right censored negative label sample indicating that the entry has not drifted within at least the current storage age seconds. If the result is inconsistent, it degenerates into a drifted positive label sample. The ε probability is adaptively adjusted according to the prediction residual variance of the entry. S153. Receive change events from upstream data sources through the upstream subscription channel. When the data object involved in the change event matches the dependent object of a certain cache entry, write the current age of the cache entry at the time of the change into the training set as the positive label sample of the precise drift time. S154. When the bypass cache is determined and the real call is triggered due to insufficient prediction confidence or sensitivity requirements, the bypass call result is compared with the cache result. If they are inconsistent, the sample is added to the database and a sensitive scene label is attached. During training, it is given a higher weight than that of ordinary samples. S155. Perform incremental updates on the backbone model and the residual sub-model according to the preset hot update trigger conditions, perform full retraining according to the preset cold retraining cycle, and include the model version number in the environment dependency fingerprint each time a new model version is generated during training, so that the change of the predictor version is one of the trigger conditions for cache invalidation.

[0019] Preferably, step S160 includes: S161. Before each cache entry is hit, read the current four-family features of the entry, and use the backbone model and the residual sub-model to infer the remaining effective duration quantile distribution, including the 0.1 quantile, 0.5 quantile and 0.9 quantile. S162. If the current age of the entry is less than or equal to the 0.1 quantile, it is determined to be a safe hit, and the cached result is returned directly. S163. If the current age of the entry is greater than the 0.1 quantile and less than or equal to the 0.5 quantile, it is determined to be a conditional hit, and an asynchronous background refresh is triggered while returning the cached result. S164. If the current age of the entry is greater than the 0.5 quantile and less than or equal to the 0.9 quantile, then a decision is made based on the sensitivity level of the current Agent request: if the sensitivity level is higher than or equal to the preset threshold, then a bypass forced readjustment is executed; otherwise, a conditional hit is executed and an asynchronous background refresh is triggered. S165. If the current age of the entry is greater than the 0.9 quantile, it is determined to be a high-risk expiration, and a bypass forced re-adjustment is performed and the cached result is discarded. S166. Calculate the width between the 0.9 quantile and the 0.1 quantile as a prediction confidence measure. The width is in seconds. When the width exceeds the preset confidence threshold, trigger an active refresh to obtain new true results.

[0020] Embodiments of the present invention also provide a class-shared prediction residual correction learning system for implementing the above-described class-shared prediction residual correction learning method, wherein the class-shared prediction residual correction learning system includes: The classification and distribution module is used to classify and distribute MCP tools according to the dimensions of side effects and timeliness, filter the target tool categories to enter the effective duration learning pipeline, and perform static permanent caching, event registration and compensation, or direct bypass and non-caching on non-target categories respectively. The feature acquisition module is used to continuously collect four sets of features on the MCP gateway side for each cached entry entering the effective duration learning pipeline: the tool static feature set, the entry drift history feature set, the upstream driving signal feature set, and the request context feature set. The collected features are written into the feature warehouse for sharing between online inference and offline training. The class-shared prediction module is used to train a class-shared gradient boosting decision tree predictor as the backbone model, based on the MCP tool category, and to train multiple quantile prediction outputs in parallel using quantile regression loss. The backbone model outputs the quantile distribution of the remaining valid duration of cache entries based on the four family features. The individualized residual module is used to independently train individualized residual gradient boosting decision tree sub-models for high-frequency tools or high-frequency parameter clusters whose cumulative sample number exceeds a preset threshold. The residual sub-model is trained with the four family features as input and the difference between the actual remaining effective duration and the predicted value of the backbone model as the target. The final predicted value is the sum of the output of the backbone model and the output of the residual sub-model. The online learning module is used to derive training labels, including drift positive labels, right censored negative labels, and precise drift time labels, through four methods: adjacent real call comparison, ε-probe, upstream counterfactual, and rejection of backfilling. The module performs incremental updates and full retraining on the backbone model and the residual sub-model according to a preset scheduling strategy. The effective duration module is used to read the current four-family features of each cached entry before each cached entry is hit, call the backbone model and the residual sub-model to infer the remaining effective duration quantile distribution, and make a joint decision based on the quantile distribution and the sensitivity level of the current Agent request, and output one of the three effective duration decision results: directly return to the cache, background asynchronous refresh, or bypass forced re-tune.

[0021] Embodiments of the present invention also provide a shared prediction residual correction learning device, comprising: processor; A memory in which executable instructions of the processor are stored; The processor is configured to perform the steps of the above-described class-shared prediction residual correction learning method by executing the executable instructions.

[0022] Embodiments of the present invention also provide a computer-readable storage medium for storing a program that, when executed, implements the steps of the above-described class-shared prediction residual correction learning method.

[0023] The purpose of this invention is to provide a shared prediction residual correction learning method, system, device, and storage medium that can achieve item-level TTL dynamic prediction, integrate four families of features: tool static features, item drift history, upstream change signals, and agent request context, and jointly model the remaining effective time quantile distribution through a shared predictor and individualized residual correction, and has online closed-loop learning capability. Attached Figure Description

[0024] Other features, objects, and advantages of the invention will become more apparent from the following detailed description of non-limiting embodiments with reference to the accompanying drawings.

[0025] Figure 1 This is a flowchart of the class-shared prediction residual correction learning method of the present invention.

[0026] Figure 2This is a flowchart illustrating the class-shared prediction residual correction learning method of the present invention.

[0027] Figure 3 This is a detailed diagram of the TTL cache decision branch in the class-shared prediction residual correction learning method of the present invention.

[0028] Figure 4 This is a system architecture diagram of the class-shared prediction residual correction learning system of the present invention.

[0029] Figure 5 This is a schematic diagram of the structure of the class-shared prediction residual correction learning device of the present invention.

[0030] Figure 6 This is a schematic diagram of the structure of a computer-readable storage medium according to an embodiment of the present invention. Detailed Implementation

[0031] The following specific examples illustrate the implementation methods of this application. Those skilled in the art can easily understand the other advantages and effects of this application from the content disclosed herein. This application can also be implemented or applied through other different specific embodiments, and various details in this application can be modified or changed according to different viewpoints and application systems without departing from the spirit of this application. It should be noted that, unless otherwise specified, the embodiments and features in the embodiments of this application can be combined with each other.

[0032] The embodiments of this application will now be described in detail with reference to the accompanying drawings, so that those skilled in the art can easily implement the application. This application may be embodied in many different forms and is not limited to the embodiments described herein.

[0033] In this application, the terms "one embodiment," "some embodiments," "example," "specific example," or "some examples," etc., refer to specific features, structures, materials, or characteristics represented in connection with that embodiment or example, which are included in at least one embodiment or example of this application. Furthermore, the specific features, structures, materials, or characteristics represented may be combined in any suitable manner in one or more embodiments or examples. Moreover, without contradiction, those skilled in the art can combine and integrate different embodiments or examples represented in this application, as well as features of different embodiments or examples.

[0034] Figure 1 This is a flowchart of the class-shared prediction residual correction learning method of the present invention. Figure 1 As shown, the class-shared prediction residual correction learning method of the present invention includes the following steps: S110. MCP tools are categorized and distributed according to side effects and timeliness. Target tool categories are selected for entry into the effective learning pipeline. Non-target categories are handled through static permanent caching, event registration and compensation, or direct bypassing without caching. MCP (Model Context Protocol) is a standardized protocol for interaction between the LLM Agent and external tools and data sources.

[0035] S120. For each cached entry entering the effective duration learning pipeline, continuously collect four sets of features at runtime on the MCP gateway side: the tool static feature set, the entry drift history feature set, the upstream driving signal feature set, and the request context feature set. Write the collected features into the feature repository for sharing between online inference and offline training. Here, TTL (Time-To-Live) refers to the maximum time a cached entry can be reused before it is considered expired.

[0036] S130. Taking the MCP tool category as a unit, the training class shares a gradient boosting decision tree predictor as the backbone model. Multiple quantile prediction outputs are trained in parallel using quantile regression loss. The backbone model outputs the quantile distribution of the remaining valid duration of cached entries based on four family features. Here, GBDT (Gradient Boosting Decision Tree) is an ensemble learning algorithm that iteratively adds decision trees to fit the residuals.

[0037] S140. For high-frequency tools or high-frequency parameter clusters with a cumulative sample count exceeding a preset threshold, independently train individualized residual gradient boosting decision tree sub-models. The residual sub-models are trained with four family features as input and the difference between the actual remaining effective duration and the predicted value of the backbone model as the objective. The final predicted value is the sum of the output of the backbone model and the output of the residual sub-model.

[0038] S150. Training labels, including drift positive labels, right-censored negative labels, and precise drift time labels, are derived through four methods: adjacent real call comparison, ε-probe, upstream counterfactual, and rejection of backfilling. The backbone model and residual sub-models are incrementally updated and fully retrained according to a preset scheduling strategy. Right-censoring is a concept in survival analysis, referring to a situation where the event has not yet occurred at the end of the observation period, and it is only known that the event occurred at a time longer than the observation duration.

[0039] S160. Before each cache entry is hit, read the current four family features of the entry, call the backbone model and residual sub-model to infer the remaining effective duration quantile distribution, and make a joint decision based on the quantile distribution and the sensitivity level of the current Agent request, and output one of the three effective duration decision results: directly return to the cache, background asynchronous refresh, or bypass forced rescheduling.

[0040] The fundamental method of this invention integrates tool classification and distribution, four-family feature collection, class-shared backbone prediction, individualized residual correction, multi-source label online learning, and quantile decision-making into a closed-loop process. For the first time, it provides a dynamic TTL prediction architecture that can simultaneously achieve high hit rates and low false hit rates for MCP tool call caching scenarios. Specifically, step S110 uses a two-dimensional classification matrix to filter target tool categories, solving the inefficiency problem of using a unified caching strategy for different tool types. Step S120, through the collection of 60-dimensional features from four families, enables TTL prediction to simultaneously reflect tool static attributes, historical item drift patterns, upstream data source changes, and agent intent, overcoming the limitation of single features in traditional solutions. Steps S130 and S140, through a cascaded architecture of backbone plus residuals, achieve a smooth transition from cold start to steady state. Step S150, through closed-loop learning formed by four label sources, solves the label sparsity problem in caching scenarios. Step S160, through joint decision-making based on quantiles and sensitivity, enables the system to flexibly select caching strategies according to business risk preferences. The above steps work together to form a complete closed loop from tool registration to TTL decision-making, which significantly improves the hit rate of MCP tool call cache, reduces the false hit rate, and achieves maintenance-free automated TTL management.

[0041] In a preferred embodiment, step S110 includes: S111. When registering MCP tools, tools are categorized into four types based on side effects: read-only, idempotent write, rollbackable write, and externally non-rollbackable. Simultaneously, they are categorized into four types based on timeliness: static, slow-changing, fast-changing, and event-driven, constructing a two-dimensional classification matrix. "Read-only" refers to a tool that only reads data without modifying any state; "idempotent write" means that multiple executions of a write operation have the same effect as a single execution; "rollbackable write" means that the write operation can be undone or rolled back; and "externally non-rollbackable" means that the write operation involves an external system and cannot be undone. In the timeliness dimension, "static" means the result remains almost unchanged; "slow-changing" means the result changes at the hourly level; "fast-changing" means the result changes at the minute or second level; and "event-driven" means the result changes only when a specific event occurs.

[0042] S112. Mark the tools belonging to the combination of read-only-slow change, read-only-fast change and idempotent write in the two-dimensional classification matrix as the target tool category to enter the effective duration learning pipeline. Mark the read-only-static class tools as adopting the static permanent caching strategy. Mark the rollback write class tools as adopting the event registration and compensation processing strategy. Mark the external non-rollback class tools as directly bypassed and not cached.

[0043] S113. For the target tool category entering the effective duration learning pipeline, further extract the protocol method type, parameter pattern structure fingerprint, and parameter cardinality estimate of the tool as static metadata of the tool, which will be used for tool category identification in subsequent feature construction and model training.

[0044] This embodiment defines the detailed process of tool classification and distribution (S111-S113). Its technical advantages are as follows: First, the two-dimensional classification matrix (side effect dimension × timeliness dimension) constructed in S111 can systematically and accurately classify all MCP tools, ensuring that each tool is assigned to the most suitable caching path. Second, by marking read-only-slow-change, read-only-fast-change, and idempotent write as target tool categories in S112, it covers most scenarios suitable for caching where TTL needs dynamic prediction, while excluding tools unsuitable for caching (such as external non-rollback write operations), avoiding ineffective TTL prediction overhead and potential data consistency issues. More importantly, in S112, a permanent caching strategy is adopted for read-only-static tools, an event registration and compensation strategy is adopted for rollback-write tools, and a direct bypass strategy is adopted for external non-rollback tools. This differentiated processing allows the system to select the optimal caching strategy based on the essential characteristics of the tool, rather than applying the same logic to all tools, thereby maximizing caching benefits while ensuring data correctness. The static metadata extracted from S113, such as protocol method type, parameter pattern structure fingerprint, and parameter cardinality estimation, provides rich prior information for subsequent feature construction, enabling the model to obtain reasonable initial predictions even in the cold start phase.

[0045] In a preferred embodiment, in step S120: The tool static feature family includes MCP tool category encoding, refresh level identifier, protocol method type, parameter pattern structure fingerprint, parameter cardinality estimation, tool historical average latency, average number of bytes in the result, and average drift interval of the tool category. Among them, "refresh level" refers to the frequency level of change of the tool result; "parameter pattern structure fingerprint" refers to the unique identifier obtained by hashing the field type of each field in the tool parameter schema; "parameter cardinality estimation" refers to the estimated number of times the parameter combination has occurred in history.

[0046] The indicator set of the entry drift history feature family includes: the number of seconds elapsed since the cached entry was cached (i.e., its current age), the number of drifts of the entry within a specified time window in the past, the mean and variance of the K most recent drift intervals, the time since the most recent drift, the similarity sequence of the K most recent result fingerprints, and sliding window aggregation statistics based on the indicator set. Here, "age" refers to the time elapsed since the cached entry was created; "drift" refers to the state change where the cached result is inconsistent with the actual result; "result fingerprint" refers to the unique identifier obtained by hashing the returned result content; and "sliding window aggregation statistics" include mean, range, and exponentially weighted moving average (EWMA), etc.

[0047] The upstream driving signal feature family includes the time since the most recent change for each upstream object in the set of upstream objects on which the tool depends, the minimum, mean, and maximum times since the most recent change, short-window and long-window estimates of the upstream change frequency, and a Boolean flag indicating whether the upstream is in an active change burst state. Here, "upstream object" refers to the external data source or service on which the tool's results depend; "change burst state" refers to an active state in which multiple changes occur upstream within a short period.

[0048] The request context feature family includes the coarse category of the current Agent request, the relative position of this call in the plangraph, whether there are write operations in subsequent planned steps, whether there are payment-related highly sensitive calls, the tenant's service level agreement (SLA) level, the user's historical tolerance for timeliness, and the time zone and business period on the requesting side. Here, the "plangraph" refers to the directed acyclic graph of Agent task execution, describing the dependencies between steps; the "service level agreement (SLA)" refers to the service quality standards agreed upon between the tenant and the service provider.

[0049] This embodiment defines the specific composition of four feature families (approximately 60 dimensions). Its technical effects are as follows: Through the tool static feature family (approximately 15 dimensions), the model can obtain inherent attribute information about the tool itself, such as its category, refresh frequency, and historical latency. This information provides basic prior knowledge for TTL prediction. Through the entry drift history feature family (approximately 20 dimensions), the model can capture the historical change patterns of a specific cached entry—for example, some entries change frequently within a specific time period, while others remain stable for a long time—these time-series patterns are key signals for predicting future drift times. Through the upstream driving signal feature family (approximately 15 dimensions), the model can perceive the latest changes in the data source in real time. When a change occurs upstream, the TTL is immediately tightened; when the upstream remains stable for a long time, the TTL is lengthened, achieving adaptive capability synchronized with the actual state of the data source. Through the request context feature family (approximately 10 dimensions), the model can perceive the risk sensitivity of the current Agent call—payment calls require a more conservative TTL, while digest calls can use a more aggressive TTL—achieving context-aware differentiated decision-making. The four family features comprehensively characterize the factors affecting TTL from four dimensions: tools, entries, upstream, and context. The total number of dimensions is controlled at around 60 to ensure that the inference speed is at the microsecond level, which fully meets the latency requirements of MCP hot paths.

[0050] In a preferred embodiment, step S130 includes: S131. For each of the three MCP tool categories—read-only-slow-change, read-only-fast-change, and idempotent-write—construct an independent gradient boosting decision tree regressor as the class-shared backbone model for that category. The backbone model uses the quantile regression loss function as the training objective. The "quantile regression loss (also known as pinball loss)" is a loss function used to estimate specific quantiles of the target variable, achieving quantile prediction by imposing asymmetric penalties on different quantiles.

[0051] S132. Train the prediction output of each backbone model in parallel, including multiple quantiles such as the 0.1 quantile, 0.5 quantile and 0.9 quantile, where the 0.1 quantile is used as a conservative estimate, the 0.9 quantile as an aggressive estimate and the 0.5 quantile as a median estimate.

[0052] S133. In training sample processing, drift samples derived from comparisons with adjacent real calls are assigned full label values; consistent samples derived from ε-probes are treated as right-censored samples and assigned survival analysis weights; samples with precise drift moments derived from upstream counterfactual sources are assigned the highest sample weight; and sensitive scene samples that refuse to be backfilled are assigned the second-highest sample weight. Here, "survival analysis weight" refers to the statistical weight used to correct bias when processing right-censored data.

[0053] S134. For new tools or parameters with no historical data, use the hierarchical Bayesian prior distribution corresponding to the refresh level declared by the tool author as the initial prediction, and increase the ε-probe probability to a preset high value to accelerate sample accumulation. Here, "hierarchical Bayesian prior" refers to a method of smooth estimation based on prior knowledge of the tool category level.

[0054] This embodiment defines the training details of the backbone model (S131-S134). Its technical advantages are as follows: S131 constructs independent backbone models for the three types of tools, enabling each type to learn the common patterns within that type, avoiding pattern confusion caused by training different types of tools together. S132 trains the 0.1, 0.5, and 0.9 quantiles in parallel. The output quantile distribution provides rich probabilistic information for subsequent differential decision-making—the 0.1 quantile provides a conservative estimate for safe hit judgment, the 0.9 quantile provides an aggressive estimate for forced refresh judgment, and the width in between reflects the uncertainty of the prediction. S133 assigns different weights to different types of samples—upstream counterfactual samples provide accurate drift moments and are therefore given the highest weight; rejected samples come from sensitive scenarios and are therefore given the second highest weight; right-censored samples are processed using survival analysis weights—this differentiated sample processing method ensures that the model learns effective information from various label sources while avoiding estimation bias caused by right-censored data. In S134, by using hierarchical Bayesian priors and up-regulating the ε-probe probability, new tools and parameters can obtain reasonable TTL predictions during the cold start phase. By rapidly accumulating samples, the system gradually transitions to data-driven model predictions, achieving a smooth cold start with zero downtime.

[0055] In a preferred embodiment, step S140 includes: S141. For each tool identifier or a more granular combination of tool identifier and parameter cluster, maintain its cumulative sample count. When the cumulative sample count reaches a preset threshold, automatically trigger the independent training of a residual gradient boosting decision tree sub-model for that tool or parameter cluster. Here, "parameter cluster" refers to a group of tool call combinations with similar parameter characteristics.

[0056] S142. The input of the residual sub-model is the four-family features of the complete four-family runtime, and the output target is set as the difference between the actual remaining effective duration and the corresponding trunk model prediction value. The tree depth and leaf node number of the residual sub-model are both smaller than those of the trunk model.

[0057] S143. During inference, the output of the backbone model and the output of the residual sub-model are added and fused for each quantile to obtain the corrected quantile prediction value.

[0058] S144. When a tool still exhibits residual variance higher than the preset variance threshold on the residual sub-model, the residual sub-model is further drilled down to the parameter cluster level for subdivision modeling, and refined level by level until the residual variance converges to the preset range.

[0059] This embodiment defines the training and inference details of the individualized residual sub-model (S141-S144). Its technical advantages are as follows: The automatic triggering mechanism in S141 allows the system to automatically activate the residual sub-model after accumulating a sufficient number of samples, without manual intervention, achieving a smooth transition from class-shared prediction to individualized correction. In S142, the residual sub-model is trained using complete four-family features as input and the residuals of the backbone prediction as the target, enabling the sub-model to capture tool-specific patterns that the class-shared backbone cannot model—for example, exchange rate queries for different currency pairs within the same tool category have completely different drift rhythms. The size of the residual sub-model is much smaller than the backbone model (shallower tree, fewer leaves), ensuring negligible inference overhead. The quantile-level additive fusion in S143 ensures that each quantile receives individualized correction, rather than just correcting the mean prediction. The step-by-step drill-down mechanism in S144 (from tool level to parameter cluster level and then to finer granularity) enables the system to automatically identify and handle cases where there are still significant differences even in the tool level residual model. Through recursive refinement, it achieves accurate modeling of extreme long-tail differences until the residual variance converges, ensuring the prediction accuracy of the model at different granularities.

[0060] In a preferred embodiment, step S150 includes: S151. Derive training samples from call logs continuously recorded by the MCP gateway: Compare the result hashes of two adjacent real calls with the same tool identifier, parameter fingerprint, and environment dependency fingerprint. If the result hash changes, register a drift event between the two call times, using the time interval between two adjacent real calls as a conservative upper bound for the drift time. The "environment dependency fingerprint (capability_stamp)" is a component of the cache key, used to distinguish the same tool call under different environments; the "result hash (result_hash)" is a unique identifier obtained by hashing the returned result content.

[0061] S152. Execute a real call probe on the cached hit entries with a preset ε probability, compare the probe results with the cache results, and if the results are consistent, generate a right-censored negative label sample indicating that the entry has not drifted within at least the current age seconds. If the results are inconsistent, degenerate into a drifted positive label sample. The ε probability is adaptively adjusted according to the variance of the predicted residual of the entry.

[0062] S153. Receive change events from upstream data sources through the upstream subscription channel. When the data object involved in the change event matches the dependent object of a cached entry, write the current age of the cached entry at the time of the change into the training set as a positive label sample of the precise drift time. The "upstream subscription channel" includes database CDC (Change DataCapture), object storage event notification, file mtime monitoring, and message queue offset tracking.

[0063] S154. When bypass caching is determined and a real call is triggered due to insufficient prediction confidence or sensitivity requirements, the bypass call result is compared with the cache result. If they are inconsistent, the sample is added to the database and a sensitive scene label is attached. During training, it is given a higher weight than that of ordinary samples.

[0064] S155. Perform incremental updates on the backbone model and residual sub-models according to the preset hot update trigger conditions, perform full retraining according to the preset cold retraining cycle, and include the model version number in the environment dependency fingerprint each time a new model version is generated during training, so that the change of the predictor version is one of the trigger conditions for cache invalidation.

[0065] This embodiment defines the detailed process of online label acquisition and model update (S151-S155). Its technical advantages are as follows: In S151, drift samples are derived by comparing adjacent real calls, utilizing existing call logs in the MCP gateway to obtain a large number of drift labels without additional cost. In S152, right-censored negative labels are actively acquired through an ε-probe mechanism, solving the survivor bias problem caused by using only positive drift labels—if only positive labels (drift events) are used, the training set will have a fatal survivor bias: only truly changed entries are recorded, while long-term stable entries never appear in the training set, and the model will systematically underestimate the remaining effective duration. By introducing negative labels, the model can learn the lower bound information of "no drift by age seconds," thus avoiding the TTL from becoming shorter with repeated learning. In S153, precise drift times are obtained through upstream subscription channels. Compared to adjacent call comparisons which only provide an upper bound on the drift, upstream counterfactual analysis provides precise drift times, offering the model the highest quality training samples. Sensitive scenario samples that are rejected in S154 are given higher weight during training, making the model pay more attention to the prediction accuracy in high-risk scenarios. The hot update, cold retraining, and model versioning mechanisms in S155 ensure that the model can continuously adapt to business changes (hot update), avoid long-term drift accumulation (cold retraining), and prevent the excessively long TTL given by the old model from being used after the new model is launched (versioning failure), forming a complete continuous learning closed loop.

[0066] In a preferred embodiment, step S160 includes: S161. Before each cache entry is hit, read the current four-family features of the entry, and call the backbone model and residual sub-model to infer the remaining effective duration quantile distribution, including the 0.1 quantile, 0.5 quantile and 0.9 quantile.

[0067] S162. If the current age of the entry is less than or equal to the 0.1 quantile, it is considered a safe hit, and the cached result is returned directly.

[0068] S163. If the current age of the entry is greater than the 0.1 quantile and less than or equal to the 0.5 quantile, it is determined to be a conditional hit, and an asynchronous background refresh is triggered while returning the cached result.

[0069] S164. If the current age of the entry is greater than the 0.5 quantile and less than or equal to the 0.9 quantile, then a decision is made based on the sensitivity level of the current Agent request: if the sensitivity level is higher than or equal to the preset threshold, then a bypass forced readjustment is executed; otherwise, a conditional hit is executed and an asynchronous background refresh is triggered.

[0070] S165. If the current age of the entry is greater than the 0.9 quantile, it is determined to be a high-risk expiration, and a bypass forced re-adjustment is performed and the cached result is discarded.

[0071] S166. Calculate the width between the 0.9 quantile and the 0.1 quantile as a prediction confidence measure. When the width exceeds the preset confidence threshold, trigger an active refresh to obtain new true results.

[0072] This embodiment defines the detailed rules for TTL decision-making (S161-S166). Its technical effect is as follows: through the hierarchical decision-making mechanism based on three quantile thresholds in S161-S165, the system can achieve a fine balance between cache hit rate and data freshness—when the cache age is within the 0.1 quantile (safest interval), a direct hit is performed; when it is between the 0.1 and 0.5 quantiles (relatively safe interval), a hit is performed with asynchronous refresh; when it is between the 0.5 and 0.9 quantiles (risk interval), whether to force a refresh is determined based on Agent sensitivity; and when it exceeds the 0.9 quantile (high-risk interval), a forced refresh is performed. This hierarchical strategy allows the system to return to the cache in most cases (ensuring low latency and high throughput), while continuously updating data in the background through asynchronous refresh (ensuring freshness), triggering expensive synchronous calls only when necessary. In S166, the prediction confidence is determined by the quantile width—the larger the width, the more uncertain the model—and a refresh is proactively triggered when the uncertainty is too high, avoiding erroneous decisions when the model lacks confidence. The entire decision-making process is completed in microseconds, without affecting the performance of the MCP thermal path at all.

[0073] Figure 2This is a flowchart illustrating the class-shared prediction residual correction learning method of the present invention. The following is a summary of the process. Figure 1 and 2 Taking the deployment and operation of a typical MCP tool call caching system as an example, this paper describes in detail the implementation process of a complete embodiment of the present invention.

[0074] Step 1: System Initialization and Module Deployment (corresponding to...) Figure 1 Step S110)

[0075] The development team first deployed the class-shared prediction residual correction learning system of this invention. For example... Figure 2 As shown, the system comprises six core modules: classification and distribution module, feature acquisition module, class sharing prediction module, individualized residual module, online learning module, and effective duration module. The system is deployed on the MCP gateway side, serving as the middleware layer of the MCP protocol stack, located between the MCP client (Agent runtime) and the MCP tool server.

[0076] Upon system startup, the classification and dispatch module is initialized first. This module maintains a two-dimensional classification matrix in memory, with rows representing side-effect types (read-only, idempotent write, rollback-capable write, externally non-rollbackable) and columns representing timeliness types (static, slow-changing, fast-changing, event-driven). The system loads a pre-configured tool classification mapping table, provided by tool developers through extended annotations of the MCP protocol during tool registration. For existing tools, the system provides a management interface allowing operations personnel to manually specify or infer tool classifications through automatic detection mechanisms.

[0077] Simultaneously, the system initializes the feature acquisition module. This module establishes a feature acquisition pipeline on the MCP gateway side, intercepting and recording every MCP tool call request and response passing through the gateway. The feature acquisition module maintains a feature store, using a time-series database or memory cache as backend storage, to store the real-time and historical values ​​of the four families of features.

[0078] The system also initializes the online learning module. This module maintains three sample repositories: a hot sample repository (stores recently accumulated samples to be processed, used to trigger incremental updates), a cold sample repository (stores all historical samples, used for full retraining), and a label queue (stores raw call logs and label-derived tasks to be processed). The online learning module also initializes subscription channels with upstream data sources, including database CDC connections, object storage event listeners, and file system mtime monitors.

[0079] Step 2: Tool Registration and Classification Assume there are three MCP tools that need to be registered into the system: Tool A: Historical Document Query Tool (Read-Only - Static). This tool retrieves historical versions of documents from the document database based on the document ID. Once a document is published, its content remains almost unchanged, making it a typical read-only - static tool.

[0080] Tool B: Exchange Rate Inquiry Tool (Read-Only - Quick Change). This tool displays real-time exchange rates for currency pairs (such as USD / JPY, USD / CNY). Exchange rates fluctuate frequently during trading days, classifying it as a read-only - quick change tool. However, the drift rhythm differs between different currency pairs—USD / JPY is dominated by the US Eastern Time opening session, while USD / CNY is dominated by the weekday 09:00-16:00.

[0081] Tool C: Inventory Deduction Tool (Idempotent Write). This tool deducts product inventory when an order is generated, using idempotent keys to ensure consistent results across multiple calls. Inventory data changes are synchronized with actual inventory fluctuations, classifying it as an idempotent write tool.

[0082] Tool D: Payment Submission Tool (Externally Non-Rollbackable). This tool submits payment requests to a third-party payment gateway. Once submitted, it cannot be reversed; therefore, it falls into the category of externally non-rollbackable tools.

[0083] The classification and dispatch module processes data based on a two-dimensional classification matrix: Tool A (read-only - static) is marked as employing a static permanent caching strategy—its results are permanently cached and never expire unless manually cleared. Tool B (read-only - fast change) and Tool C (idempotent write) are marked as target tool categories for entering the TTL learning pipeline. Tool D (externally non-rollbackable) is marked as directly bypassed and not cached—it is executed live on every call, ensuring the accuracy and irreversibility of payment operations.

[0084] For tools B and C entering the TTL learning pipeline, the classification and dispatch module further extracts their static metadata: protocol method type (both GET or POST), parameter pattern structure fingerprint (tool B's parameter schema includes the from_currency and to_currency fields, and tool C's parameter schema includes the sku_id and quantity fields), and parameter cardinality estimation (tool B has approximately 200 currency pair combinations, and tool C has approximately 10,000 SKUs). This static metadata is written into the feature repository as the foundation data for the tool's static feature family.

[0085] Step 3: Runtime Feature Acquisition (corresponding to...) Figure 1 Step S120)

[0086] After the system enters steady-state operation, the feature acquisition module continuously collects features from the four families for each tool that passes through the MCP gateway.

[0087] Taking a single call to tool B (exchange rate query tool) as an example: The agent needs to query the real-time USD / JPY exchange rate. After receiving the call request, the MCP gateway's feature acquisition module executes the following acquisition process: (1) Collection of static features of tools: Read the category code (read-only - fast change class code = 02), refresh energy level identifier (fast change = 2), protocol method type (GET), parameter pattern structure fingerprint (hash value of {from_currency, to_currency}), parameter cardinality estimate (number of times the currency pair has appeared in history), tool historical average latency (obtained from call log statistics, about 120ms), average number of bytes of result (about 50 bytes), and average drift interval of tool category (obtained from statistics of all tools in this category, about 90 seconds).

[0088] (2) Collection of historical feature families for item drift: Using (tool_id=B, arg_fingerprint=fingerprint of USD / JPY) as the key, query the historical data of this item in the feature database. Current age (seconds elapsed since caching) = 45 seconds. Number of drifts in the past 24 hours = 3, number of drifts in the past 7 days = 18. Mean of the interval between the last three drifts = 62 seconds, variance = 15 seconds². Duration since the last drift = 18 seconds. Similarity sequence of the last K result fingerprints (calculated using MinHashJaccard) = [0.95, 0.92, 0.88, 0.85, 0.82]. Sliding window aggregation statistics: mean number of drifts within a 5-minute window = 0.6 times / minute, range = 3 times, EWMA = 0.55.

[0089] (3) Upstream driving signal feature collection: Query the dependency declaration of tool B—this tool depends on the REST API of the external exchange rate data source. The feature collection module obtains the latest change information of the data source through the upstream subscription channel (Last-Modified header or subscription callback of the external API). The upstream recent change duration = 8 seconds (meaning that the exchange rate data source was updated once 8 seconds ago). The minimum upstream recent change duration = 2 seconds, the average = 15 seconds, and the maximum = 120 seconds. The short window estimate of change frequency (past 1 minute) = 3 times / minute, and the long window estimate (past 1 hour) = 1.2 times / minute. The upstream active change burst flag = True (because the short window estimate is significantly higher than the long window estimate).

[0090] (4) Request Context Feature Collection: Extracted from the context passed in with the request header by the Agent framework. Current Agent task coarse category = Transaction (code = 03). Relative position of this call in the plan graph = Intermediate aggregation (this exchange rate query is used to calculate the total order price, located in the middle layer of the plan graph). Write operation exists in subsequent planning steps = True (the next step will be inventory deduction). No payment-sensitive calls exist (payment calls are in later steps). Tenant SLA level = Gold (requires high timeliness). User's historical tolerance for timeliness = Medium (historical "refresh" frequency is 15%). Request side timezone = Asia / Tokyo, business period = transaction period.

[0091] The four feature groups total approximately 60 dimensions. The feature acquisition module completes the acquisition and calculation of all features in microseconds and writes the feature vectors into the feature warehouse. At the same time, the original call logs are written to the label queue of the online learning module.

[0092] Step 4: Backbone model prediction (corresponding to) Figure 1 Step S130)

[0093] The class-shared prediction module maintains three class-shared backbone models, corresponding to three types of tools: read-only-slow-change, read-only-fast-change, and idempotent write. Each backbone model is a LightGBM gradient boosting decision tree regressor, which has been trained on historical data.

[0094] For tool B (read-only - fast-changing class), the class-shared prediction module calls the backbone model corresponding to that class. The input to the backbone model is the 60-dimensional feature vector just written by the feature acquisition module. The backbone model internally performs the following calculations: First, the model maps 60-dimensional features to nodes in a tree, and obtains predicted values ​​for three quantiles through voting and weighting across multiple decision trees. Because LightGBM employs optimization techniques such as Gradient-based One-Side Sampling (GOSS) and Exclusive Feature Bundling (EFB), the latency for a single inference operation is controlled at the microsecond level.

[0095] Assume the three quantiles output by the backbone model are: 0.1 quantile = 30 seconds, 0.5 quantile = 75 seconds, and 0.9 quantile = 180 seconds. This means that the model has a 90% confidence level that the remaining effective duration of the item is at least 30 seconds (conservative estimate), a 50% confidence level that it is at least 75 seconds (median estimate), and a 10% confidence level that it is at least 180 seconds (aggressive estimate).

[0096] Step 5: Individualized residual correction (corresponding to) Figure 1 Step S140)

[0097] The individualized residual module checks the cumulative number of samples for tool B. Since tool B (USD / JPY) is a high-frequency tool, the cumulative drift events have exceeded the preset threshold N_min = 500. Therefore, the individualized residual module automatically triggers the residual GBDT sub-model trained for this tool.

[0098] The input to the residual sub-model is also a complete 60-dimensional feature vector, and the output target is "the difference between the actual remaining effective time and the backbone prediction value". Because the USD / JPY exchange rate fluctuates significantly more frequently than the class average during the Eastern Time Opening session, the residual sub-model learns a positive residual (i.e., the actual TTL is shorter than the backbone prediction). Assume the residuals of the three quantiles output by the residual sub-model are: 0.1 quantile residual = -10 seconds, 0.5 quantile residual = -5 seconds, and 0.9 quantile residual = +2 seconds.

[0099] The final predicted value is the sum of the backbone output and the residual output: 0.1 quantile = 30 + (-10) = 20 seconds, 0.5 quantile = 75 + (-5) = 70 seconds, 0.9 quantile = 180 + 2 = 182 seconds.

[0100] For new tools or parameters with a cumulative sample size of less than N_min (such as the EUR / TRY currency pair appearing for the first time in Tool B), the individualized residual module will not trigger the residual sub-model, and will only use the output of the backbone model. Simultaneously, the hierarchical Bayesian prior mechanism uses the prior distribution corresponding to the refresh level declared by the tool authors (rapid change → mean 90 seconds) as a smoothing factor for initial predictions, ensuring that new parameters can obtain reasonable TTL predictions even during the cold start phase. The ε-probe probability has been increased from the default 5% to 20% to accelerate sample accumulation.

[0101] Step 6: Online Tag Collection (corresponding to...) Figure 1 Step S150)

[0102] The online learning module continuously collects training labels through four methods: (1) Comparison of adjacent real calls: Suppose that tool B (USD / JPY) has a real call at t=0 seconds, and the result hash is hash_1. At t=45 seconds, there is another real call (which was executed because it was not cached for some reason), and the result hash is hash_2. The online learning module compares hash_1 and hash_2 and finds that they are inconsistent. Therefore, it registers a drift event between t=0 and t=45 and generates a positive label sample: the remaining valid duration of this entry is ≤45 seconds.

[0103] (2) ε-Probe: At t=60 seconds, the system determines that the cached entry has been hit (based on the current age=60 seconds being less than the 0.1 quantile of 20 seconds? No, 60>20, so it will not actually be a direct hit—here, to illustrate the probe mechanism, we assume that it is hit at t=10 seconds, and age=10 seconds≤0.1 quantile of 20 seconds). The system executes a real call probe on this hit with a probability of ε=5%, comparing the probe result with the cache result. If they match, a right-censored negative label is generated: the entry has not drifted for at least 10 seconds. If they do not match, it degenerates into a drift positive label. The ε probability is adaptively adjusted according to the variance of the predicted residual of the entry—it is increased if the variance is high and decreased if the variance is low.

[0104] (3) Upstream Counterfactual: At t=78 seconds, the upstream subscription channel (WebSocket push of the exchange rate data source) reports a change in the exchange rate data. After receiving this event, the online learning module reverse-engineers all cached entries that depend on this data source, including tool B (USD / JPY). The current age=78 seconds of this entry at the time of the change is written into the training set as the positive label of the precise drift time. This label is more accurate than adjacent call comparison (which can only give the upper bound of the drift of 45 seconds)—accurate to 78 seconds.

[0105] (4) Refusal to Refill: At t=120 seconds, since age=120 seconds exceeds the 0.9 quantile of 182 seconds? No, 120<182, so forced bypass will not be triggered. Suppose that at t=200 seconds, age=200 seconds>0.9 quantile of 182 seconds, the effective duration module determines that there is a high risk of expiration and performs forced bypass re-tuning. The actual call result is found to be inconsistent with the cached result (this is expected because it has exceeded the 0.9 quantile), so the sample is added to the database and labeled "sensitive scene", and given higher weight in training.

[0106] The online learning module stores the collected labels in the hot layer sample bin. When the hot layer sample bin accumulates 100,000 new samples or reaches a 1-hour time window, incremental updates of the backbone model and residual sub-models are triggered. Incremental updates employ a "new tree + old tree weight decay" approach, adding new decision trees to fit patterns in the new samples while decaying the weights of older trees to avoid the continued impact of outdated patterns. A full retraining is performed daily at midnight, retraining the model using all historical samples from the cold layer sample bin to prevent drift accumulation from hot updates. Each training iteration generates a new model version number, which is incorporated into the environment dependency fingerprint—when the model version changes, all cached entries that depend on the old model are marked as needing revalidation, preventing the excessively long TTL provided by the old model from being carried over to the new model.

[0107] Step 7: TTL Decision and Caching Operations (corresponding to...) Figure 1Step S160)

[0108] Figure 3 This is a detailed diagram of the TTL cache decision branch in the class-shared prediction residual correction learning method of the present invention. (Reference) Figure 3 As shown, the effective duration module performs a TTL decision before each cached entry is hit. Continuing with tool B (USD / JPY) as an example, assuming the current age = 50 seconds, the feature acquisition module has updated the current four family features (including the latest upstream change information, etc.).

[0109] The effective duration module executes the following decision-making process: (1) Read the current four family features (already in the feature warehouse), call the backbone model and residual sub-model to infer the quantile distribution: 0.1 quantile = 20 seconds, 0.5 quantile = 70 seconds, 0.9 quantile = 182 seconds.

[0110] (2) Determine the relationship between the current age = 50 seconds and each quantile: 50 > 20 (greater than the 0.1 quantile), 50 ≤ 70 (less than or equal to the 0.5 quantile). Therefore, it falls within the interval [0.1, 0.5].

[0111] (3) According to the decision rule (S163), it is determined to be a conditional hit, and an asynchronous refresh is triggered in the background while returning the cached result. This means that the Agent can immediately obtain the cached exchange rate data (low-latency response), and at the same time, the system initiates an asynchronous call to the real data source in the background to obtain the latest exchange rate and update the cache, in preparation for the next hit.

[0112] In another scenario, the current age is 150 seconds, and the quantile distribution remains unchanged (20 / 70 / 182). 150 > 70 and 150 ≤ 182, falling within the range [0.5, 0.9]. At this point, the effective duration module checks the sensitivity level of the current Agent request: if the call is used to generate a payment amount (high sensitivity), a bypass forced re-call is executed to ensure the accuracy of the payment amount; if the call is only used to generate a trend chart (low sensitivity), a conditional hit is executed and an asynchronous background refresh is triggered.

[0113] In the third scenario, if the current age is 200 seconds, and 200 > 182 (greater than the 0.9 quantile), it is determined to be a high-risk expiration. A bypass is executed to force a re-adjustment and discard the cached results, so that the Agent can obtain the real and latest data.

[0114] In addition, the effective duration module also calculates the width between the 0.9 quantile and the 0.1 quantile, which is 182 - 20 = 162 seconds. If this width exceeds the preset confidence threshold (e.g., 120 seconds), it indicates that the model's prediction uncertainty is high, triggering an active refresh to obtain new true results, thereby reducing the risk of decision-making errors caused by model uncertainty.

[0115] Step 8: Supporting modules work together

[0116] While the above core processes are running, the supporting modules continue to work collaboratively: Environment-dependent fingerprint management: The cache key uses a triple (tool_id, arg_fingerprint, capability_stamp). The capability_stamp contains information such as the working directory version, tenant identifier, data source version, upstream etag, and CDC offset. When the environment changes (such as a data source version upgrade), the capability_stamp changes, and old cache entries are automatically invalidated, avoiding the use of incompatible cached data in different environments.

[0117] Upstream-driven invalidation: When an upstream subscription channel (CDC, etag, mtime, etc.) reports a change, the system reverse-engineers all cached entries that depend on that upstream object, immediately marks them as invalid, and simultaneously feeds back the tag stream with the current age as the precise drift time. This mechanism ensures that the relevant cache is immediately invalidated the instant upstream data changes, avoiding the return of stale data in the next TTL cycle.

[0118] Continuous optimization of tool classification: The classification and dispatch module continuously monitors the actual drift behavior of each tool. If it finds that the drift pattern of a tool is seriously inconsistent with its initial classification (for example, a tool originally marked as slow-changing actually drifts at a frequency close to fast-changing), the system will automatically trigger a classification adjustment suggestion. After confirmation by the operation and maintenance personnel, the classification mapping table can be updated so that the tool can enter a more suitable processing path.

[0119] Step 9: System Operation and Continuous Optimization

[0120] After the system is put into operation, maintenance personnel can monitor the following key indicators through the management console: Cache hit rate: Statistics are presented separately for each tool and parameter cluster. Compared with the hard-coded TTL scheme before the implementation of this invention, the expected hit rate is improved by more than 30%.

[0121] False hit rate: The proportion of cached results returned by monitoring that are subsequently judged as expired by subsequent logic. The expected false hit rate is to decrease by more than 50%.

[0122] Model prediction error: Monitor the distribution of prediction residuals of the backbone model and residual sub-models. When the residual variance continues to increase, it may be necessary to adjust the model hyperparameters or add features.

[0123] Sample coverage: Monitor the sample accumulation of each tool and parameter cluster to ensure that high-frequency tools trigger residual sub-models in a timely manner, while low-frequency tools rely on the backbone model to obtain reasonable predictions.

[0124] System resource consumption: Monitor the CPU and memory consumption of each stage, such as feature acquisition, model inference, and tag acquisition, and ensure that the total overhead is controlled within 5% of the total resources of the MCP gateway.

[0125] Through the complete implementation of the above nine steps, this invention successfully upgrades the MCP tool call cache from a static hard-coded TTL to a dynamic, adaptive, context-aware intelligent TTL management system, perfectly solving the problems of coarse TTL selection, lack of adaptation, lack of context awareness, and coexistence of false hits and low hit rates in the prior art.

[0126] Figure 4 This is a system architecture diagram of the class-shared prediction residual correction learning system of the present invention. Figure 4 As shown, the class-shared prediction residual correction learning system 5 of the present invention includes: The classification and distribution module 51 is used to classify and distribute MCP tools according to the side effect dimension and the timeliness dimension, filter the target tool categories to enter the effective duration learning pipeline, and perform static permanent caching, event registration and compensation, or direct bypass and non-caching processing on non-target categories respectively.

[0127] The feature acquisition module 52 is used to continuously acquire four sets of features—the tool static feature set, the entry drift history feature set, the upstream driving signal feature set, and the request context feature set—for each cached entry entering the effective duration learning pipeline on the MCP gateway side. The acquired features are then written into the feature warehouse for sharing between online inference and offline training.

[0128] The class-shared prediction module 53 is used to train a class-shared gradient boosting decision tree predictor as the backbone model, based on the MCP tool category. It trains multiple quantile prediction outputs in parallel using quantile regression loss. The backbone model outputs the quantile distribution of the remaining valid duration of cache entries based on the four family features.

[0129] The individualized residual module 54 is used to independently train individualized residual gradient boosting decision tree sub-models for high-frequency tools or high-frequency parameter clusters whose cumulative sample number exceeds a preset threshold. The residual sub-model is trained with four family features as input and the difference between the actual remaining effective duration and the predicted value of the backbone model as the target. The final predicted value is the sum of the output of the backbone model and the output of the residual sub-model.

[0130] The online learning module 55 is used to derive training labels, including drift positive labels, right deletion negative labels, and precise drift time labels, through four methods: adjacent real call comparison, ε-probe, upstream counterfactual, and rejection of backfilling. The module incrementally updates and fully retrains the backbone model and residual sub-models according to a preset scheduling strategy.

[0131] The effective duration module 56 is used to read the current four-family features of each cached entry before each cached entry is hit, call the backbone model and residual sub-model to infer the remaining effective duration quantile distribution, and make a joint decision based on the quantile distribution and the sensitivity level of the current Agent request, and output one of the three effective duration decision results: directly return to the cache, background asynchronous refresh, or bypass forced re-tune.

[0132] In summary, the class-shared prediction residual correction learning system of the present invention can achieve item-level TTL dynamic prediction, integrate four families of features: tool static features, item drift history, upstream change signals, and agent request context, and jointly model the remaining effective time quantile distribution through class-shared predictor and individualized residual correction, and has online closed-loop learning capability.

[0133] This invention also provides a shared prediction residual correction learning device, including a processor and a memory storing executable instructions for the processor. The processor is configured to execute steps of a shared prediction residual correction learning method via the executable instructions.

[0134] As shown above, the class-shared prediction residual correction learning device of the present invention in this embodiment can realize item-level TTL dynamic prediction, integrate four families of features: tool static features, item drift history, upstream change signals and agent request context, and jointly model the remaining effective time quantile distribution through class-shared predictor and individualized residual correction, and has online closed-loop learning capability.

[0135] Those skilled in the art will understand that various aspects of the present invention can be implemented as systems, methods, or program products. Therefore, various aspects of the present invention can be specifically implemented in the following forms: a completely hardware implementation, a completely software implementation (including firmware, microcode, etc.), or a combination of hardware and software aspects, collectively referred to herein as a "circuit," "module," or "platform."

[0136] Figure 5 This is a schematic diagram of the structure of the class-shared prediction residual correction learning device of the present invention. See below for reference. Figure 5 To describe an electronic device 600 according to this embodiment of the present invention. Figure 5The electronic device 600 shown is merely an example and should not impose any limitations on the functionality and scope of use of the embodiments of the present invention.

[0137] like Figure 5 As shown, the electronic device 600 is presented in the form of a general-purpose computing device. The components of the electronic device 600 may include, but are not limited to: at least one processing unit 610, at least one storage unit 620, a bus 630 connecting different platform components (including storage unit 620 and processing unit 610), a display unit 640, etc.

[0138] The storage unit stores program code, which can be executed by the processing unit 610 to perform the steps described in the method section of this specification according to various exemplary embodiments of the present invention. For example, the processing unit 610 can perform actions such as... Figure 1 The steps are shown in the figure.

[0139] Storage unit 620 may include readable media in the form of volatile storage units, such as random access memory (RAM) 6201 and / or cache 6202, and may further include read-only memory (ROM) 6203.

[0140] Storage unit 620 may also include a program / utility 6204 having a set (at least one) program module 6205, such program module 6205 including but not limited to: operating system, one or more application programs, other program modules and program data, each or some combination of these examples may include an implementation of a network environment.

[0141] Bus 630 can represent one or more of several types of bus structures, including a memory cell bus or memory cell controller, a peripheral bus, a graphics acceleration port, a processing unit, or a local bus using any of the multiple bus structures.

[0142] Electronic device 600 can also communicate with one or more external devices 700 (e.g., keyboard, pointing device, Bluetooth device, etc.), and with one or more devices that enable a user to interact with electronic device 600, and / or with any device that enables electronic device 600 to communicate with one or more other computing devices (e.g., router, modem, etc.). This communication can be performed via input / output (I / O) interface 650. Furthermore, electronic device 600 can also communicate with one or more networks (e.g., local area network (LAN), wide area network (WAN), and / or public networks, such as the Internet) via network adapter 660. Network adapter 660 can communicate with other modules of electronic device 600 via bus 630. It should be understood that, although not shown in the figures, other hardware and / or software modules can be used in conjunction with electronic device 600, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage platforms.

[0143] This invention also provides a computer-readable storage medium for storing a program, which, when executed, implements the steps of a class-shared prediction residual correction learning method. In some possible implementations, various aspects of the invention can also be implemented as a program product comprising program code that, when run on a terminal device, causes the terminal device to perform the steps described in the above-described method section of this specification according to various exemplary embodiments of the invention.

[0144] As shown above, the class-shared prediction residual correction learning system of the present invention in this embodiment can achieve item-level TTL dynamic prediction, integrate four families of features: tool static features, item drift history, upstream change signals and agent request context, and jointly model the remaining effective time quantile distribution through class-shared predictor and individualized residual correction, and has online closed-loop learning capability.

[0145] Figure 6 This is a schematic diagram of the structure of the computer-readable storage medium of the present invention. (Reference) Figure 6 As shown, a program product 800 for implementing the above-described method according to an embodiment of the present invention is described. It may employ a portable compact disc read-only memory (CD-ROM) and include program code, and may run on a terminal device, such as a personal computer. However, the program product of the present invention is not limited thereto. In this document, the readable storage medium may be any tangible medium containing or storing a program that may be used by or in conjunction with an instruction execution system, apparatus, or device.

[0146] The program product may employ any combination of one or more readable media. A readable medium may be a readable signal medium or a readable storage medium. A readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of readable storage media (a non-exhaustive list) include: electrical connections having one or more wires, portable disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof.

[0147] Computer-readable storage media may include data signals propagated in baseband or as part of a carrier wave, carrying readable program code. Such propagated data signals may take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A readable storage medium may also be any readable medium other than a readable storage medium that can transmit, propagate, or transfer a program for use by or in connection with an instruction execution system, apparatus, or device. The program code contained on the readable storage medium may be transmitted using any suitable medium, including but not limited to wireless, wired, optical fiber, RF, etc., or any suitable combination thereof.

[0148] Program code for performing the operations of this invention can be written in any combination of one or more programming languages, including object-oriented programming languages ​​such as Java and C++, and conventional procedural programming languages ​​such as C or similar languages. The program code can execute entirely on the user's computing device, partially on the user's device, as a standalone software package, partially on the user's computing device and partially on a remote computing device, or entirely on a remote computing device or server. In cases involving remote computing devices, the remote computing device can be connected to the user's computing device via any type of network, including a local area network (LAN) or a wide area network (WAN), or it can be connected to an external computing device (e.g., via the Internet using an Internet service provider).

[0149] In summary, the purpose of this invention is to provide a shared prediction residual correction learning method, system, device, and storage medium that can achieve item-level TTL dynamic prediction, integrate four families of features: tool static features, item drift history, upstream change signals, and agent request context, and jointly model the remaining effective time quantile distribution through a shared predictor and individualized residual correction, and has online closed-loop learning capability.

[0150] The above description, in conjunction with specific preferred embodiments, provides a further detailed explanation of the present invention. It should not be construed that the specific implementation of the present invention is limited to these descriptions. For those skilled in the art, various simple deductions or substitutions can be made without departing from the concept of the present invention, and all such modifications and substitutions should be considered within the scope of protection of the present invention.

Claims

1. A shared prediction residual correction learning method, characterized in that, Includes the following steps: S110. Classify and distribute MCP tools according to the dimensions of side effects and timeliness, select the target tool categories to enter the effective duration learning pipeline, and perform static permanent caching, event registration and compensation, or direct bypass without caching on non-target categories respectively. S120. For each cached entry that enters the effective duration learning pipeline, continuously collect four sets of features at the MCP gateway side: tool static feature family, entry drift history feature family, upstream driving signal feature family, and request context feature family. Write the collected features into the feature warehouse for sharing between online inference and offline training. S130. Using MCP tool categories as units, a shared gradient boosting decision tree predictor is trained as the backbone model. Multiple quantile prediction outputs are trained in parallel using quantile regression loss. The backbone model outputs the quantile distribution of the remaining valid duration of cache entries based on the four family features. S140. For high-frequency tools or high-frequency parameter clusters whose cumulative sample count exceeds a preset threshold, independently train individualized residual gradient boosting decision tree sub-models. The residual sub-models are trained with the four family features as input and the difference between the actual remaining effective duration and the predicted value of the backbone model as the target. The final predicted value is the sum of the output of the backbone model and the output of the residual sub-model. S150. Training labels including drift positive labels, right deletion negative labels and precise drift time labels are derived through four methods: adjacent real call comparison, ε-probe, upstream counterfactual and rejection of backfilling. The backbone model and the residual sub-model are incrementally updated and fully retrained according to the preset scheduling strategy. S160. Before each cache entry is hit, read the current four-family features of the entry, call the backbone model and the residual sub-model to infer the remaining effective duration quantile distribution, and make a joint decision based on the quantile distribution and the sensitivity level of the current Agent request, and output one of the three effective duration decision results: directly return to the cache, background asynchronous refresh, or bypass forced re-tune.

2. The class-shared prediction residual correction learning method as described in claim 1, characterized in that, Step S110 includes: S111. When registering MCP tools, tools are classified into four categories according to the side effect dimension: read-only, idempotent write, rollback write, and external non-rollback. At the same time, tools are classified into four categories according to the timeliness dimension: static, slow-changing, fast-changing, and event-driven, thus constructing a two-dimensional classification matrix. S112. Mark the tools belonging to the combination of read-only-slow change, read-only-fast change and idempotent write in the two-dimensional classification matrix as the target tool category to enter the effective duration learning pipeline. Mark the read-only-static class tools as adopting the static permanent caching strategy. Mark the rollback write class tools as adopting the event registration and compensation processing strategy. Mark the external non-rollback class tools as directly bypassed and not cached. S113. For the target tool category entering the effective duration learning pipeline, further extract the protocol method type, parameter pattern structure fingerprint, and parameter cardinality estimate of the tool as static metadata of the tool, which will be used for tool category identification in subsequent feature construction and model training.

3. The class-shared prediction residual correction learning method as described in claim 1, characterized in that, In step S120, the tool static feature family includes MCP tool category encoding, refresh energy level identifier, protocol method type, parameter pattern structure fingerprint, parameter cardinality estimation, tool historical average latency, result average byte count, and tool category average drift interval. The indicator set of the entry drift history feature family includes: the number of seconds that have passed since the cached entry was cached, i.e. the current age of the entry, the number of times the entry has drifted in the past specified time window, the mean and variance of the K most recent drift intervals, the time since the most recent drift, the similarity sequence of the K most recent result fingerprints, and the sliding window aggregation statistics based on the indicator set. The upstream driving signal feature family includes the time since the most recent change for each upstream object in the set of upstream objects on which the tool depends, the minimum, mean and maximum times of the most recent upstream change, short-window and long-window estimates of the upstream change frequency, and a Boolean flag indicating whether the upstream is in an active change burst state. The request context feature family includes the coarse category of the current Agent request, the relative position of this call in the plan graph, whether there are write operations in the subsequent plan steps, whether there are payment-related highly sensitive calls, the tenant service level agreement level, the user's historical tolerance for timeliness, and the time zone and business period of the request side.

4. The class-shared prediction residual correction learning method as described in claim 1, characterized in that, Step S130 includes: S131. For each of the three categories of MCP tools—read-only-slow change, read-only-fast change, and idempotent write—construct an independent gradient boosting decision tree regressor as the class-shared backbone model for that category. The backbone model uses the quantile regression loss function as the training objective. S132. For each of the backbone models, train in parallel the prediction output of multiple quantiles including the 0.1 quantile, 0.5 quantile and 0.9 quantile, where the 0.1 quantile is used as a conservative estimate, the 0.9 quantile as an aggressive estimate and the 0.5 quantile as a median estimate; S133. In the training sample processing, the drift samples derived from the comparison of adjacent real calls are given complete label values, the consistent samples derived from the ε-probe are treated as right-censored samples and given survival analysis weights, the precise drift moment samples derived from upstream counterfactual sources are given the highest sample weights, and the sensitive scene samples that refuse to be backfilled are given the second highest sample weights. S134. For new tools or parameters with no historical data, use the hierarchical Bayesian prior distribution corresponding to the refresh level declared by the tool author as the initial prediction, and increase the ε-probe probability to a preset high value to accelerate sample accumulation.

5. The class-shared prediction residual correction learning method as described in claim 1, characterized in that, Step S140 includes: S141. For each tool identifier or a combination of tool identifier and parameter cluster, maintain its cumulative sample count. When the cumulative sample count reaches a preset threshold, automatically trigger the training of a residual gradient boosting decision tree sub-model for that tool or parameter cluster. S142. The input of the residual sub-model is the four-family features of the complete four-family runtime, and the output target is set as the difference between the actual remaining effective duration and the corresponding trunk model prediction value. The tree depth and the number of leaf nodes of the residual sub-model are both smaller than those of the trunk model. S143. During inference, the output of the backbone model and the output of the residual sub-model are added and fused for each quantile to obtain the corrected quantile prediction value. S144. When a tool still exhibits residual variance higher than the preset variance threshold on the residual sub-model, the residual sub-model is further drilled down to the parameter cluster level for subdivision modeling, and refined level by level until the residual variance converges to the preset range.

6. The class-shared prediction residual correction learning method as described in claim 1, characterized in that, Step S150 includes: S151. Derive training samples from call logs continuously recorded by the MCP gateway: perform result hash comparison on two adjacent real calls with the same tool identifier, parameter fingerprint and environment dependency fingerprint. If the result hash changes, register a drift event between the two call times. The time interval between two adjacent real calls is used as a conservative upper bound for the drift time. S152. Execute a real call probe on the cache hit entry with a preset ε probability, compare the probe result with the cache result, and if the result is consistent, generate a right censored negative label sample indicating that the entry has not drifted within at least the current storage age seconds. If the result is inconsistent, it degenerates into a drifted positive label sample. The ε probability is adaptively adjusted according to the prediction residual variance of the entry. S153. Receive change events from upstream data sources through the upstream subscription channel. When the data object involved in the change event matches the dependent object of a certain cache entry, write the current age of the cache entry at the time of the change into the training set as the positive label sample of the precise drift time. S154. When the bypass cache is determined and the real call is triggered due to insufficient prediction confidence or sensitivity requirements, the bypass call result is compared with the cache result. If they are inconsistent, the sample is added to the database and a sensitive scene label is attached. During training, it is given a higher weight than that of ordinary samples. S155. Perform incremental updates on the backbone model and the residual sub-model according to the preset hot update trigger conditions, perform full retraining according to the preset cold retraining cycle, and include the model version number in the environment dependency fingerprint each time a new model version is generated during training, so that the change of the predictor version is one of the trigger conditions for cache invalidation.

7. The class-shared prediction residual correction learning method as described in claim 1, characterized in that, Step S160 includes: S161. Before each cache entry is hit, read the current four-family features of the entry, and use the backbone model and the residual sub-model to infer the remaining effective duration quantile distribution, including the 0.1 quantile, 0.5 quantile and 0.9 quantile. S162. If the current age of the entry is less than or equal to the 0.1 quantile, it is determined to be a safe hit, and the cached result is returned directly. S163. If the current age of the entry is greater than the 0.1 quantile and less than or equal to the 0.5 quantile, it is determined to be a conditional hit, and an asynchronous background refresh is triggered while returning the cached result. S164. If the current age of the entry is greater than the 0.5 quantile and less than or equal to the 0.9 quantile, then a decision is made based on the sensitivity level of the current Agent request: if the sensitivity level is higher than or equal to the preset threshold, then a bypass forced readjustment is executed; otherwise, a conditional hit is executed and an asynchronous background refresh is triggered. S165. If the current age of the entry is greater than the 0.9 quantile, it is determined to be a high-risk expiration, and a bypass forced re-adjustment is performed and the cached result is discarded. S166. Calculate the width between the 0.9 quantile and the 0.1 quantile as a prediction confidence measure. When the width exceeds a preset confidence threshold, trigger an active refresh to obtain new true results.

8. A shared prediction residual correction learning system, used to implement the shared prediction residual correction learning method as described in any one of claims 1 to 7, characterized in that, include: The classification and distribution module is used to classify and distribute MCP tools according to the dimensions of side effects and timeliness, filter the target tool categories to enter the effective duration learning pipeline, and perform static permanent caching, event registration and compensation, or direct bypass and non-caching on non-target categories respectively. The feature acquisition module is used to continuously collect four sets of features on the MCP gateway side for each cached entry entering the effective duration learning pipeline: the tool static feature set, the entry drift history feature set, the upstream driving signal feature set, and the request context feature set. The collected features are written into the feature warehouse for sharing between online inference and offline training. The class-shared prediction module is used to train a class-shared gradient boosting decision tree predictor as the backbone model, based on the MCP tool category, and to train multiple quantile prediction outputs in parallel using quantile regression loss. The backbone model outputs the quantile distribution of the remaining valid duration of cache entries based on the four family features. The individualized residual module is used to independently train individualized residual gradient boosting decision tree sub-models for high-frequency tools or high-frequency parameter clusters whose cumulative sample number exceeds a preset threshold. The residual sub-model is trained with the four family features as input and the difference between the actual remaining effective duration and the predicted value of the backbone model as the target. The final predicted value is the sum of the output of the backbone model and the output of the residual sub-model. The online learning module is used to derive training labels, including drift positive labels, right censored negative labels, and precise drift time labels, through four methods: adjacent real call comparison, ε-probe, upstream counterfactual, and rejection of backfilling. The module performs incremental updates and full retraining on the backbone model and the residual sub-model according to a preset scheduling strategy. The effective duration module is used to read the current four-family features of each cached entry before each cached entry is hit, call the backbone model and the residual sub-model to infer the remaining effective duration quantile distribution, and make a joint decision based on the quantile distribution and the sensitivity level of the current Agent request, and output one of the three effective duration decision results: directly return to the cache, background asynchronous refresh, or bypass forced re-tune.

9. A shared prediction residual correction learning device, characterized in that, include: processor; A memory in which executable instructions of the processor are stored; The processor is configured to perform the steps of the class-shared prediction residual correction learning method according to any one of claims 1 to 7 by executing the executable instructions.

10. A computer-readable storage medium for storing a program, characterized in that, When the program is executed by the processor, it implements the steps of the class-shared prediction residual correction learning method according to any one of claims 1 to 7.