Hybrid ai adaptive optimization system and method based on agent context engineering

The hybrid AI adaptive optimization system based on agent context engineering solves the problems of context simplification loss, semantic degradation, and high computational cost in long-cycle tasks for large language models. It realizes structured knowledge management and self-optimization, and improves the stability and efficiency of the model.

CN121301536BActive Publication Date: 2026-04-21SHANGHAI LINGSHU INTELLIGENT TECH CO LTD +2
View PDF 1 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
SHANGHAI LINGSHU INTELLIGENT TECH CO LTD
Filing Date
2025-12-15
Publication Date
2026-04-21

AI Technical Summary

Technical Problem

Existing context optimization techniques based on large language models suffer from problems in long-cycle tasks, such as loss of information due to context simplification, semantic collapse due to overall rewriting, high computational cost, poor stability, and lack of structured evolution mechanisms.

Method used

A hybrid AI adaptive optimization system based on agent context engineering is adopted. By constructing a structured context knowledge base containing knowledge units of metadata and content, incremental updates are performed using generation, feedback analysis, and knowledge integration modules. A growth-refinement strategy and a distributed storage architecture are employed to achieve continuous accumulation and traceable evolution of knowledge.

Benefits of technology

To prevent context collapse and knowledge loss, improve the model's self-learning and adaptability, enhance inference performance and task success rate, reduce computational costs and latency, and enhance the system's interpretability and security.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121301536B_ABST
    Figure CN121301536B_ABST
Patent Text Reader

Abstract

This invention provides a hybrid AI adaptive optimization system based on agent context engineering, comprising a context knowledge base, a generation module, a feedback analysis module, and a knowledge integration module. This invention overcomes the problems of context simplification leading to information loss (Brevity Bias), context collapse due to overall rewriting, and high latency, high cost, and instability in the learning process inherent in existing Large Language Model (LLM)-based context optimization techniques.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the fields of Artificial Intelligence (AI) and Natural Language Processing (NLP), and in particular to a hybrid AI adaptive optimization system and method based on agent context engineering. Background Technology

[0002] With the rapid development of Large Language Models (LLMs), LLM-based artificial intelligence systems (including agents, compound AI systems, retrieval augmentation generation (RAG) systems, etc.) have made significant progress in natural language understanding, knowledge reasoning, and task execution.

[0003] Currently, there are two main types of performance optimization paths:

[0004] 1. Weighting optimization

[0005] This involves improving model performance through further fine-tuning, efficient parameter adjustment (such as LoRA, Prefix-tuning), or continuous training. While these methods can improve model performance, they suffer from high computational costs, long iteration cycles, and susceptibility to catastrophic forgetting, making them unsuitable for frequent online adaptations or self-learning scenarios.

[0006] 2. Context-level optimization

[0007] This involves modifying model behavior by optimizing input prompts, system prompts, contextual memory, or task descriptions, without altering the model weights. This type of approach has become a major research direction in recent years, and its representative techniques include:

[0008] The Reflexion method: The model reflects on its own error trajectories and generates improvement suggestions to update subsequent prompts.

[0009] The GEPA (Genetic-Pareto Prompt Evolution) method uses a genetic search and reflection mechanism to iteratively optimize prompts in multiple rounds, achieving interpretable performance improvements.

[0010] The Dynamic Cheatsheet method maintains an external dynamic memory (CheatsheetMemory) during the inference phase to continuously accumulate task strategies, code snippets, and experience for reuse in subsequent tasks.

[0011] These methods achieve an interpretable optimization path of "frozen model parameters and malleable behavior" through natural-language feedback or external storage, enabling LLM to adaptively adjust task strategies at runtime.

[0012] Structure and working principle of existing technology

[0013] like Figure 2 As shown, existing context optimization systems generally include the following modules:

[0014] Input module: Receives user task requests (Query) and initial context (Prompt / Memory);

[0015] Language model inference module: Generates inference paths, tool calls, or text output based on input;

[0016] Feedback module: Extracts feedback signals from execution results (including errors, logs, external API call responses, etc.);

[0017] Context rewriting module: Converts feedback signals into natural language descriptions, and the model performs a complete rewrite of the original context.

[0018] Update module: Uses the newly generated context as input for the next round of tasks to achieve iterative optimization.

[0019] Its working principle can be summarized as: task execution → result evaluation → self-reflection → context rewriting → next round of execution. This cycle can achieve self-learning and strategy transfer in multiple tasks.

[0020] Problems and defects of existing technologies

[0021] While the above methods have achieved some success in terms of interpretability and flexibility, the following prominent problems still exist in large-scale applications and long-term tasks:

[0022] 1. Information Simplification Bias

[0023] Existing context optimization algorithms (such as GEPA and TextGrad) typically pursue concise and generalizable prompts to reduce computational resource consumption and improve generalization ability. However, this over-compression strategy often leads to the discarding of key information such as domain knowledge, error patterns, and tool usage details during multiple rounds of rewriting.

[0024] For example, in programming analysis or financial reasoning tasks, optimized prompts are often compressed into a few generic instructions (such as "analyze the input and generate results"), thereby losing task-specific contextual constraints and leading to a decline in system performance.

[0025] 2. Semantic Degradation

[0026] In schemes employing a "total rewrite" mechanism, each iteration generates a new, complete context directly from the Large Language Model (LLM). As the length of the context increases, the model tends to over-summarize the content, resulting in shorter, more generalized text (e.g., reduced from 18,000 tokens to less than 200 tokens), thus causing the loss of a significant amount of valuable strategy and knowledge information.

[0027] Experimental results show that this semantic degradation phenomenon leads to a significant decrease in task success rate, even lower than the baseline performance of the model without context adaptation.

[0028] 3. Overall rewriting has high computational overhead and poor stability.

[0029] Each complete rewrite requires generating a large amount of new text, resulting in high computational load and latency. Due to the lack of a structured incremental update mechanism, the system is prone to introducing semantic noise or redundant content during multiple rounds of self-learning, leading to instability in the model's knowledge base structure and significant performance fluctuations.

[0030] 4. Lack of structured evolutionary mechanisms

[0031] Current context updates are mostly performed through the free generation of natural language text, lacking unit-based management of knowledge content, indexable organization, and semantic deduplication mechanisms. This makes it difficult to systematically maintain contextual knowledge, track its source and change records, and hinders subsequent manual review and compliance interpretation.

[0032] In summary, while current context-optimized adaptive language modeling methods can improve model performance in the short term, they still face technical bottlenecks such as excessive context compression, knowledge loss, performance instability, and high computational costs when dealing with long-cycle tasks, industry-specific scenarios, or high-reliability applications. Summary of the Invention

[0033] This invention provides a hybrid AI adaptive optimization system and method based on agent context engineering, which overcomes the problems of context simplification loss (Brevity Bias), context collapse caused by overall rewriting, and high latency, high cost and instability in the learning process in existing context optimization techniques based on large language model (LLM).

[0034] To achieve the above objectives, the present invention adopts the following technical solution:

[0035] A hybrid AI adaptive optimization system based on agent context engineering includes:

[0036] A contextual knowledge base is used to store structured knowledge units. Each knowledge unit consists of two parts: metadata and content. The metadata describes the source, creation timestamp, number of times it is used, and confidence level of the knowledge unit. The content stores task-related strategies, rules, common error correction methods, or tool call examples.

[0037] The generation module is used to receive user query requests, retrieve matching knowledge units from the context knowledge base, generate reasoning trajectories, tool call instructions or candidate results based on the query requests and matching knowledge units, and simultaneously label the knowledge units used in the generation process and the knowledge units that lead to misjudgments.

[0038] The feedback analysis module is used to analyze the inference trajectory and its corresponding execution feedback, extract reusable strategies, error patterns and correction suggestions, and form incremental update candidate information, namely Delta dataset;

[0039] A knowledge integration module is used to process the Delta dataset and then write it back to the context knowledge base for updating.

[0040] The usage of knowledge units annotated by the generation module is synchronized to the feedback analysis module, providing a basis for the feedback analysis module to extract strategies and make correction suggestions; the updated context knowledge base of the knowledge integration module provides an updated knowledge source for the generation module to subsequently retrieve and match knowledge units.

[0041] In this specification, the knowledge integration module processes the Delta dataset using incremental local updates, specifically: only the knowledge units involved in the Delta dataset are updated at the field level; the field-level updates include supplementing key phrases in the descriptive information of the knowledge unit content, handling key conflicts in code snippets or tool templates, and adjusting the usage frequency and confidence level of the knowledge unit metadata.

[0042] In this specification, the knowledge integration module is also used to perform growth-refinement operations: during the growth phase, newly added knowledge units or partially updated knowledge units determined by the difference threshold are added to the context knowledge base; during the refinement phase, when preset triggering conditions are met, the knowledge units in the context knowledge base are clustered for deduplication, low-confidence knowledge units are frozen or archived, the index is rebuilt, and a version snapshot of the context knowledge base is generated; the preset triggering conditions include any one of the following: the number of active knowledge units in the context knowledge base reaches 5000, the length of the concatenated context reaches 8000 tokens, and the success rate of the recent 100 tasks drops to 5%.

[0043] In this specification, the processing of the Delta dataset by the knowledge integration module also includes semantic deduplication: calculating the semantic similarity between candidate knowledge units in the Delta dataset and existing knowledge units in the context knowledge base; when the semantic similarity is less than 0.82, the candidate knowledge unit is added to the context knowledge base as a new knowledge unit; when the semantic similarity is greater than or equal to 0.82, the existing knowledge units are updated.

[0044] In this specification, the context knowledge base adopts a distributed storage architecture, which supports multi-node synchronous updates of knowledge units, knowledge unit version rollback, and redundant backup, so as to improve the reliability and fault tolerance of the context knowledge base.

[0045] Hybrid AI adaptive optimization methods based on agent context engineering include:

[0046] Step 1: Offline preheating to build an initial context knowledge base;

[0047] The first batch of knowledge units are generated based on historical task samples, rule base and documents. Embedding vectors are generated for knowledge units and a hybrid index is established. Semantic deduplication threshold and incremental batch size are marked to form an initial context knowledge base.

[0048] Step 2: Task reception and knowledge retrieval;

[0049] Upon receiving a user query request, the system selects the Top-K matching knowledge units from the initial or updated context knowledge base using a combination of keyword matching and semantic similarity retrieval.

[0050] Step 3: Generate execution and trajectory records;

[0051] Based on the query request and the matched Top-K knowledge units, a reasoning trajectory, tool call instructions or candidate results are generated, and the usage and execution feedback of each knowledge unit are recorded.

[0052] Step 4: Feedback extraction generates the Delta dataset;

[0053] Analyze the reasoning trajectory and execution feedback in step 3, extract reusable strategies, error patterns and correction suggestions, mark the effective and ineffective times of knowledge units, and form incremental update candidate information, namely Delta dataset;

[0054] Step 5: Knowledge integration and updating of the knowledge base;

[0055] The Delta dataset is subjected to semantic deduplication and field-level merging, and the processed knowledge units are written back to the context knowledge base for updating.

[0056] Step 6: Growth - Refinement and Optimization of the Knowledge Base;

[0057] When the context knowledge base meets the preset triggering conditions, the knowledge units in the knowledge base are clustered and deduplicated, low-confidence units are frozen or archived, the index is rebuilt, and a knowledge base version snapshot is generated.

[0058] In this specification, step 4, which marks the number of valid and invalid times of a knowledge unit, further includes: calculating the decay of the historical valid and invalid times of the knowledge unit according to the time decay rule with a half-life of 30 days, and determining the confidence level of the knowledge unit by combining the source credibility of the knowledge unit; wherein, when the execution feedback is successful, it is counted as a valid number, and when the execution feedback is failed or misleading, it is counted as an invalid number, and a knowledge unit that is marked as misleading 3 times in a row is automatically downgraded.

[0059] In this specification, after selecting the Top-K matching knowledge units in step 2, the content of the Top-K knowledge units is segmented and spliced ​​together. During the splicing process, the KV-cache reuse mechanism is enabled to reduce the computational overhead and response latency of long context processing. The K value of the Top-K ranges from 8 to 32.

[0060] In this manual, the field-level merging process in step 5 is as follows: the description information field of the knowledge unit retains the longest content and adds key phrases; the code snippet or tool template field is merged according to keywords; and the usage frequency and confidence fields in the metadata are updated according to the annotation results in step 4.

[0061] In this manual, the preset triggering conditions in step 6 include any one of the following: the number of active knowledge units in the context knowledge base reaches 5,000, the length of the concatenated context reaches 8,000 tokens, and the success rate of the recent 100 tasks drops to 5%.

[0062] In summary, the present invention has at least the following beneficial effects:

[0063] 1. Preventing context collapse and knowledge loss: By introducing a structured, incremental context update mechanism, knowledge is organized and stored in the form of "bullets", avoiding semantic compression and experience loss caused by traditional whole rewriting, and realizing continuous accumulation and traceable evolution of context.

[0064] 2. Enhance the model's self-learning and adaptive capabilities: Through a three-stage cycle of "Generator - Reflector - Curator", the model can automatically extract experience, correct strategies, and optimize context based on task execution results, achieving self-improvement under unsupervised or weakly supervised conditions.

[0065] 3. Improve inference performance and task success rate: Through the structured evolution of context and the multi-round "grow-and-refine" mechanism, the model maintains stable performance improvement in multi-round inference, tool invocation and domain inference.

[0066] 4. Reduce computational cost and latency: By adopting incremental context update and non-LLM-based merging algorithm, the overhead of context rewriting and inference latency are significantly reduced, achieving low-cost and high-efficiency online adaptation.

[0067] 5. Enhance the interpretability and security of the system: By organizing the context into entries and metadata, the behavioral decision-making path and knowledge evolution process of the model can be traced and audited, which is conducive to building a compliant and trustworthy enterprise-level AI system. Attached Figure Description

[0068] To more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings used in the following description of the embodiments will be briefly introduced. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0069] Figure 1 This is a schematic diagram of the hybrid AI adaptive optimization system based on agent context engineering involved in this invention.

[0070] Figure 2 A schematic diagram for optimizing the system for the existing context.

[0071] Figure 3 This is a schematic diagram illustrating the relationship between the data structures involved in this invention.

[0072] Figure 4 This is a schematic diagram of the timing of the method flow involved in this invention. Detailed Implementation

[0073] In the following description, only certain exemplary embodiments are briefly described. As those skilled in the art will recognize, the described embodiments can be modified in various ways without departing from the spirit or scope of the embodiments of the invention. Therefore, the drawings and description are considered to be exemplary in nature and not restrictive.

[0074] The following disclosure provides many different implementations or examples for carrying out different structures of the embodiments of the present invention. To simplify the disclosure of the embodiments of the present invention, specific examples of components and arrangements are described below. Of course, these are merely examples and are not intended to limit the embodiments of the present invention. Furthermore, reference numerals and / or reference letters may be repeated in different examples of the embodiments of the present invention; such repetition is for simplification and clarity and does not in itself indicate a relationship between the various implementations and / or arrangements discussed.

[0075] The embodiments of the present invention will now be described in detail with reference to the accompanying drawings.

[0076] like Figure 1 As shown, this embodiment provides a hybrid AI adaptive optimization system based on agent context engineering, including:

[0077] A contextual knowledge base is used to store structured knowledge units. Each knowledge unit consists of two parts: metadata and content. The metadata describes the source, creation timestamp, number of times it is used, and confidence level of the knowledge unit. The content stores task-related strategies, rules, common error correction methods, or tool call examples.

[0078] The generation module is used to receive user query requests, retrieve matching knowledge units from the context knowledge base, generate reasoning trajectories, tool call instructions or candidate results based on the query requests and matching knowledge units, and label the knowledge units used in the generation process and knowledge units that may cause misjudgment.

[0079] The feedback analysis module is used to receive the inference trajectory and the corresponding execution feedback output by the generation module, analyze the inference trajectory and execution feedback, extract reusable strategies, error patterns and correction suggestions, and form incremental update candidate information (i.e. Delta dataset).

[0080] The knowledge integration module is used to receive the Delta dataset output by the feedback analysis module, process the Delta dataset, and write it back to the context knowledge base.

[0081] The usage of knowledge units annotated by the generation module is synchronized to the feedback analysis module, providing a basis for the feedback analysis module to extract strategies and make correction suggestions; the updated context knowledge base of the knowledge integration module provides an updated knowledge source for the generation module to subsequently retrieve and match knowledge units.

[0082] In some embodiments, the knowledge integration module processes the Delta dataset as an incremental local update, specifically: only the knowledge units involved in the Delta dataset are updated at the field level, without rewriting the context knowledge base as a whole; the field-level update includes supplementing key phrases in the descriptive information of the knowledge unit content, handling key conflicts in code snippets or tool templates (when there is a key conflict, the latest and verified version is taken), and adjusting the usage frequency and confidence of the knowledge unit metadata.

[0083] In some embodiments, the knowledge integration module is further configured to perform a growth-refinement operation: during the growth phase, newly added knowledge units or partially updated knowledge units determined by a difference threshold are appended to the context knowledge base; during the refinement phase, when a preset trigger condition is met, the knowledge units in the context knowledge base are clustered for deduplication, low-confidence knowledge units are frozen or archived, the index is rebuilt, and a version snapshot of the context knowledge base is generated; the preset trigger condition includes any one of the following: the number of active knowledge units in the context knowledge base reaches 5000, the length of the concatenated context reaches 8000 tokens, and the success rate of the recent 100 tasks drops to 5%.

[0084] In some embodiments, the processing of the Delta dataset by the knowledge integration module further includes semantic deduplication: calculating the semantic similarity (using cosine similarity) between candidate knowledge units in the Delta dataset and existing knowledge units in the context knowledge base; when the semantic similarity is less than 0.82, adding the candidate knowledge unit as a new knowledge unit to the context knowledge base; when the semantic similarity is greater than or equal to 0.82, updating the existing knowledge units.

[0085] In some embodiments, the context knowledge base adopts a distributed storage architecture, supporting multi-node synchronous updates of knowledge units, knowledge unit version rollback, and redundant backups to improve the reliability and fault tolerance of the context knowledge base; the generation module can be replaced by a compressed large language model (such as Qwen-Tiny, Llama-Distilled) in low-computing-power environments.

[0086] Hybrid AI adaptive optimization methods based on agent context engineering include:

[0087] Step 1: Offline warm-up and construction of the initial context knowledge base - Generate the first batch of knowledge units (the knowledge units include metadata and content) based on historical task samples, rule base and documents, generate embedding vectors for knowledge units and build a hybrid index, mark parameters such as semantic deduplication threshold and incremental batch size to form the initial context knowledge base;

[0088] Step 2: Task Reception and Knowledge Retrieval – Receive user query requests and select the Top-K matching knowledge units from the initial or updated context knowledge base using keyword matching combined with semantic similarity retrieval.

[0089] Step 3: Generate execution and trajectory records—Based on the query request and the matching Top-K knowledge units, generate inference trajectories, tool call instructions or candidate results, and record the usage of each knowledge unit (including used, misleading, and unused) and execution feedback (including success, failure, and partial success).

[0090] Step 4: Feedback Extraction to Generate Delta Dataset – Analyze the reasoning trajectory and execution feedback in Step 3, extract reusable strategies, error patterns and correction suggestions, mark the effective and ineffective times of knowledge units, and form incremental update candidate information (i.e. Delta dataset).

[0091] Step 5: Knowledge integration and knowledge base update—Semantic deduplication and field-level merging are performed on the Delta dataset, and the processed knowledge units are written back to the context knowledge base;

[0092] Step 6: Growth-Refinement and Optimization of Knowledge Base - When the context knowledge base meets the preset triggering conditions, the knowledge units in the knowledge base are clustered and deduplicated, low-confidence units are frozen or archived, and the index is rebuilt to generate a knowledge base version snapshot.

[0093] In some embodiments, step 4 of marking the number of valid and invalid times of knowledge units further includes: calculating the decay of the historical number of valid and invalid times of knowledge units according to the time decay rule of 30 days as the half-life, and determining the confidence level of knowledge units by combining the source credibility of knowledge units; wherein, when the execution feedback is successful, it is counted as a valid number, and when the execution feedback is failed or misleading, it is counted as an invalid number, and knowledge units that are marked as misleading three times in a row are automatically downgraded.

[0094] In some embodiments, after selecting the Top-K matching knowledge units in step 2, the content of the Top-K knowledge units is segmented and spliced ​​together. During the splicing process, the KV-cache reuse mechanism is enabled to reduce the computational overhead and response latency of long context processing. The K value of the Top-K ranges from 8 to 32.

[0095] In some embodiments, the field-level merging process in step 5 specifically involves: retaining the longest content and supplementing key phrases in the description information field of the knowledge unit; merging code snippets or tool template fields by keywords (taking the latest and verified version when there is a conflict with the same keyword); and updating the usage frequency and confidence fields in the metadata according to the annotation results in step 4.

[0096] In some embodiments, the preset triggering conditions in step 6 include any one of the following: the number of active knowledge units in the context knowledge base reaches 5,000, the length of the concatenated context reaches 8,000 tokens, and the success rate of the recent 100 tasks drops to 5%; when clustering and deduplicating, a semantic similarity threshold (with a loosening amount of 0.02 added to the basic threshold of 0.82) is used for clustering to merge knowledge units with similar semantics.

[0097] The technical concept of this invention is as follows:

[0098] (I) Glossary

[0099] LLM: Large Language Model.

[0100] Context Knowledge Base: A structured collection of context information maintained by this invention, used to store and manage knowledge units, strategy rules, and historical experience related to various tasks.

[0101] Knowledge Unit: The smallest unit of information in the context knowledge base, consisting of two parts: metadata and content. The metadata describes information such as source, timestamp, number of times used, and confidence level, while the content stores specific strategies, rules, or task experience.

[0102] Generation Module / Feedback Analysis Module / Knowledge Integration Module: These are the three main functional modules of the system of this invention, corresponding to the functions of generating task results, analyzing execution feedback, and structuring, merging, and updating knowledge units, respectively.

[0103] (II) Overall System Structure

[0104] like Figure 1 As shown, the intelligent context evolution system comprises three collaborative modules (which can be deployed as in-process components or distributed microservices):

[0105] 1. Generation Module: Receives user query requests and relevant knowledge units in the current context knowledge base, generates reasoning trajectories, tool call instructions or candidate results, and marks which knowledge units are used during execution or may lead to misjudgment.

[0106] 2. Feedback Analysis Module: Analyzes the inference trajectory and execution feedback (such as code execution, external tool calls, result verification, etc.) generated by the generation module, extracts reusable strategies, error patterns and correction suggestions, and forms incremental update candidate information (Delta dataset).

[0107] 3. Knowledge Integration Module: This module performs semantic deduplication, merging, and updating operations on incremental update candidate information, and writes it back to the context knowledge base. It employs a lightweight non-linguistic model logic processing approach to ensure deterministic processing and low latency. The system also supports multi-epoch adaptive optimization and parallel batch merging to improve overall throughput and knowledge update efficiency.

[0108] (III) Data Structure and Storage Organization (Playbook and Entries)

[0109] The relationship between data structures is as follows Figure 3 As shown.

[0110] Context Knowledge Base: An ordered or grouped collection of multiple knowledge units. It can build multi-level indexes based on dimensions such as task domain, tool type, and error mode to support fast retrieval and matching.

[0111] Knowledge Unit Structure:

[0112] Metadata includes unique identifiers, statistical counters (such as the number of times it is marked as "valid / invalid"), creation time, source, and confidence level, which are used to support version control and quality assessment.

[0113] The content section includes reusable task strategies, key domain knowledge points, common errors and their correction methods, tool call examples, template code snippets, etc., to support reasoning generation and strategy reuse.

[0114] The Generation Module explicitly labels or reports back "which knowledge units are used or cause misjudgments in the current task" during task execution, so that the Feedback Analysis Module can accurately locate the knowledge source and generate targeted feedback and update suggestions.

[0115] (iv) Working principles and methods (method topic)

[0116] Method flow sequence diagram as follows Figure 4 As shown.

[0117] S0 Warm-start (executed offline)

[0118] Location: Occurs before S1, usually a one-time or periodic offline process, and is not included in the online SLA.

[0119] Objective: To initialize the context knowledge base, indexes, and key thresholds with historical data to a usable and optimal starting point, providing a stable foundation for subsequent online incremental updates (S1–S5).

[0120] S0.1 Initial Knowledge Construction

[0121] Sources: Historical task samples, rule base, documents, examples.

[0122] Actions: Generate the first batch of knowledge units (strategies, templates, common errors and fixes, etc.); create a v0 version snapshot.

[0123] S0.2 Vectorization and Indexing

[0124] Generate embedding vectors for knowledge units and query text, and establish an ANN / keyword hybrid index; preset Top-K (8–32) retrieval strategy.

[0125] S0.3 Parameter Calibration (Default values ​​recommended, adjustable)

[0126] Semantic deduplication / merging threshold sim_threshold = 0.82 (recommended 0.75–0.90);

[0127] Add / update the difference threshold min_delta_diff = 0.15 (0.10–0.25);

[0128] Δ Batch size delta_batch_size = 32 (16–128);

[0129] Parallel merging concurrent merge_workers = 8 (4–32);

[0130] Growth-refinement trigger: Size GF_size = 5,000, Length GF_ctxlen = 8,000 tokens, Performance drop-off GF_perf_drop = 5%;

[0131] The count decay half-life is 30 days, and the misleading freeze threshold is k = 3.

[0132] S0.4 Caching and Template Preparation;

[0133] Pre-generate short prompt summaries for frequently used tasks and tool call templates; enable KV-cache warm-up.

[0134] S0 output

[0135] Initial knowledge base v0 (including embedded index);

[0136] Parameter / threshold configuration table (see the specific configuration data in "S0.3 Parameter Calibration" above);

[0137] Pre-set templates and cache;

[0138] Offline evaluation baseline (accuracy, latency, token cost);

[0139] Then proceed to the online closed loop of S1–S5; if there are major version changes to the business, S0 can be repeated as a periodic warm-up as needed.

[0140] S1. Task Reception and Initial Retrieval

[0141] The system receives input task requests (Query) and the current context knowledge base. It employs a combined strategy of keyword matching and semantic similarity retrieval to select Top-K candidate knowledge units (K is configurable, commonly 8–32).

[0142] Vectorization and Retrieval: Generate an embedding vector e(·) from the Query and knowledge unit text, and retrieve the Top-K based on the ANN index.

[0143] Similarity metric: cosine similarity; default similarity threshold sim_threshold = 0.82 (recommended range 0.75–0.90).

[0144] Context concatenation: Only the hit fields (strategy fragments / code templates / constraints) are extracted and concatenated in segments, and KV-cache reuse is enabled to reduce long context overhead.

[0145] S2. Generator: Execution and Track Records

[0146] The reasoning and invocation are completed step by step in an external tool or code execution environment; the generated module records the execution trajectory.

[0147] Usage Records: For each referenced knowledge unit, mark outcome ∈ {used, misleading, ignored} and execution signal ∈ {success, fail, partial}, and write it to USAGE_RECORD.

[0148] Log evidence: Saves evidence fields such as tool returns, assertion results, and exception stack traces.

[0149] Batch settings: Incremental candidate aggregations generated by a single task are Δ batches, with a default delta_batch_size of 32 (can be 16–128, in conjunction with parallel merging threads).

[0150] S3. Feedback Analysis

[0151] Based on the execution trajectory and feedback signals, the feedback analysis module automatically extracts experiential knowledge, error patterns and correction strategies, and produces a Δ dataset (updated / added to several candidate knowledge units).

[0152] Natural feedback sources include: computational validation, external API consistency, unit testing, assertion / threshold monitoring, etc.

[0153] Valid / Invalid Labels:

[0154] Success: Add to helpful_count;

[0155] Failure or misleading: counted in harmful_count (automatic demotion or freezing after k=3 consecutive misleadings).

[0156] Time decay count (half_life = 30 days):

[0157] ; ;

[0158] ;

[0159] Overall confidence level (example formula):

[0160] ;

[0161] The default values ​​are α∈[0.1,0.4], β∈[1.0,1.5], and γ∈[0.1,0.3]. src_score indicates the source credibility (high for tool execution, medium for pure language generation).

[0162] Multi-round refinement: Supports up to N rounds of iteration (N can be 2–5), denoising and merging similar candidates in each round to improve stability.

[0163] S4. Knowledge Integration Module

[0164] Perform a deterministic, non-LLM structured merge on the Delta dataset and write it back to the knowledge base.

[0165] Location and Partial Updates: Field-Level Strategies

[0166] Description: Longest retention + supplementary key phrases;

[0167] code_snippet / tool_template: Key-level merging (for key conflicts, the latest and verified version is used);

[0168] Count / Confidence: Updated according to time decay rules.

[0169] New criterion: Added when the similarity to candidate nearest neighbors is less than sim_threshold;

[0170] Minimum difference threshold min_delta_diff = 0.15 (0.10–0.25): values ​​less than the threshold are considered "updated" rather than "added".

[0171] Semantic deduplication: Based on embedding similarity clustering; default sim_threshold = 0.82, and a loosening factor + ε can be added during deduplication (e.g., ε = 0.02).

[0172] Parallel merging: merge_workers = 8 (adjustable from 4 to 32), supports batch delta parallel processing.

[0173] Threshold-triggered "refined" batch processing:

[0174] Size threshold GF_size: Active knowledge units ≥ 5,000;

[0175] Length threshold GF_ctxlen: Concatenation context ≥ 8,000 tokens;

[0176] Performance threshold GF_perf_drop: Success rate decreases by ≥5% in the last 100 window sliding attempts.

[0177] Key features: The system adopts an incremental Delta update mechanism to avoid high latency and information loss caused by a complete rewrite.

[0178] S5. Grow-and-Refine

[0179] The system employs a "grow first, refine later" strategy to dynamically maintain and optimize the knowledge base.

[0180] Growth phase: Add new knowledge units through min_delta_diff or perform partial updates to relevant fields;

[0181] Refining phase (triggered by any threshold: GF_size / GF_ctxlen / GF_perf_drop):

[0182] 1. Re-cluster using sim_threshold + ε and merge redundancies;

[0183] 2. Reduce the weight / freeze / archive units with low confidence and long-term inactivity;

[0184] 3. Rebuild the index and generate a version snapshot (supports backtracking and difference auditing).

[0185] Operating mode:

[0186] Active Mode: Refine immediately after each Delta (Δ). Specifically, Active Mode is a real-time triggering mechanism in the Grow-and-Refine strategy. It means that after the feedback analysis module generates incremental update candidate information (Delta dataset), the knowledge integration module does not wait for a preset threshold (such as knowledge base size, context length, or task success rate fallback threshold) to trigger it, but immediately performs refinement optimization operations on the context knowledge base. This mode is triggered immediately after each Delta is generated. For example, in a financial audit scenario, after each Delta of a corrected formula or rule is generated, Active Mode immediately refines the knowledge base to ensure that subsequent audit tasks use the latest and most accurate rules, avoiding repeated errors. The essence of this mode is to deeply bind incremental updates with real-time optimization, achieving dynamic self-purification of the knowledge base through non-LLM deterministic logic (clustering, confidence calculation, index reconstruction), which is a key support for the "low latency, high reliability" characteristics of the hybrid AI adaptive optimization system.

[0187] Lazy mode: Executes only when triggered by the above thresholds to balance latency and accuracy.

[0188] The above S1–S5 processes together constitute the core “generation-feedback-integration” closed-loop mechanism of this invention, and combined with incremental Delta update and growth-and-refine technical path, the language model can achieve self-learning, self-optimization and continuous knowledge evolution without retraining the weights.

[0189] (V) Key Parameters and Default Values

[0190]

[0191] (vi) Key Algorithm Points

[0192] 1. Knowledge unitization and local update mechanism: The system only performs local updates on knowledge units related to the current task, avoiding the overall rewriting of the entire context knowledge base, thereby significantly reducing computational overhead and reducing the risk of semantic degradation.

[0193] 2. Incremental Update (Delta) Mechanism: After each task is executed, only a small batch of incremental update candidate information (Delta dataset) is generated. The knowledge integration module performs the merging operation in a deterministic, non-linguistic model logic manner. This process supports parallel merging and batch adaptation, improving the system update efficiency and stability.

[0194] 3. Grow-and-Refine Strategy: The system maintains contextual knowledge through a "grow first, then refine" strategy; new knowledge unit identifiers are added during the growth phase, and structural optimization is achieved during the refinement phase through embedding similarity deduplication and counting accumulation; two triggering methods, active mode and lazy mode, ensure a balance between knowledge accuracy and response latency.

[0195] 4. Execution signal-driven feedback analysis: The system utilizes natural feedback signals such as code execution, tool calls, or task verification to automatically complete the quality assessment and validity judgment of knowledge units by the feedback analysis module without manual annotation, realizing a weakly supervised self-learning update mechanism.

[0196] 5. Service layer performance optimization: For long context scenarios, the system uses methods such as KV-cache reuse, context compression and offline caching to amortize computing resources and optimize latency, so that the increase in context length will not linearly increase service costs.

[0197] (vii) Comparison with existing technologies (highlighting key improvements)

[0198] Complete rewrite vs. incremental update comparison

[0199] Existing techniques (total rewriting): In existing context optimization methods, the entire context content is rewritten by a large language model (LLM) in each round. This approach is prone to information simplification distortion (i.e., over-compression and loss of detail) and semantic degradation in long iterations (e.g., the context length is reduced from about 16,000 tokens to less than 200 tokens, resulting in a significant decrease in model performance). At the same time, the computational latency and resource costs are also high.

[0200] This invention (Adaptive Context Optimization System):

[0201] This invention employs a combination of knowledge unitization structure, incremental update mechanism (Delta), and growth-and-refine strategy to achieve efficient and interpretable continuous optimization of the context.

[0202] Preventing semantic degradation: Historical details and knowledge units are fully preserved and annotated. The system only makes partial revisions to the relevant parts, avoiding information loss caused by overall rewriting.

[0203] High efficiency: The knowledge integration module performs incremental merging operations on deterministic and non-linguistic models and supports parallel processing, significantly reducing context adaptation latency and inference token costs.

[0204] Robustness: This system modularizes task reasoning, feedback analysis, and knowledge integration, which are completed collaboratively by the generation module, feedback analysis module, and knowledge integration module, respectively, thus avoiding the uncertainty and error accumulation problems existing in the traditional monolithic rewrite architecture.

[0205] (viii) Comparative Experiment Design and Report

[0206] Baseline and the proposed solution

[0207] Baseline:

[0208] Base LLM (system prompt only);

[0209] Fixed Prompt + ICL;

[0210] "Complete rewrite" style context update;

[0211] This case:

[0212] Ours-Offline: Preheating + Incremental Updates Off (Incremental Only);

[0213] Ours-Online: Preheating + Online Incremental (Default Parameters) (Method in this Case);

[0214] index:

[0215] Accuracy: Formula accuracy rate, field mapping accuracy rate, and overall audit conclusion consistency rate;

[0216] Efficiency: Average response latency (ms), Token cost (prompt + gen);

[0217] Robustness: performance retention rate and misleading event rate on change sets;

[0218] Interpretability: Traceability coverage (the proportion of outputs that can be located to knowledge units);

[0219] Run configuration

[0220] sim_threshold∈{0.78, 0.82, 0.86}; GF_size∈{1k, 3k, 5k}; delta_batch_size∈{16, 32, 64};

[0221] Concurrent merge_workers=8; half_life=30d; k=3 (continuous misdirection freeze).

[0222] Test report

[0223]

[0224] in:

[0225] Ours-Offline: Warm-up (building the initial context knowledge base offline) + Incremental update disabled (growth only: disabling the online incremental update mechanism, allowing only the addition of knowledge units (growth phase), without performing semantic deduplication, field-level merging, or refining optimization operations);

[0226] Ours-Online: Warm-up (building an initial context knowledge base online) + Online Incremental (default parameters enable online incremental update closed loop (generating results in the generation module → refining the Delta dataset in the feedback analysis module → updating the knowledge base in the knowledge integration module), and use default parameters (such as semantic deduplication threshold of 0.82, growth-refinement trigger threshold, etc.) to perform local updates of knowledge units, semantic deduplication, field-level merging and growth-refinement optimization operations) (the method in this case).

[0227] In some embodiments, alternatives and extensions to the Generation Module include:

[0228] This module can be implemented using a single large language model, or it can adopt a multi-model collaborative architecture: for example, a lightweight model is dedicated to task parsing and instruction planning, while another high-precision model is dedicated to the generation of inference code or operation sequences.

[0229] In embedded devices or low-computing environments, the generation module can be replaced by a compressed model (such as Qwen-Tiny, Llama-Distilled, etc.) to reduce the consumption of computing resources.

[0230] In specific application scenarios, the generation module can also be merged with the Tool Agent Subsystem into a unified execution component, enabling integrated operation of task reasoning and tool invocation execution.

[0231] In some embodiments, the Feedback Analysis Module can be used as an alternative:

[0232] This module can be implemented by another language model, rule engine, or symbolic logic analyzer to replace the natural language analysis process.

[0233] Feedback analysis logic can also be transformed into a structured template matching mechanism (such as error pattern matching based on JSON format), thereby eliminating the need for natural language generation and improving determinism and controllability.

[0234] For real-time response systems, the feedback analysis module can be omitted, and the knowledge integration module can directly extract feedback data from the execution log and generate incremental updates.

[0235] In some embodiments, the Knowledge Integration Module replaces and extends the following:

[0236] In addition to using non-LLM deterministic logic implementation, lightweight embedding models can be introduced for semantic clustering and deduplication operations to improve similarity matching accuracy.

[0237] In application scenarios that require human intervention, a human-in-the-Loop Integration mechanism can be added, whereby human review or expert confirmation is conducted to ensure the accuracy and compliance of knowledge unit updates.

[0238] The knowledge integration logic can also be embedded in a database trigger mechanism to achieve automatic database entry and version control, thereby enhancing the system's maintainability and traceability.

[0239] In some embodiments, alternative implementations of the context knowledge base storage method are:

[0240] Contextual knowledge bases can employ various data storage solutions, including relational databases (such as PostgreSQL), vector databases (such as Milvus and FAISS), or hybrid index structures (Hybrid Search), to cater to both structured and semantic retrieval needs.

[0241] For large-scale or high-availability deployment scenarios, the knowledge base can be expanded into a distributed storage architecture, supporting multi-node synchronous updates, version rollback, and redundant backups to improve the system's reliability and fault tolerance.

[0242] In some embodiments, for certain low-risk or low-sensitivity tasks, the S3 (feedback extraction) step can be omitted, and the generation module can directly pass the task execution feedback data to the knowledge integration module for automatic correction and incremental updates.

[0243] In some embodiments, in offline batch optimization mode, the real-time execution of S5 (growth-refining) can be omitted, and semantic deduplication and knowledge pruning operations are only performed during the periodic batch processing stage to reduce system operating costs and improve throughput efficiency.

[0244] In some embodiments, a verification step (S2.5) can be added between S2 and S3: the system can use the rule base or simulation engine to verify the correctness and consistency of the output of the generation module, ensuring the reliability of subsequent feedback analysis.

[0245] In some embodiments, a version management step (S6) can be added after S5: generating a version snapshot for each round of context knowledge base to enable knowledge evolution retrospection, difference analysis, and audit trail.

[0246] In some embodiments, the two steps of "feedback analysis – knowledge integration" can be performed in parallel: after the feedback analysis module generates incremental update data (Delta dataset), the knowledge integration module can immediately perform semantic deduplication and deterministic write-back to shorten the system response time.

[0247] For real-time responsive systems, S1–S2–S3 can be merged into a unified pipelined task pipeline, and low-latency, high-throughput continuous inference and dynamic optimization processes can be achieved through parallelization and asynchronous mechanisms.

[0248] In some embodiments, an application example of the present invention is: a financial statement intelligent analysis and compliance audit system based on agent context engineering.

[0249] I. Application Background

[0250] In the daily operations of financial institutions (such as banks, securities companies, and accounting firms), a large number of financial statements, audit working papers, and regulatory disclosure documents (such as balance sheets and profit and loss statements in XBRL format) need to be automatically parsed, risk identified, and compliance determined.

[0251] Traditional rule-based matching or model fine-tuning methods have the following main problems:

[0252] 1. When regulatory rules or report templates change, the model needs to be retrained, resulting in high costs and long update cycles;

[0253] 2. The fixed prompt method is difficult to cover industry-specific terminology, typical error patterns, and historical experience, resulting in unstable output results;

[0254] 3. The generated results lack traceability and do not meet the requirements of financial audit and regulatory compliance.

[0255] Therefore, there is an urgent need for an intelligent financial analysis framework that has continuous self-learning capabilities, strong interpretability, and low-cost maintenance.

[0256] II. Example of the running process (method flow)

[0257] (S1) Task Input and Initial Retrieval: The auditor uploads a quarterly XBRL financial report. The system retrieves knowledge units related to "profit fluctuation detection," "cash flow anomaly analysis," and "asset revaluation" from the context knowledge base and sorts them by semantic similarity (Top-K).

[0258] These candidate knowledge units are pieced together to form contextual hints, which are then input into the GenerationModule to support the reasoning process.

[0259] (S2) The automatic analysis report generation module calls a large language model (LLM, such as DeepSeek, GPT, etc.) to generate a natural language audit analysis report and outputs a structured JSON result at the same time.

[0260] The system's computing components further perform financial indicator calculations and comparisons to complete the initial draft of automated analysis.

[0261] (S3) The feedback analysis and correction system detected that "there is a deviation in the calculation of the cash equivalents change rate". The feedback analysis module automatically extracted the correction experience based on the execution log: "Cash equivalents should include the short-term treasury bond income item, and the formula coefficients need to be adjusted".

[0262] The module generates an incremental update candidate (Delta data), the content of which is as follows:

[0263] Rule: include_short_term_treasury = True;

[0264] Comment: adjust formula for cash equivalents.

[0265] (S4) Knowledge Integration and Updating

[0266] The Knowledge Integration Module compares and processes the Delta data: if the similarity to an existing knowledge unit is less than 0.75, the system automatically creates a new knowledge unit and writes it to the knowledge base; if the similarity is high, the "helpful_count" field of the original knowledge unit is incremented. Through this mechanism, the system achieves automated knowledge accumulation and dynamic optimization.

[0267] (S5) Self-learning and knowledge evolution: As audit tasks accumulate over multiple quarters, the system gradually forms a contextual knowledge base:

[0268] A high-value set of audit rules (experience base);

[0269] Common errors and corresponding repair strategies;

[0270] Reusable financial calculation formulas and analysis templates.

[0271] In subsequent tasks, the system can directly reuse these knowledge units to achieve adaptive report correction and continuous learning without human intervention.

[0272] III. Technical Improvements

[0273]

[0274] The embodiments described above are for illustrative purposes only and are not intended to limit the invention. Therefore, any changes in numerical values ​​or substitutions of equivalent elements should still fall within the scope of this invention.

[0275] The above detailed description will enable those skilled in the art to understand that the present invention can indeed achieve the aforementioned objectives and has complied with the provisions of the Patent Law.

[0276] Although preferred embodiments of the invention have been described, those skilled in the art, upon learning the basic inventive concept, can make other changes and modifications to these embodiments. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments as well as all changes and modifications falling within the scope of the invention. The above descriptions are merely preferred embodiments of the invention and are not intended to limit the invention. It should be noted that any modifications, equivalent substitutions, and improvements made within the spirit and principles of the invention should be included within the scope of protection of the invention.

[0277] It should be noted that the above description of the process is for illustrative purposes only and does not limit the scope of this specification. Those skilled in the art can make various modifications and changes to the process under the guidance of this specification. However, these modifications and changes remain within the scope of this specification.

[0278] The basic concepts have been described above. Obviously, for those skilled in the art who have read this application, the above disclosure is merely illustrative and does not constitute a limitation of this application. Although not explicitly stated herein, those skilled in the art may make various modifications, improvements, and corrections to this application. Such modifications, improvements, and corrections are suggested in this application, and therefore, such modifications, improvements, and corrections still fall within the spirit and scope of the exemplary embodiments of this application.

[0279] Furthermore, this application uses specific terms to describe its embodiments. For example, "an embodiment," "one embodiment," and / or "some embodiments" refer to a particular feature, structure, or characteristic related to at least one embodiment of this application. Therefore, it should be emphasized and noted that "an embodiment," "one embodiment," or "an alternative embodiment" mentioned twice or more in different positions in this specification do not necessarily refer to the same embodiment. In addition, certain features, structures, or characteristics in one or more embodiments of this application can be appropriately combined.

[0280] Furthermore, those skilled in the art will understand that aspects of this application can be described and illustrated through several patentable types or situations, including any new and useful combination of processes, machines, products, or substances, or any new and useful improvements thereof. Therefore, aspects of this application can be implemented entirely in hardware, entirely in software (including firmware, resident software, microcode, etc.), or a combination of hardware and software. All of the above hardware or software can be referred to as a “unit,” “module,” or “system.” Furthermore, aspects of this application can take the form of a computer program product embodied in one or more computer-readable media, wherein computer-readable program code is contained therein.

[0281] The computer program code required for the operation of each part of this application can be written in any one or more programming languages, including object-oriented programming languages ​​such as Java, Scala, Smalltalk, Eiffel, JADE, Emerald, C++, C#, VB.NET, and Python; general programming languages ​​such as C; Visual Basic, Fortran2103, Perl, COBOL2102, PHP, and ABAP; dynamic programming languages ​​such as Python, Ruby, and Groovy; or other programming languages. This program code can run entirely on the user's computer, or as a standalone software package on the user's computer, or partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the latter case, the remote computer can be connected to the user's computer via any network, such as a local area network (LAN) or wide area network (WAN), or connected to an external computer (e.g., via the Internet), or in a cloud computing environment, or used as a service such as Software as a Service (SaaS).

[0282] Furthermore, unless expressly stated in the claims, the order of processing elements and sequences, the use of numbers and letters, or other names described in this application are not intended to limit the order of the processes and methods of this application. Although some currently considered useful embodiments of the invention have been discussed in the foregoing disclosure by way of various examples, it should be understood that such details are for illustrative purposes only, and the appended claims are not limited to the disclosed embodiments; rather, the claims are intended to cover all modifications and equivalent combinations that conform to the substance and scope of the embodiments of this application. For example, although the implementation of the various components described above can be embodied in a hardware device, it can also be implemented as a purely software solution, such as an installation on an existing server or mobile device.

[0283] Similarly, it should be noted that, in order to simplify the description of the present application and thus aid in the understanding of one or more embodiments of the invention, the foregoing description of the embodiments of the present application sometimes combines multiple features into a single embodiment, drawing, or description thereof. However, this approach of the present application should not be construed as reflecting an intention that the claimed subject matter requires more features than expressly recited in each claim. Rather, the subject of the invention should possess fewer features than in any single embodiment described above.

Claims

1. A hybrid AI adaptive optimization system based on agent context engineering, characterized in that, include: A contextual knowledge base is used to store structured knowledge units. Each knowledge unit consists of two parts: metadata and content. The metadata describes the source, creation timestamp, number of times it is used, and confidence level of the knowledge unit. The content stores task-related strategies, rules, common error correction methods, or tool call examples. The generation module is used to receive user query requests, retrieve matching knowledge units from the context knowledge base, generate reasoning trajectories, tool call instructions or candidate results based on the query requests and matching knowledge units, and simultaneously label the knowledge units used in the generation process and the knowledge units that lead to misjudgments. The feedback analysis module is used to analyze the inference trajectory and its corresponding execution feedback, extract reusable strategies, error patterns and correction suggestions, and form incremental update candidate information, namely Delta dataset. A knowledge integration module is used to process the Delta dataset and then write it back to the context knowledge base for updating. The knowledge integration module processes the Delta dataset using incremental local updates, specifically: only the knowledge units involved in the Delta dataset are updated at the field level; the field-level updates include supplementing key phrases in the descriptive information of the knowledge unit content, handling key conflicts in code snippets or tool templates, and adjusting the usage frequency and confidence level of the knowledge unit metadata. The usage of knowledge units annotated by the generation module is synchronized to the feedback analysis module, providing a basis for the feedback analysis module to extract strategies and make correction suggestions; the updated context knowledge base of the knowledge integration module provides an updated knowledge source for the generation module to subsequently retrieve and match knowledge units.

2. The hybrid AI adaptive optimization system based on agent context engineering according to claim 1, characterized in that, The knowledge integration module is also used to perform growth-refinement operations: in the growth stage, newly added knowledge units or partially updated knowledge units determined by the difference threshold are added to the context knowledge base; in the refinement stage, when preset trigger conditions are met, the knowledge units in the context knowledge base are clustered for deduplication, low-confidence knowledge units are frozen or archived, the index is rebuilt, and a version snapshot of the context knowledge base is generated; the preset trigger conditions include any one of the following: the number of active knowledge units in the context knowledge base reaches 5000, the length of the concatenated context reaches 8000 tokens, and the success rate of the recent 100 tasks drops to 5%.

3. The hybrid AI adaptive optimization system based on agent context engineering according to claim 1, characterized in that, The knowledge integration module's processing of the Delta dataset also includes semantic deduplication: calculating the semantic similarity between candidate knowledge units in the Delta dataset and existing knowledge units in the context knowledge base; when the semantic similarity is less than 0.82, the candidate knowledge unit is added as a new knowledge unit to the context knowledge base. When the semantic similarity is greater than or equal to 0.82, the existing knowledge units are updated.

4. The hybrid AI adaptive optimization system based on agent context engineering according to claim 1, characterized in that, The context knowledge base adopts a distributed storage architecture, which supports multi-node synchronous updates of knowledge units, knowledge unit version rollback, and redundant backups to improve the reliability and fault tolerance of the context knowledge base.

5. A hybrid AI adaptive optimization method based on agent context engineering, implemented based on the system described in any one of claims 1-4, characterized in that, include: Step 1: Offline preheating to build an initial context knowledge base; The first batch of knowledge units are generated based on historical task samples, rule base and documents. Embedding vectors are generated for knowledge units and a hybrid index is established. Semantic deduplication threshold and incremental batch size are marked to form an initial context knowledge base. Step 2: Task reception and knowledge retrieval; Upon receiving a user query request, the system selects the Top-K matching knowledge units from the initial or updated context knowledge base using a combination of keyword matching and semantic similarity retrieval. Step 3: Generate execution and trajectory records; Based on the query request and the matched Top-K knowledge units, a reasoning trajectory, tool call instructions or candidate results are generated, and the usage and execution feedback of each knowledge unit are recorded. Step 4: Feedback extraction generates the Delta dataset; Analyze the reasoning trajectory and execution feedback in step 3, extract reusable strategies, error patterns and correction suggestions, mark the effective and ineffective times of knowledge units, and form incremental update candidate information, namely Delta dataset; Step 5: Knowledge integration and updating of the knowledge base; The Delta dataset is subjected to semantic deduplication and field-level merging, and the processed knowledge units are written back to the context knowledge base for updating. Step 6: Growth - Refinement and Optimization of the Knowledge Base; When the context knowledge base meets the preset triggering conditions, the knowledge units in the knowledge base are clustered and deduplicated, low-confidence units are frozen or archived, the index is rebuilt, and a knowledge base version snapshot is generated.

6. The hybrid AI adaptive optimization method based on agent context engineering according to claim 5, characterized in that, Step 4, which marks the number of valid and invalid times for knowledge units, also includes: calculating the decay of the historical valid and invalid times for knowledge units according to the time decay rule of 30 days as the half-life, and determining the confidence level of knowledge units by combining the source credibility of knowledge units; among them, when the execution feedback is successful, it is counted as a valid number, and when the execution feedback is failed or misleading, it is counted as an invalid number. Knowledge units that are marked as misleading three times in a row are automatically downgraded in weight.

7. The hybrid AI adaptive optimization method based on agent context engineering according to claim 5, characterized in that, In step 2, after selecting the Top-K matching knowledge units, the content of the Top-K knowledge units is segmented and spliced ​​together. During the splicing process, the KV-cache reuse mechanism is enabled to reduce the computational overhead and response latency of long context processing. The K value of the Top-K ranges from 8 to 32.

8. The hybrid AI adaptive optimization method based on agent context engineering according to claim 5, characterized in that, The field-level merging process in step 5 is as follows: the description information field of the knowledge unit retains the longest content and adds key phrases; the code snippet or tool template field is merged according to keywords; and the usage frequency and confidence fields in the metadata are updated according to the annotation results in step 4.

9. The hybrid AI adaptive optimization method based on agent context engineering according to claim 5, characterized in that, The preset trigger conditions in step 6 include any one of the following: the number of active knowledge units in the context knowledge base reaches 5,000, the length of the concatenated context reaches 8,000 tokens, or the success rate of the recent 100 tasks drops to 5%.

Citation Information

Patent Citations

  • Dynamic adaptation question answering system and method based on hierarchical structure and retrieval enhancement

    CN118193714A