Agent context pollution treatment method and system
Patent Information
- Application Number
- CN202610917802.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-06-24
- Publication Date
- 2026-10-13
AI Technical Summary
[0005]本发明提供智能体上下文污染治理方法及系统,解决自主智能体运行环境中上下文对象污染难以有效识别和处置的技术问题
[0016]本发明通过对上下文对象执行集中登记、风险分层、隔离扫描、量化评估、差异化修复和结构化审计,解决了现有技术平面化扫描不区分层级、缺乏长期记忆自动修复能力及治理证据链不完整的技术问题,取得了以下技术效果。
Smart Images

Figure CN122904853A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of artificial intelligence technology, specifically to a method and system for managing contextual contamination in intelligent agents. Background Technology
[0002] Autonomous agents rely on various context objects, such as system prompts, tool definition files, memory documents, routing configurations, and permission configurations, to guide their decision-making. When business processes undergo iterative changes, old command strings, routing rules, permission declarations, and interaction scripts may remain in these context objects, causing the agent to read and execute obsolete behavioral logic in subsequent sessions. This phenomenon is called context pollution.
[0003] Existing technologies employ a flat scanning approach for context objects, failing to differentiate the varying degrees of influence on agent decision-making among system prompts, tool definitions, long-term memory, and operational logs, and uniformly applying the same handling strategy to all context objects. Furthermore, inspection tasks share the same context loading environment as ordinary agents, potentially loading contaminated business memories during the inspection process; information generated during the governance process is stored in natural language log format, making it impossible for scheduling and auditing systems to consume it in a structured manner.
[0004] The aforementioned existing technologies have the following drawbacks: automatic rewriting of active contexts with high control over system prompts may disrupt the core operational configuration of the agent; low-risk contamination in long-term memory only triggers alarms without repair, failing to eliminate the impact of old information in a timely manner; the repair of long-term memory relies entirely on manual inspection, resulting in a long repair cycle and a high probability of omission; and the lack of a complete evidence chain from hit to repair to re-inspection makes it impossible to support compliance audit traceability. Summary of the Invention
[0005] This invention provides a method and system for managing context pollution in intelligent agents, which solves the technical problem of effectively identifying and handling context object pollution in the operating environment of autonomous intelligent agents.
[0006] This invention discloses a method for managing context pollution in intelligent agents, comprising steps A and B. Step A involves acquiring the registration records of all context objects in the intelligent agent's operating environment, generating a list to be scanned based on the registration records, loading negative pattern rules and standard correction instructions that are in effect, creating a light context session that does not inject long-term memory or register the inspected tools, calculating the context activity for each context object in the light context session, and classifying the context object as an active context or long-term memory based on the comparison result between the context activity and the activity threshold. Step B includes: performing negative pattern rule matching on each context object; calculating the contamination risk value for each hit item based on context activity, rule matching strength coefficient, semantic similarity value, historical hit rate, and control capability coefficient; classifying the hit items into different disposal queues based on the contamination risk value; performing automatic repair on hit items that are classified into the automatic repair candidate queue and belong to the long-term memory level; and calculating the automatic repair credibility in a product form to confirm the validity of the repair results.
[0007] Furthermore, the calculation of the contextual activity also includes: For all loading events associated with each context object, obtain the loading status value of each loading event within the current inspection window, multiply the weight coefficient corresponding to each loading event by the loading status value, and sum them to obtain the context activity. The loading timings include session initialization, before tool invocation, after tool invocation, memory retrieval, and report generation. Each loading timing corresponds to a different weight coefficient, and the sum of all weight coefficients is one. When a loading timing has occurred at least once within the inspection window, its loading status value is one; otherwise, it is zero.
[0008] Furthermore, classifying the context object as an active context or long-term memory also includes: When the context activity level is greater than the activity level threshold, the context object is classified as an active context. Active contexts only perform detection and reporting, and do not perform automatic rewriting. When the context activity level is not greater than the activity level threshold and the object type is a memory document, the context object is classified as a long-term memory. When the object type is a runtime log, the context object is classified as a runtime report. Files that exist in the registry directory but do not appear in the registry record are marked as unregistered contexts, and their allowed action is set to manual confirmation only.
[0009] Furthermore, the execution of negative pattern rule matching also includes: For regular expression matching and exact string matching, the context object file content is read, the matching items are searched in the text, and the start and end positions of the matching and the rule hit identifier are recorded; for structured path matching, the context object file content is parsed into a structured representation, the node values are extracted according to the path expression specified by the negative pattern rule, and it is determined whether they match the expected values. For semantic similarity matching, the content of the context object file is divided into a list of text segments by paragraph. For each text segment, a vector representation is calculated using a pre-trained text embedding model. Then, the cosine similarity is calculated with the semantic anchor vectors pre-stored in the negative pattern rule. When the cosine similarity exceeds the similarity threshold set by the negative pattern rule, the text segment is recorded as a semantic match.
[0010] Furthermore, the method of assigning the hit items to different treatment queues based on pollution risk values also includes: The pollution risk value is obtained by multiplying the context activity, rule matching strength coefficient, cosine similarity value between the hit segment and the rule semantic anchor point, historical inspection hit rate and control capability coefficient by their respective weight coefficients and then summing them up. The sum of each weight coefficient is one. The control capability coefficient is determined by the combination of the tool call field and the risk level field; when the pollution risk value is lower than the first treatment threshold, it is included in the report record queue. When the alarm value is not lower than the first handling threshold and is lower than the second handling threshold, it is assigned to the normal alarm queue; when the alarm value is not lower than the second handling threshold and is lower than the third handling threshold, it is assigned to the automatic repair candidate queue. When the threshold is not lower than the third processing threshold, it is placed in the queue that requires manual confirmation.
[0011] Furthermore, the automatic repair of hits that are included in the automatic repair candidate queue and whose hierarchical level is long-term memory also includes: Confirm that the allowed action field of the hit object includes the automatic repair option; confirm that the associated standard correction description is in a valid state and the effective time is no later than the current time; confirm that the rule version number of the associated negative mode rule is consistent with the rule version that took effect after the most recent update time in the registration record; After all prerequisites are met, a full content backup is performed; the repair action is selected based on the proportion of the hit content to the total content of the context object. If the hit ratio exceeds the preset high ratio threshold, the overall overwrite is selected; if it is lower than the preset low ratio threshold, the partial replacement is selected; if it is in between, the append correction description is selected; after the write operation is performed, the negative pattern rule matching scan is re-performed on the repaired file.
[0012] Furthermore, the calculation of automatic repair reliability in product form also includes: The reliability of automatic repair is the product of five binary factors: the integrity verification result of the correction description, the version consistency verification result, the backup result, the post-repair rescan result, and the compliance verification result of the handling action; each factor is set to one when it passes and zero when it fails. When the automatic repair confidence level is 1, the repair status is marked as confirmed; when the automatic repair confidence level is 0, a backup restore is performed and the hit items are marked as requiring manual confirmation.
[0013] Furthermore, step B is followed by step C: A structured inspection report is generated by summing all scan results and repair records; for each hit item, the alarm level value is calculated by multiplying the pollution risk value, the normalized value of consecutive hits, the reverse factor of cooling time, and the factor of overdue manual handling by the corresponding weight coefficients, and then summing them up. The sum of each weight coefficient is one. The cooling time reversal factor is a cutoff value that is the ratio of the actual interval time since the last alarm to the cooling time window; when the manual processing overdue factor is one, the cooling period restriction is forcibly ignored and the alarm is resent. Based on the comparison results between the alarm level value and the notification threshold and escalation threshold, perform silent updates, normal alarms, or create high-priority work orders.
[0014] Furthermore, step D is included after step C: The system receives processing results submitted by manual reviewers. These results include false alarm confirmation, manual repair completion, and rule adjustment. For false alarm confirmation, the hit information is written into the exception condition field of the corresponding negative pattern rule record. In subsequent inspections, hit items that meet all exception conditions are ignored. When the rule version number of the associated negative pattern rule, the description version number of the corresponding standard correction description, or the asset version number of the corresponding context object changes, the stored false alarm fragment samples are re-executed for rule matching under the new version of the negative pattern rule. After manual processing is completed, a special re-inspection task is automatically triggered. The re-inspection scope is limited to the list of hit objects processed manually this time, and the re-inspection results are written into the original structured inspection report.
[0015] This invention provides an intelligent agent context contamination management system, comprising: The context registration module is used to obtain the registration records of all context objects in the intelligent agent's operating environment and generate a list to be scanned; The rule loading module is used to read the negative pattern rules and standard correction instructions that are in effect from the rule store, and to perform version integrity verification. The isolation inspection module is used to create light context sessions that do not inject long-term memory or register the inspected tools. In the light context session, the context activity of each context object is calculated and hierarchical classification is performed. The rule matching and risk assessment module is used to perform negative pattern rule matching for each context object, calculate the pollution risk value for the matched items, and classify the matched items into the corresponding disposal queue based on the pollution risk value. The automatic repair module is used to perform precondition verification, content backup, repair action execution, and automatic repair confidence calculation on the hit items that are included in the automatic repair candidate queue and belong to the long-term memory level. The reporting and alarm module is used to summarize scan results and repair records to generate structured inspection reports, calculate alarm level values for hit items, and execute corresponding alarm actions.
[0016] This invention solves the technical problems of existing technologies, such as flat scanning that does not distinguish between levels, lack of long-term memory automatic repair capabilities, and incomplete governance evidence chains, by performing centralized registration, risk stratification, isolation scanning, quantitative assessment, differentiated repair, and structured auditing on context objects, and achieves the following technical effects.
[0017] By creating a lightweight context session to perform isolated scanning, the inspection process does not read contaminated business memory, register the inspected tool, or inherit historical dialogues, enabling the detection results to objectively reflect the actual contamination state of the context object and avoiding the problem of distorted detection results caused by the inspection session loading contaminated context objects.
[0018] By introducing contextual liveness Quantify the actual loading frequency of the context object, and Incorporating pollution risk values The calculation factor ensures that the priority of subsequent processing is consistent with the actual impact of the context object on the agent's current operation, rather than relying solely on the static content matching result.
[0019] By differentiating between automatic repair of long-term memory and detection-only reporting of active contexts, automatic rewriting is not performed on active contexts with high control capabilities, such as system prompts, tool definitions, and permission configurations. This reduces the risk of compromising critical operational configurations while cleaning up contaminated content. The reliability of automatic repair is expressed as a product. Multiple checks are performed on the repair results. If any check fails, the overall credibility is zero and a backup recovery is triggered, preventing the repair operation itself from introducing new content errors.
[0020] By alarm level value Introducing consecutive hit counts and manual processing of overdue factors This distinguishes between genuine ongoing risks and hits that are within the normal processing cycle. After manual processing is completed, a special re-inspection task is automatically triggered, and the re-inspection results are written into the original structured inspection report, forming a complete closed-loop evidence chain of hits, alarms, manual processing, special re-inspections, and status closure, supporting subsequent compliance audit traceability. Attached Figure Description
[0021] Figure 1 This is a flowchart of the intelligent agent context pollution control method provided in the embodiments of the present invention. Detailed Implementation
[0022] The following is an example of an application of the present invention, such as Figure 1 As shown, the implementation process is as follows: An enterprise operations platform (codename: OPS-ALPHA) deployed multiple collaborative agents responsible for handling tasks such as work order dispatch, inventory queries, and compliance audits. In Q2 of 20XX, the platform underwent a business process iteration, replacing the old work order routing rules and permission declarations. However, related old content remained in multiple context objects, causing agents to continue reading and executing deprecated routing logic in subsequent sessions. This triggered a full context pollution inspection task (task ID: TASK-20XX-0831).
[0023] Step S1: Register the context object and generate a list of objects to be scanned; After the inspection task is initiated, the system reads the registration records of all context objects of the OPS-ALPHA platform from the registry. The work order routing agent (codename: AGT-ROUTE) and the compliance audit agent (codename: AGT-AUDIT) share a single tool definition file. AGT-ROUTE's long-term memory document records the historical decision results of older routing rules. The system recursively traverses the registry directory and finds a configuration file (path: / ctx / legacy / deprecated-cmd.yaml) not present in the registry. It appends this file to the scan list and sets the allowed action to be manual confirmation only.
[0024] Table 1. Partial List ofItems to be Scanned Step S2: Load the negative mode rules and standard correction instructions, and perform version integrity verification; The system read all 47 active negative pattern rules from the rule storage. It calculated the overall hash fingerprint of all rule records and compared it with the hash fingerprint stored at the end of the last inspection (Q1 20XX). It found 3 new rules (corresponding to process changes in Q2), and the rule set version change record was v4.1 → v4.4.
[0025] During the reference integrity verification phase, the reference identifier (COR-REF-0089) of the correction description for rule RUL-0089 was found to be expired in the correction description database. This rule was marked as an orphan rule and will not participate in this scan, generating an orphan rule alarm record. The remaining 46 rules all passed the verification, and their associated correction descriptions are in a valid state.
[0026] Table 2: Negative Pattern Rule Loading Results (Key Rules) Step S3: Create an isolation inspection session, calculate context liveness, and perform hierarchical classification; The system creates a lightweight context session (session ID: ISESSION-0831). No memory documents from long-term memory storage are injected into the context window, and tool definitions for AGT-ROUTE or AGT-AUDIT are not registered. Only four types of tools are registered: text reading, regular expression matching, semantic similarity calculation, and report writing.
[0027] In a light context session, computation is performed for each context object in the list to be scanned. Taking / ctx / route / sys-prompt.txt as an example, this object is associated with session initialization ( , ) and before tool call ( , If both loading events occur within the inspection window, then... ,Exceed Classified as an active context. / ctx / route / memory-001.md only associates with memory retrieval ( , A loading timing, If the value is below the threshold and the object type is a memory document, it is classified as long-term memory.
[0028] Table 3. Results of Contextual Activity Calculation and Hierarchical Classification Steps S2-1 to S2-4 (Example 2): Construct a context reference directed graph and perform strong connected component detection; In multi-agent collaborative scenarios, the system expands the reference relationship fields of the registration records and constructs a directed graph of context references. The file ` / ctx / shared / tool-def.json` is referenced by both ` / ctx / route / sys-prompt.txt` and ` / ctx / audit / memory-007.md`; ` / ctx / route / memory-001.md` records the historical output of ` / ctx / shared / tool-def.json`, forming a directed edge from ` / ctx / shared / tool-def.json` to ` / ctx / route / memory-001.md`. ` / ctx / route / memory-001.md` is in turn referenced by ` / ctx / route / sys-prompt.txt` (with a placeholder embedding of the historical decision summary), and the output of ` / ctx / route / sys-prompt.txt` is recorded by ` / ctx / route / memory-001.md`, forming a circular reference.
[0029] The Tarjan algorithm was applied to the directed graph, and a strongly connected component containing two nodes was detected: { / ctx / route / memory-001.md, / ctx / route / sys-prompt.txt}. This component was assigned the domain identifier D-001 and marked as a coupling pollution domain. The out-degree of / ctx / shared / tool-def.json is 2, exceeding the fan-out threshold. , marked as a high diffusion source node; its reachable number of nodes is 4, accounting for 80% of the total number of nodes in the whole graph (5), exceeding This is further labeled as a global diffusion kernel.
[0030] Table 4 Context Reference Directed Graph Node Attributes Steps S4 (Example 1) and S2-5 (Example 2): Perform rule matching, calculate pollution risk value, and trace the transmission chain; A rule-matching scan was performed on all nodes. ` / ctx / route / memory-001.md` was matched by rule RUL-0071 (exact string match), the matched fragment being the old routing instruction string "ROUTE_V1::dispatch_legacy". Starting from this matched node, a breadth-first traversal was performed along the outgoing edges, and a semantically similar fragment (cosine similarity 0.87, exceeding...) was detected in ` / ctx / route / sys-prompt.txt`. Mark it as a node that spreads contamination, and record the propagation path: memory-001.md→sys-prompt.txt.
[0031] The file / ctx / audit / memory-007.md was matched by rule RUL-0091 (semantic similarity matching). The matched fragment is an old version of the permission declaration semantic fragment, with an actual similarity of 0.82. This is a direct match rather than a propagation of contamination.
[0032] Calculation of hits in / ctx / route / memory-001.md : , (Exact string matching) (Non-semantic rules) (6 out of the last 10 inspections were successful). (Affects tool usage and has a high risk level). Substitute into the formula: satisfy ( , ), and are included in the automatic repair candidate queue.
[0033] Table 5 Summary of Pollution Risk Values for Hit Items Step S2-6: Calculate the impact of cascading contamination and generate a priority remediation queue for propagation; Calculate / ctx / route / memory-001.md The path to the contaminated node that can be reached from this node is / ctx / route / sys-prompt.txt, with a hop count of [number missing]. Activity The total number of nodes that can transmit contamination can be reached. Substitute into the formula: Calculate the comprehensive transmission risk value Since / ctx / route / memory-001.md does not belong to the global diffusion kernel, it is calculated directly using the standard formula: ` / ctx / shared / tool-def.json` is the global diffusion kernel, assuming it... , , middle Term multiplied by diffusion amplification factor : according to Arrange in descending order to generate a priority repair queue for propagation. : / ctx / shared / tool-def.json (0.68) → / ctx / route / memory-001.md (0.59) → / ctx / audit / memory-007.md (0.35).
[0034] Steps S5 (Example 1) and S2-7 (Example 2): Perform automatic repair, remove contaminated copies from the propagation chain, and perform atomized batch repair; The file ` / ctx / route / memory-001.md` enters the automatic repair precondition verification: the hierarchical level is long-term memory (passed); the allowed actions include automatic repair (passed). satisfy (Passed); Correction instructions: COR-REF-0071 integrity check passed. Rule version consistency check passed (); ).
[0035] Hit rate assessment: The hit segment "ROUTE_V1::dispatch_legacy" accounts for approximately 18% of the total content of the memory document, which is less than 30%. Therefore, a partial replacement action is selected. Full backup completed successfully. According to the recommended tool in COR-REF-0071, the hit fragment was replaced with "ROUTE_V2::dispatch_standard", but the rescan result showed no hits. ).
[0036] The repair status was marked as confirmed. Subsequently, the propagation segment in / ctx / route / sys-prompt.txt was located and replaced along the propagation path. After replacement, a rescan confirmed that there were no hits.
[0037] The files ` / ctx / route / memory-001.md` and ` / ctx / route / sys-prompt.txt` both belong to the coupled contamination domain D-001. The system aggregates these two nodes into an atomic repair batch. Both nodes were successfully backed up, and the repairs were successful. All values are 1, and the entire atomic batch is marked as confirmed. ` / ctx / shared / tool-def.json` belongs to an active context (hierarchical attribution verification failed), and has been moved from the automatic repair candidate queue to the queue requiring manual confirmation.
[0038] Table 6 Automatic Repair Execution Results Steps S6 (Example 1) and S2-8 (Example 2): Generate a structured report and execute alarm scheduling; The system summarizes all scan and repair results and generates a cascaded pollution control report (report ID: RPT-TASK-20XX-0831). The report records the total number of directed graph nodes (5), the total number of directed edges (5), one coupled pollution domain (D-001, containing 2 nodes), one global diffusion kernel ( / ctx / shared / tool-def.json), and one pollution propagation link.
[0039] Calculate the alarm level value for / ctx / shared / tool-def.json : , (Unresolved 7 times in a row) , (20 hours since the last alarm, 24-hour cooling window). (Processing time not exceeding 72 hours). Substitute into the formula: If the threshold for notification (0.30) is exceeded but the threshold for escalation (0.60) is below, a normal alarm notification will be triggered, with a work order indicating that the object requires manual confirmation. For coupled contamination domain D-001, which has completed atomized remediation, the report records it as closed and will not trigger alarms again.
[0040] Step S7: Process the manual review and write back, and perform a special re-inspection; Manual reviewers submit the manual remediation completion result to ` / ctx / shared / tool-def.json` via the audit console, recording the reviewer's identifier (OPS-REVIEWER-03) and completion time. The system automatically triggers a special re-inspection task (re-inspection identifier: RECHECK-0831-01), with the re-inspection scope limited to ` / ctx / shared / tool-def.json`. If the re-inspection result is unsuccessful, the status of the successful items is updated to "closed," and the re-inspection report identifier is written to the re-inspection report identifier field of the original governance report RPT-TASK-20XX-0831. At this point, all successful items under task TASK-20XX-0831 form a complete closed-loop evidence chain from successful detection, alarm, automatic remediation or manual processing, special re-inspection, to status closure.
[0041] The data flow throughout the governance process is as follows: The list of objects to be scanned generated in step S1 provides the object scope for all subsequent steps; the data calculated in step S3... Simultaneously, as in step S4 The input factors and steps S2-6 The downstream activity input is used throughout the entire risk quantification process; the hit items generated in step S4 and their... The value is expanded into a set of propagation contamination nodes through propagation link tracing in step S2-5, and then summarized in step S2-6. The sorting queue drives the execution order of repair steps S5 and S2-7; the repair results... The verification status and propagation segment rescan conclusions are finally incorporated into the structured reports of steps S6 and S2-8, and the status closure is completed through manual write-back and special re-inspection in step S7. The data fields maintain a consistent correspondence throughout the process.
[0042] The embodiments of the present invention have been described above. However, the embodiments are not limited to the specific implementation methods described above. The specific implementation methods described above are merely illustrative and not restrictive. Those skilled in the art can make more equivalent embodiments under the guidance of the present embodiments, and all of them are within the protection scope of the present embodiments.
Claims
1. A method for managing contextual contamination in intelligent agents, characterized in that, It includes at least steps A and B, wherein step A includes: Obtain the registration records of all context objects in the intelligent agent's operating environment, and generate a list to be scanned based on the registration records; load the negative pattern rules and standard correction instructions that are in effect; create a light context session that does not inject long-term memory and does not register the inspected tools; calculate the context activity for each context object in the light context session; and classify the context object as active context or long-term memory based on the comparison result between the context activity and the activity threshold. Step B includes: performing negative pattern rule matching on each context object; calculating the contamination risk value for each hit item based on context activity, rule matching strength coefficient, semantic similarity value, historical hit rate, and control capability coefficient; classifying the hit items into different disposal queues based on the contamination risk value; performing automatic repair on hit items that are classified into the automatic repair candidate queue and belong to the long-term memory level; and calculating the automatic repair credibility in a product form to confirm the validity of the repair results.
2. The method for managing contextual contamination in intelligent agents according to claim 1, wherein, The calculation of the context activity also includes: For all loading events associated with each context object, obtain the loading status value of each loading event within the current inspection window, multiply the weight coefficient corresponding to each loading event by the loading status value, and sum them to obtain the context activity. The loading timings include session initialization, before tool invocation, after tool invocation, memory retrieval, and report generation. Each loading timing corresponds to a different weight coefficient, and the sum of all weight coefficients is one. When a loading timing has occurred at least once within the inspection window, its loading status value is one; otherwise, it is zero.
3. The method for managing contextual contamination in intelligent agents according to claim 2, wherein, The classification of context objects into active contexts or long-term memory also includes: When the context activity level is greater than the activity level threshold, the context object is classified as an active context. Active contexts only perform detection and reporting, and do not perform automatic rewriting. When the context activity level is not greater than the activity level threshold and the object type is a memory document, the context object is classified as a long-term memory. When the object type is a runtime log, the context object is classified as a runtime report. Files that exist in the registry directory but do not appear in the registry record are marked as unregistered contexts, and their allowed action is set to manual confirmation only.
4. The method for managing contextual contamination in intelligent agents according to claim 1, wherein, The execution of negative pattern rule matching also includes: For regular expression matching and exact string matching, the context object file content is read, the matching items are searched in the text, and the start and end positions of the matching and the rule hit identifier are recorded; for structured path matching, the context object file content is parsed into a structured representation, the node values are extracted according to the path expression specified by the negative pattern rule, and it is determined whether they match the expected values. For semantic similarity matching, the content of the context object file is divided into a list of text segments by paragraph. For each text segment, a vector representation is calculated using a pre-trained text embedding model. Then, the cosine similarity is calculated with the semantic anchor vectors pre-stored in the negative pattern rule. When the cosine similarity exceeds the similarity threshold set by the negative pattern rule, the text segment is recorded as a semantic match.
5. The method for managing contextual contamination in intelligent agents according to claim 1, wherein, The method of classifying the hit items into different disposal queues based on pollution risk values also includes: The pollution risk value is obtained by multiplying the context activity, rule matching strength coefficient, cosine similarity value between the hit segment and the rule semantic anchor point, historical inspection hit rate and control capability coefficient by their respective weight coefficients and then summing them up. The sum of each weight coefficient is one. The control capability coefficient is determined by the combination of the tool call field and the risk level field; when the pollution risk value is lower than the first treatment threshold, it is included in the report record queue. When the alarm value is not lower than the first handling threshold and is lower than the second handling threshold, it is assigned to the normal alarm queue; when the alarm value is not lower than the second handling threshold and is lower than the third handling threshold, it is assigned to the automatic repair candidate queue. When the threshold is not lower than the third processing threshold, it is placed in the queue that requires manual confirmation.
6. The method for managing contextual contamination in intelligent agents according to claim 1, wherein, The automatic repair of hits that are included in the automatic repair candidate queue and whose level belongs to long-term memory also includes: Confirm that the allowed action field of the hit object includes the automatic repair option; confirm that the associated standard correction description is in a valid state and the effective time is no later than the current time; confirm that the rule version number of the associated negative mode rule is consistent with the rule version that took effect after the most recent update time in the registration record; After all prerequisites are met, a full content backup is performed; the repair action is selected based on the proportion of the hit content to the total content of the context object. If the hit ratio exceeds the preset high ratio threshold, the overall overwrite is selected; if it is lower than the preset low ratio threshold, the partial replacement is selected; if it is in between, the append correction description is selected; after the write operation is performed, the negative pattern rule matching scan is re-performed on the repaired file.
7. The method for managing contextual contamination in intelligent agents according to claim 6, wherein, The calculation of automatic repair reliability in product form also includes: The reliability of automatic repair is the product of five binary factors: the integrity verification result of the correction description, the version consistency verification result, the backup result, the post-repair rescan result, and the compliance verification result of the handling action; each factor is set to one when it passes and zero when it fails. When the automatic repair confidence level is 1, the repair status is marked as confirmed; when the automatic repair confidence level is 0, a backup restore is performed and the hit items are marked as requiring manual confirmation.
8. The method for managing contextual contamination in intelligent agents according to claim 1, wherein, Step B is followed by step C: Generate a structured inspection report by summarizing all scan results and repair records; For each hit item, the alarm level value is calculated by multiplying the pollution risk value, the normalized value of consecutive hits, the reverse factor of cooling time, and the factor of overdue manual handling by the corresponding weight coefficients, and then summing them up. The sum of each weight coefficient is one. The cooling time reversal factor is a cutoff value that is the ratio of the actual interval time since the last alarm to the cooling time window; when the manual processing overdue factor is one, the cooling period restriction is forcibly ignored and the alarm is resent. Based on the comparison results between the alarm level value and the notification threshold and escalation threshold, perform silent updates, normal alarms, or create high-priority work orders.
9. The method for managing contextual contamination in intelligent agents according to claim 8, wherein, Step D is included after step C: Receive processing results submitted by manual reviewers. The types of processing results include false alarm confirmation, manual repair completion, and rule adjustment. For false alarm confirmation, write the hit information into the exception condition field of the corresponding negative mode rule record. In subsequent inspections, hit items that meet all exception conditions will be ignored. When the rule version number of the associated negative pattern rule, the description version number of the corresponding standard correction description, or the asset version number of the corresponding context object changes, the rule matching of the stored false alarm fragment samples will be re-executed under the new version of the negative pattern rule. After manual processing is completed, a special re-inspection task is automatically triggered. The scope of the re-inspection is limited to the list of objects hit in this manual processing, and the re-inspection results are written into the original structured inspection report.
10. An agent context pollution control system, used to execute the agent context pollution control method according to any one of claims 1 to 9, characterized in that, include: The context registration module is used to obtain the registration records of all context objects in the intelligent agent's operating environment and generate a list to be scanned; The rule loading module is used to read the negative pattern rules and standard correction instructions that are in effect from the rule store, and to perform version integrity verification. The isolation inspection module is used to create light context sessions that do not inject long-term memory or register the inspected tools. In the light context session, the context activity of each context object is calculated and hierarchical classification is performed. The rule matching and risk assessment module is used to perform negative pattern rule matching for each context object, calculate the pollution risk value for the matched items, and classify the matched items into the corresponding disposal queue based on the pollution risk value. The automatic repair module is used to perform precondition verification, content backup, repair action execution, and automatic repair confidence calculation on the hit items that are included in the automatic repair candidate queue and belong to the long-term memory level. The reporting and alarm module is used to summarize scan results and repair records to generate structured inspection reports, calculate alarm level values for hit items, and execute corresponding alarm actions.