Artificial intelligence agent control context generation method and system
By maintaining the environment version and control generation of the control source directory, registering directory updates, and performing predictive parsing and atomic commits, the problem of inconsistent control context caused by changes in the control source directory is resolved, ensuring the safe reuse and consistency of control state.
Patent Information
- Application Number
- CN202611398045.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-09-09
- Publication Date
- 2026-11-27
AI Technical Summary
Existing technologies cannot accurately distinguish between environmental changes and changes in the published control state when the control source directory changes, resulting in inconsistent control contexts for target operations and failing to ensure the safe reuse of predicted results and consistency of actual loading.
By maintaining a control source directory that records control sources and their resolution relationships, registering directory updates and updating the versions of affected queries, maintaining the directory environment version and the control generation of published control status, and performing predictive resolution, impact witnessing, environment change reconfirmation, independent authorization, and atomic commit, the integrity and consistency of the control context are ensured.
It enables secure reuse of control capabilities under changes in the directory environment, ensuring consistency between the control context and the actual loaded candidates, avoiding inconsistencies in control states caused by environmental changes, and improving the accuracy of model inference and tool decision-making.
Smart Images

Figure CN123180155A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the fields of artificial intelligence agent runtime control and computer data processing technology, and in particular to a method, system, electronic device, and computer-readable storage medium for generating a control context by utilizing environment version, control generation, parsing impact evidence, fresh transition permission, actual load candidate, and atomic commit, under the condition that the control source directory is updated through controlled entry registration. Background Technology
[0002] During runtime, AI agents typically select control sources such as instructions, rules, skills, tool definitions, hooks, policies, memories, or plugins based on workspaces, directories, sessions, objects, or task scopes before model inference or tool decisions, and assemble the resolved results into a control context for use by the model or tool. Even if the target operation only manifests as reading resources, entering a directory, opening an object, or loading capabilities, it may indirectly cause new control sources or resolution relationships to take effect.
[0003] The source directory can be inserted, deleted, moved, updated in content, or have its relationships updated during agent execution. If every time the directory changes, the completed predictions are discarded and re-resolved, updates unrelated to the target scope will also block the target operation; if only the total version of a directory is compared and the prediction is reused directly, it may miss new sources, changes in imported sources, or changes in resolution relationships such as occlusion or rollback in the ancestor directories of the target scope.
[0004] For example, if a prediction resolution query retrieves an ancestor scope and returns an empty result, and that scope is subsequently added to the control source for the first time, simply recording the source hit without recording the empty query does not prove that the new source is unrelated to existing predictions. Similarly, recording only loaded files without recording the query status of accessed import sources and relation endpoints does not sufficiently determine whether import and resolution relation updates affect the prediction results.
[0005] Direct permissions for a target operation typically only determine whether reading, entering, or opening the target object is permitted, and do not automatically cover the effects of the operation on the control source, changes in resolution relationships, or expansion of effective permissions. Even if the prediction results can be safely reused after environmental changes, the permissions bound to the old environment may have expired, been revoked, or generated according to the old policy, and therefore cannot be revived along with the prediction results.
[0006] Furthermore, the data obtained from predictive parsing cannot replace the actual loading results before submission. If the published object is a re-acquired object using a variable location instead of the candidate object actually loaded and verified this time, or if the complete status identifier only covers the content digest and not the source identity, permissions, consumption order, and parsing relationship, the approved status may be inconsistent with the final status upon entering the control context.
[0007] Therefore, a feasible runtime mechanism is needed that, while preserving the ability to securely reuse updates under unrelated environmental updates, identifies relevant updates by fully parsing impact evidence; reissues independent licenses for the current environment; forms isolated candidates based on the actual loading path; and completes full binding verification, candidate release, control generation advancement, and license consumption within the same atomic operation. Summary of the Invention
[0008] The technical problem to be solved by this invention is: for target operations that do not explicitly request modification of control configuration but can indirectly change the control context through control source resolution, how to distinguish between changes in the control source directory environment and changes in the published control state, accurately determine whether existing predictions can be reused, and ensure that only states that are freshly authorized based on the current environment and completely consistent with the actual loaded candidates can enter the control context used by model inference or tool decision-making.
[0009] To address the aforementioned issues, this invention employs an AI agent runtime that maintains a control source directory, including control sources and resolution relationships, through a controlled update entry point. It registers directory updates and updates the versions of affected queries, maintaining the directory environment version and the control generation of published control states. For target operations, it sequentially executes predictive resolution, impact witness recording, environment change reconfirmation, independent authorization, actual load isolation, and atomic commit. The complete state identifier for predictions and candidates covers source identity and content, resolution relationships, valid permissions, contribution source consumption order, scope and conditions, and resolution rule identity and version. The runtime retains the actual candidate bound to the newly licensed object, and directly publishes the retained candidate after atomic verification, without reloading according to variable relocation. Changes in the directory environment can trigger prediction reuse or re-resolution, but do not directly advance the control generation; successful candidate publication advances the control generation; control changes that invalidate existing preparations due to policies, resolution conditions, or rules can also advance the generation.
[0010] The term "control source" as used in this article refers to a structured source capable of influencing model inference inputs or the scope of tool decisions. This includes instructions, rules, skills, tool definitions, tool patterns, hooks, policies, memories, plugins, or other resolvable sources. A control source descriptor must contain at least a stable source identity, normalized location, scope, content identifier, source version, activation conditions, imports, and applicable fields in the permission description.
[0011] The control source directory, as referred to in this article, is the queryable state used at runtime to resolve control sources and their relationships. Directory buckets are set up according to normalized scopes, and each bucket stores the set of control sources within that scope and its version; even if the set is empty, the version for that bucket is still stored or can be retrieved. The control source directory also includes import source versions queried by source identity, and resolution relationship indexes and corresponding query versions queried by relationship endpoints.
[0012] The environment version, as referred to in this article, is the global version that progresses after a controlled update of the source directory, indicating whether the directory environment has changed. The control generation, as referred to in this article, is a sequence number that identifies the current release baseline and the validity of the control, and it progresses upon successful replacement of the release state or upon a control change that invalidates existing preparations. The environment version describes the resolvable environment, and the control generation describes the currently consumable released state of the model or tool; the two are stored and compared separately.
[0013] The published control state, as referred to in this paper, is the control source, resolution relationship, effective permissions, and their sequential results that have been submitted for verification and are available for consumption. The control context is the published form of this state for model reasoning or tool decision-making. The current published control state serves as a pre-transition state, which is jointly defined by the state identifier and the control generation.
[0014] The target operation referred to in this article is a runtime operation that does not explicitly request modification of the control configuration but may indirectly change the control context through scope selection, condition judgment, import or resolution relationships. The predicted control state is the post-operation state calculated based on the target operation parameters and resolution rules; the candidate control state is the post-operation state obtained through the actual loading and resolution path and kept isolated before verification.
[0015] The resolution rules referred to in this article are deterministic rules that determine the ancestor order of scopes, the selection of control sources, condition activation, import expansion, relation application, and consumption ordering. Resolved relations include import, occlusion, overwrite, fallback, priority, or other relations with deterministic endpoint semantics; each relation record includes endpoint identity, relation type, condition parameters, priority, and applicable fields in the relation version.
[0016] The term "parsing influence evidence," also known as "parsing influence witness," refers to a versioned set of queries that predict the state of the directory read during the parsing process. This set includes at least the directory bucket queries and bucket versions for the target scope and its ancestor scopes. This includes queries that return an empty set, as well as the identity and version of the import source that was actually accessed, the relevant parsing relation endpoint buckets and query versions, and may include normalized query keys and query result summaries for verification.
[0017] The complete state identifier referred to in this paper is an identifier obtained by calculating or equivalently binding the normalized control state as a whole. It covers the identity and content of the control source, resolution relationship, effective permissions, consumption order of contribution sources, scope and condition parameters, as well as the identity and version of the resolution rule; the environment version is bound separately to the permission and is not used as the content field of the predicted semantic state, while the control generation can be used as the generation field of the complete state; each set is first sorted according to a defined rule, the sequence field retains the order, and then the digest is calculated based on the normalized serialization result or a versioned object identifier with equivalent complete binding function is used.
[0018] The term "transition permission" as used in this document refers to a one-time object generated by the authorization module after making an independent permission determination based on changes in the control source's effective state, resolution relationship, or effective permissions relative to the previous state of the predicted control state. A transition permission is bound to the target operation identity, the previous state identifier and control generation, the predicted complete state identifier, the current environment version, the resolution rule version, the authorization policy version, the validity period, and the revocation status, and has an unconsumed or consumed state. The consumption status can be stored in the permission registration record or represented by the final state of the transition record uniquely bound to the permission; the latter method sets the transition to a submitted final state after successful submission and accordingly refuses to allow the permission to be used for loading or submission again.
[0019] The version management module registers directory updates through controlled update entry points. When adding, deleting, or changing control source content, scope, conditions, import information, permission descriptions, or capability sets, the corresponding source record is written within the same update atomic boundary, advancing the source version and the affected directory bucket version, as well as the environment version. When the scope is changed, both the original scope directory bucket and the new scope directory bucket are updated simultaneously. The permission categories and capability sets carried by the control source are inputs for predictive parsing; even if the text content remains unchanged, the source version and the versions of related queries returning these fields should be updated, and registration should not be determined solely by whether the content summary has changed. When a new source enters a previously empty bucket, the version of that empty bucket changes, thus invalidating any witnesses that recorded that empty query.
[0020] For the addition, deletion, or modification of parsed relations, the version management module updates the relation query index within the controlled update atomic boundary based on the endpoints of the old and new relations. For each endpoint bucket where the relation can be queried from the endpoint, the query version is advanced, and then the environment version is advanced. For updates to imported source content or identity, the source version is advanced, and verifiable import query records are maintained according to its normalized identity.
[0021] The prediction and parsing module receives the target operation, previous state, control generation, environment version, and parsing rule version. It normalizes the target scope and queries the target scope and all its ancestor buckets in a predetermined order. Each query, regardless of whether it hits zero or one or more control sources, writes the normalized scope and the current bucket version to the parsing impact evidence.
[0022] For selected control sources that meet the activation conditions, the prediction and parsing module accesses their imports in a predetermined order, records the identity and version of each accessed import source, and recursively expands the imports. For occlusion, overlay, fallback, or priority relationships that need to be determined during the parsing process, the module queries the relationship index by the relevant source endpoint and records the query version of the corresponding endpoint bucket.
[0023] Imported items whose activation conditions are not met are not expanded, and the condition judgment and parameters are recorded in the parsing trajectory. When expansion is required but the import source is missing, the source identity cannot be determined, or a loop that is not supported by the parsing rules occurs, the prediction parsing fails, and no submittable prediction control state is generated. Therefore, unmet conditions and missing sources are two different processing results.
[0024] The prediction and parsing module applies parsing relationships to the selection results, calculates effective permissions and the consumption order of contribution sources, forms the predicted control state and complete state identifier, and saves the evidence of the parsing impact. The preparation record simultaneously saves the target operation parameters, the previous state identifier, the control generation, the environment version at preparation time, the identity and version of the parsing rules, and references to the prediction results.
[0025] When a change in the environment version is detected before submission compared to the preparation time, the reconfirmation module first checks the current pre-state identifier, control generation, target operation parameters, resolution conditions, and resolution rule versions. If any of these changes, the original preparation results are no longer used, and preparation should be redone based on the current state. Only if these bindings remain unchanged will the query versions in the resolution impact evidence be checked item by item in the same current environment view. If the environment changes again between the check and subsequent authorization, authorization is rejected, and reconfirmation is performed.
[0026] If the target scope, all ancestor bucket versions, import source versions, and relation endpoint query versions in the witness remain unchanged, then the environment update is irrelevant to the set read in this resolution, and the reconfirmation module can reuse the predictive control state and its complete state identifier. If any record version changes, predictive resolution is re-executed to generate a new predictive control state and a new complete witness; partial patching of the old witness does not replace re-resolution.
[0027] If a directory update bypasses the version management module, resulting in the update not being fully registered, the runtime cannot determine whether it is reusable based on the unchanged version. In the implementation, this situation can be detected through controlled write entry points, directory transaction sequence numbers, change log continuity, storage snapshot versions, or integrity flags; when a registration gap is detected, a forced re-resolution from a trusted directory snapshot is enforced, and commit is blocked if a consistent snapshot cannot be obtained.
[0028] The authorization module, independent of the direct permission of the target operation, compares the predicted control state with the previous state to obtain changes in the effective state of the control source, changes in the resolved relationships, and changes in effective permissions. It then checks the source identity, scope, relationship type, capability category, direction of change, and conditions according to the current authorization policy. Categories that have not changed can be empty; no transition permission is generated if any change requiring authorization fails.
[0029] Upon successful authorization, the authorization module reads the reconfirmed current environment version and current authorization policy version, generates a new transition license, and registers its binding with the current preparation record and prediction object. Even if the prediction status is reused because the queried versions have not changed, a new license is issued for the new current environment version, and the license corresponding to the original environment version is not used.
[0030] Environment versions use unique monotonic serial numbers. Old licenses will not be reinstated due to identical predicted complete state identifiers, restored directory contents, or cache hits. Each license has a unique identity, and its issued environment version, validity period, revocation status, and consumption status are stored in the license itself and associated registration records; after environment changes, continued execution uses the new license, while old licenses remain in their existing invalid, revoked, expired, or consumed state.
[0031] Before loading, the actual loading module checks the environment version, previous state, resolution rules, authorization policy, license period, and revocation status. Only after passing these checks does it call the actual loading and resolution path according to the current control source directory. This path re-executes source retrieval, condition judgment, import expansion, and relation application. Its output is written to a candidate area isolated from the published control context and cannot be read by the model request constructor, tool selector, or other consumers before the submission is approved.
[0032] At runtime, the candidate control state is preserved and bound to the object with the transition permission. The candidate includes the actual control source content or fixed reference, resolution relationship, effective permissions, consumption order, scope, condition parameters, and resolution rule version. The candidate uses immutable objects, content-addressable objects, or frozen records holding stable handles; upon submission, its complete state identifier is recalculated, and replacement by the caller with an object with the same identifier but not registered in the actual path is rejected.
[0033] The submission module performs a full verification within the same critical section, database transaction, or comparison and exchange operation with equivalent atomicity: the current environment version, previous state identifier and control generation, target operation identity, resolution rule version, and authorization policy version are all consistent with the new license; the license has not expired, been revoked, or been consumed; the reserved candidates are effectively bound to the objects in the new license; and the recalculated complete state identifier of the reserved candidates is consistent with the predicted complete state identifier. Objects not generated and registered through this actual loading and resolution path cannot replace the reserved candidates. The above binding read, candidate identifier recalculation, judgment, and post-success state write all occur within the same atomic boundary.
[0034] Only when all the conditions listed in
[0033] are met, the submission module directly publishes the reserved actual candidate as a control context, advances the control generation, and records the new license as consumed, without reloading the candidate according to the variable location during publication. The changes in publication reference, control generation, and license consumption state are completed in the same atomic operation; the consumption state can be represented by the license record or its uniquely bound transition's committed final state. If any condition is not met, no candidate is published, no control generation is advanced, no failed submission is mistakenly recorded as license consumption, and the original published control state remains available.
[0035] For concurrent transitions prepared based on the same prestate and control generation, multiple threads can complete prediction, authorization, and isolated loading separately, but they must enter the same commit serialization point. The first successful committer replaces the prestate and advances the control generation. The remaining transitions are rejected during atomic verification due to inconsistencies in the prestate or control generation. Therefore, at most one concurrent transition can be successfully published for that prestate.
[0036] This invention ensures that the impact of directory changes is not equivalent to changes in published state through controlled registration updates and separation of environment version and control generation; it enables relevant updates to invalidate predictions while allowing irrelevant updates to be reused through complete witnessing that includes empty queries, import sources, and relation endpoints; it still issues new licenses for the current environment after reuse; and it ensures that the approved state is consistent with the final published state by complete identification covering state semantics such as source identity, content, relationship, permissions, and order, as well as direct publication after actual candidate object binding and atomic verification, and records the license consumption state at the same atomic boundary. Attached Figure Description
[0037] Figure 1 This is an overall flowchart of the artificial intelligence agent control context generation method of the present invention.
[0038] Figure 2 This is a schematic diagram illustrating the separation of the source directory environment version and the released control status generation of this invention.
[0039] Figure 3 This is a schematic diagram illustrating the impact of parsing on empty directory queries, import sources, and parsing relationship endpoints in this invention.
[0040] Figure 4 This is a comparison chart of the reuse prediction during irrelevant source insertion and the re-parsing during relevant source insertion in this invention.
[0041] Figure 5 This is a processing diagram of the present invention from fresh transition permission, actual loading of candidates to atomic submission.
[0042] Figure 6 This is a schematic diagram of the pre-state change, strategy cancellation, and concurrent transition rejection of the present invention.
[0043] In the diagram, 100 represents the AI agent runtime, 110 the version management module, 120 the prediction and parsing module, 130 the reconfirmation module, 140 the authorization module, 150 the actual loading module, 160 the commit module, 170 the isolation candidate area, and 180 the published control context; 201 represents the environment version, 202 the control generation, 301 the ancestor directory bucket, 302 the empty directory bucket, 303 the imported source version, 304 the relation endpoint bucket, and 305 the parsed impact evidence.
[0044] In the diagram, 401 represents an irrelevant directory bucket, 402 represents a relevant directory bucket, 403 represents predictive reuse processing, and 404 represents re-parsing processing; 501 represents a fresh transition permission, 502 represents the actual loading path, 503 represents a candidate control state, 504 represents full verification, and 505 represents atomic publishing and consumption; 601 represents the pre-state, 602 represents revocation or expiration processing, 603 represents concurrent transition A, 604 represents concurrent transition B, and 605 represents rejection processing. Detailed Implementation
[0045] The overall data structure and processing procedure are described below with reference to the accompanying drawings. First, an example of a controlled memory directory and a single-process synchronization lock is given, followed by an implementation based on a persistent directory and transactions. Field names, digest algorithms, lock types, and storage media are not limited; when using relational databases, key-value stores, or versioned file indexes, controlled update registration, query version witnessing, permission binding, pre-release isolation, atomic verification, and publish / consume semantics are maintained.
[0046] like Figure 1 As shown, during runtime, 100 reads the current environment version and control generation through the version management module 110; the prediction and parsing module 120 forms the prediction status and witness; the reconfirmation module 130 reuses or recalculates when the environment changes; the authorization module 140 generates a new license for the current environment; the actual loading module 150 forms isolation candidates; and the submission module 160 publishes or rejects after full verification.
[0047] A single-process, in-memory implementation sets six data structures: DirectoryState, PublishedState, Witness, Preparation, Permit, and Candidate. DirectoryState is maintained by a controlled update entry point and includes the environment version, scope bucket table, source table, and relation endpoint index; the source table stores immutable control source descriptors containing content or references to fixed content. PublishedState contains the control generation and full control state; preparation, witness, permit, and candidate status use immutable records, while their corresponding runtime registry tables store mutable states such as stage, revocation, and object associations. The actual loading process queries these descriptors from the current directory and performs conditional, import, and relation resolution to generate candidates independent of the predicted object. Records are bound together through internal identities and object references, avoiding reliance solely on string identifiers provided by the caller.
[0048] This embodiment preserves case sensitivity, uses a unified delimiter, and rejects unsupported relative path segments, subsequently splitting them into ordered scope keys; other namespace or alias rules can be explicitly defined by an independent normalization module. For example, the target scope ` / project / module / sub-item` corresponds to four bucket queries: root, ` / project`, ` / project / module`, and the target scope. Each bucket records a monotonically increasing `bucketVersion`; empty buckets can exist as explicit records or be provided by a versioned default bucket table.
[0049] The source table uses a stable source identity as the key, and the source version changes as content, identity-related metadata, imported items, scope, conditions, permission categories, or capability sets are updated. This embodiment replaces immutable source records entirely through a source replacement entry point; when only the permission category or capability set changes, the source version, the version of the scope bucket, and the environment version are also advanced. Import queries read by source identity verify the source version, and scope queries verify the corresponding bucket version, ensuring that both direct discovery and import discovery can recognize these changes. The relationship index can use an inverted index from endpoint identity to the relationship list, with each endpoint bucket carrying a `relationQueryVersion`; when a relationship changes endpoints, the query versions of both the old and new endpoint buckets are advanced simultaneously to cover relationship exits and entries.
[0050] When using canonical encoding for the complete state, the identity, content identifier, scope, and conditions are encoded for each source; the two ends, type, conditions, and priority are encoded for each relation; and the source identity, category, and capabilities are encoded for each valid permission. The contributing source's consumption sequence, current scope and condition parameters, and the identity and version of the parsing rule are also separately encoded. Mappings and unordered sets use a stable ordering, while consumption sequences are not ordered, thus preserving order differences. The control generation can be used as a generation field in the encoding; the environment version is separately bound to the license and is not used as a predicted semantic state field. Therefore, when the reuse benchmarks such as the previous state and generation remain unchanged, irrelevant environment updates do not individually change the predicted complete state identifier.
[0051] Predictive parsing maintains an access logger. Each call to `queryScope(scopeKey)` reads the bucket version, appends the witness, and returns the bucket content. Each call to `resolveImport(sourceId)` appends the source version and reads the source. Each call to `queryRelations(endpointId)` appends the endpoint bucket version and returns the relation. When a relation query returns an empty set, the query version of the corresponding endpoint bucket is still recorded. When a new relation is added that can be queried from that endpoint, the endpoint bucket version is advanced, invalidating the witnesses of previously empty relation queries. All parsing accesses are executed through these interfaces to prevent bypasses where results are used but not counted in the witness count.
[0052] Update impact and prediction reuse implementation examples Figure 2 As shown, the initial directory environment version is V10, and the published control generation is G4. After registering a source in a scope unrelated to the current target, the environment version advances to V11, while the published context remains the original object and the control generation remains G4. This separation allows the runtime to enter witness verification without mistakenly representing unpublished directory changes as changes to the control context.
[0053] In one embodiment, the target scope is ` / project / payment`. During prediction, the root bucket, ` / project` bucket, and ` / project / payment` bucket are queried sequentially, with the payment bucket being empty. The witness still stores the versions of the three buckets. Subsequently, when the first control source is added to the payment bucket, both the bucket version and the environment version are advanced; upon reconfirmation, it is found that the version corresponding to the empty query has changed, so the old prediction is invalidated and re-parsed. New sources should not be missed due to a miss during prediction.
[0054] like Figure 3As shown, the root source declares imports A and B, where the condition for importing A is met, while the condition for importing B is not met. The parser reads the root source and the descriptors of A and B, records the versions of the three, and expands A if the condition is met; for B, it records the condition judgment and does not continue to expand B's sub-imports. If the accessed import descriptor is missing, it returns an "import missing" error; if the condition is not met after obtaining the descriptor, it is a valid inactive result, and the two do not use the same default value.
[0055] The shading relationship has a root rule at one end and a local rule at the other. In this embodiment, the local rule is the starting point of the shading relationship, and the root rule is the shading endpoint. When the relationship takes effect, the root rule is excluded from the contribution source consumption sequence and the set of valid permissions, but its descriptor and relationship record are retained for complete state representation and dependency verification. During prediction, even if the shading relationship prevents the root rule from contributing content, the corresponding relationship buckets at both ends are queried, and the queried version is written to the witness. When the relationship itself changes, the version of the relevant endpoint bucket changes; when a local rule is deleted, its source and scope bucket versions change; when runtime conditions change, generational progression is controlled, and the original preparation is invalidated; after re-resolution, the root rule resumes contribution, and the relationship set, valid permissions, or consumption order in the complete state are updated accordingly.
[0056] Import recursion uses both the currently accessed set and the completed set. When encountering a source that is currently being accessed again, if the parsing rules do not define a definite result for the loop, an unsupported loop is reported; if the source identity cannot be normalized to a stable key, an identity uncertainty is reported. All of the above exceptions terminate preparation or actual loading, and no committable candidates are generated.
[0057] like Figure 4 As shown, P1 is prepared to record the payment target scope and its ancestors in three buckets (` / project / payment`), along with related import and relation query versions. If V10 to V11 only inserts sources in the ` / project / log` bucket, the query versions in the P1 witness remain unchanged, and the prestate, control generation, operation parameters, resolution conditions, and resolution rules remain unchanged, thus reusing the predicted state.
[0058] If V11 to V12 inserts a source in the ` / project / payment` bucket, updates an import A visited by P1, or changes any related endpoint bucket in the masking relationship, then at least one witness version changes. The module re-verifies the discarded witnesses and predictive references of P1, and re-parses P2 according to the V12 directory snapshot; authorization is only performed on changes to P2 relative to its current previous state.
[0059] If the target operation parameter changes from reading ` / project / payment / bill` to entering ` / project / payment / archive`, or the control generation changes from G4 to G5, or the resolution condition changes, or the resolution rule changes from R3 to R4, the reuse branch will not be executed even if all witness versions remain unchanged. The runtime will refuse to continue using P1 and will create a preparation record with the current operation, previous state, control generation, resolution condition, and rule.
[0060] In one persistent directory implementation, a registration guard is implemented for directory write entries. Each write transaction simultaneously writes the new source or relation value, the affected bucket version, the environment version, and the continuous log number. Upon initiating recovery, the continuity of log numbers and the correspondence between the read-only storage snapshot and the version table are verified; modifications to stored objects later than registered versions can serve as further verification signals. If a registration gap or mismatch is found, the directory is marked as "incomplete registration," and predictive reuse based on the old query version is stopped. After obtaining a trusted, consistent directory snapshot, the index is rebuilt and re-parsed; if the snapshot cannot be obtained, reconstruction fails, or updates are still occurring in the bypass, commit is blocked.
[0061] The authorization, actual loading, and submission implementation module compares the predicted state with the previous state based on source identity, relationship key, and permission key. Taking reading ` / project / payment / bill` as an example, the direct read policy allows access to the target resource, while the control change policy still separately judges the addition of payment instructions, removal of masking relationships, and addition of tool capabilities; a license is issued only if all required judgments pass. One implementation checks whether the operation identity is approved, and whether the changed source identity, relationship type, and capability set conform to the control change whitelist; the same read operation may obtain different license results due to different control changes. The two judgments can be executed separately within the same policy module, or they can be provided separately by the direct operation license interface and the control change license interface.
[0062] When the environment changes from V10 to V11 and P1 is verified as reusable, the authorization module still reads V11 and the current policy S7 to issue license L2. License L1 bound to V10 does not participate in subsequent loading or commit. Even if L1 and L2 are bound to the same predicted complete state identifier, if their license identities and environment bindings are different, L1 will not be revived due to cache hits, environment content restoration, or the reappearance of the same digest.
[0063] The license and its associated registration records retain the validity period, revocation status, and consumption status. These statuses are checked during runtime before actual loading and submission. When the policy service revokes a license, the revocation status is written as the licensee's identity. Expiration, revocation, or policy version changes all require reconfirmation and reauthorization; the "previously allowed" status of an old license is not used as the current authorization result. When the scope of permissions allowed by the authorization policy changes, the policy version or the corresponding license revocation status is updated, preventing licenses that no longer conform to the current policy from being submitted. This path differs from the directory update of the control source's own permission fields described in
[0019] . In this single-process embodiment, when replacing a policy, the control generation is also advanced, invalidating existing preparations, and then preparations and authorizations are re-established based on the new policy. When the consumption status is represented by the associated transition final state described in
[0067] , the check of the final state is part of the license validity check.
[0064] like Figure 5 As shown, after L2 passes the pre-load check, the actual loading path re-queries the current directory, obtains the content or fixed reference of the control source within it, expands the imports that meet the conditions, and applies the current relationship. In the memory embodiment described in
[0047] , this path re-parses the current control source descriptor and does not directly use the prediction result as a candidate; when using a file or remote source interface, the content or stable handle obtained by the interface is fixed in this candidate. This path forms candidate C2 and freezes the actual consumption sequence; C2 enters the isolation candidate area 170, and the published control context 180 still points to the previous state during this period.
[0065] The candidate registry stores C2 references, licensed L2 identities, and loading session identities using unpredictable internal candidate identities; the loading session can be represented by the transition identity bound to this license. The submission module obtains the C2 from the registry; when the interface receives candidate parameters, it only accepts objects with the same registered reference, re-encodes them, and calculates the complete state identifier. Externally constructed objects, even if they declare the same identifier, are rejected due to mismatched object bindings or loading session bindings. Successful publication directly uses the registered candidate, without re-obtaining another object based on its location.
[0066] If the text content in two control states is the same, but their source identities are a trusted directory source and a temporary import source, respectively, then the complete identifiers will be different; when the effective permissions corresponding to the same tool text are read-only and read-write, respectively, the complete identifiers will be different; when the same group of sources is consumed in the order of "basic, local" and "local, basic", the complete identifiers will also be different. Therefore, it is not possible to judge the consistency of prediction and candidates solely based on the similarity of the content summary.
[0067] A single-process implementation allows the version update entry and the commit module to share a reentrant lock. The committing module, holding the lock, reads the environment version, previous state identifier and control generation, operation identity, resolution rule identity and version, policy version, license registration, duration, revocation, and consumption status. It verifies the object bindings of the license and the retained candidates, recalculates the complete candidate identifier, and compares it with the predicted identifier. This embodiment also re-parses from the complete control source directory within the same lock, verifying that the complete identifiers of the retained candidates match the complete resolution results; this full verification and retention, and prediction reuse, only saves the parsing work in the reconfirmation stage. Each license is uniquely bound to a transition record, which transitions through the preparation, authorization, loading, and observation stages. After all verifications pass, the release reference is directly replaced with the retained candidate within the same lock, advancing G4 to G5, and setting the associated transition to the COMMITTED final state. This final state indicates that the bound license L2 has been consumed, and the state machine refuses to load, observe, or commit again from this final state, thus eliminating the need for a separate license consumption flag field. Temporary objects obtained from the full catalog review are used only for comparison and do not replace the retained candidates; if the verification fails, the original publication reference, control generation, and license consumption status are maintained.
[0068] The database implementation can perform equivalent steps within a serializable transaction covering catalog updates and release states, or lock all relevant state rows: It reads and verifies the environment version, previous state identifier and control generation, operation identity, rule and policy version, license validity, consumption state, and candidate object bindings. Within this transaction, it recalculates the complete identifier of the retained candidates and compares it with the predicted identifier. Upon successful verification, it uses the verified version and state as update conditions, simultaneously writing a new release reference to the retained candidate, the next control generation, and the committed final state of the consumed state or unique binding transition in the license record. If the number of affected rows does not meet expectations, the transaction rolls back, the candidate remains isolated or is safely discarded, and the old release state remains unchanged.
[0069] If the actual loading result differs from the prediction in terms of source, conditions, or resolution relationships, and the candidate recalculation identifier is inconsistent with the prediction identifier, the submission will be rejected. Even if the candidate identifiers are consistent, the submission will still be rejected due to environment binding incompatibility if the directory environment version changes after authorization. If the candidates are consistent but the license has been revoked, expired, or consumed, the submission will also be rejected. The failure record includes the reason code and the identity of the relevant object, but the candidate content will not be exposed to the model or tool consumer.
[0070] like Figure 6As shown, both A and B concurrently prepare with G4 and the same pre-state. A first publishes a candidate in the atomic region, advances to G5, and consumes its license; when B subsequently enters the atomic region, even if its own license has not expired and the candidate identifier matches its own prediction, it is rejected because the current pre-state or control generation has changed. B needs to re-prepare with G5 and the current state, and cannot use the original license. If the rejection is only due to license expiration, and there are no other successful publications or control generation advancements, the current control generation can still be G4; a failed commit itself does not advance the control generation. Therefore, the general processing after rejection is to read the current pre-state and the current control generation and re-prepare, without assuming it must be G5.
[0071] If a policy revokes a tool capability after authorization, and the policy version or license revocation status changes before submission, the submission module will reject it. If a source is missing, a loop occurs, a read exception occurs, or the identity is uncertain during the actual loading process, the actual loading module will not register a candidate for submission. Using a database transaction implementation, if the submission itself encounters an exception, the atomic transaction will roll back, preventing partial updates to the publication reference, control generation, and license status.
[0072] System, Device, and Media Implementation: This invention also provides an artificial intelligence agent control context generation system, including a version management module 110, a prediction and parsing module 120, a reconfirmation module 130, an authorization module 140, an actual loading module 150, a commit module 160, an isolation candidate area 170, and a published control context 180. These modules can be combined in the same process or deployed in multiple processes through a transaction interface with version conditions.
[0073] The version management module updates the registered directory through the controlled entry point, maintaining the environment version, control generation, bucket version, and index version; the prediction and parsing module outputs the complete prediction status and queries witnesses; the reconfirmation module verifies witnesses and decides whether to reuse or recalculate when the bindings remain unchanged; the authorization module independently judges control changes and issues new licenses; the actual loading module generates isolation candidates and retains their bindings with licensed objects at runtime; the commit module performs full binding verification and complete identifier recalculation within the same atomic boundary, directly publishes the retained candidates, advances the control generation, and records the consumed licenses. The consumer only holds a read-only reference to the published control context and does not connect to the isolation candidate area.
[0074] The present invention also provides an electronic device including a processor and a memory. The memory stores a computer program as well as a directory state, a published state, a preparation record, licenses, and applicable data in the candidate list; when the processor executes the program, it performs the methods described in
[0009] to
[0035] and
[0045] to
[0071] . The electronic device may be a server, a workstation, a terminal, a container host, or other computing device running an artificial intelligence agent.
[0075] This invention also provides a computer-readable storage medium on which a computer program is stored; when the program is executed by a processor, version separation, witness generation and verification, independent authorization, actual loading isolation, and atomic commit are achieved. The medium can be a solid-state memory, a disk, an optical medium, a read-only memory, or a random access memory; when the program is loaded in modules, it maintains the state of being unconsumable before candidate release and atomically changing its commit state.
[0076] Without altering the controlled update registration, separate maintenance of environment version and control generation, complete parsing of impact evidence, new licenses, complete state semantics, actual candidate object binding, and direct release relationship after atomic verification, specific normalization rules, digest functions, index structures, and synchronization primitives can be replaced; corresponding replacements can all be implemented according to the above data fields, anomaly branches, and verification order.
Claims
1. A method for generating control context for an artificial intelligence agent, characterized in that, Executed by the AI agent runtime, the process includes: maintaining a control source directory including control sources and resolution relationships through a controlled update entry point; registering directory updates and updating the versions of affected queries; maintaining the environment version and control generation of the published control states in the control source directory, where the published control states are states used for model inference or tool decision-making; for target operations that do not explicitly request changes to control configuration but indirectly cause changes to the control context through control source resolution, using the current published control state as the preceding state, generating a predicted control state and its complete state identifier according to the target scope, resolution conditions, and resolution rules of the target operation, and generating resolution impact evidence, where the resolution impact evidence at least records the... The version of the target scope and its ancestor scope directory queries includes versions of scope directory queries with empty results, as well as versions of queries involving accessed import sources and related resolution relationships; the complete state identifier covers the control source identity and content, resolution relationships, effective permissions, consumption order of contribution sources, scope and condition parameters, and resolution rule identity and version; when the environment version changes, it is confirmed that the previous state and its control generation, target operation parameters, resolution conditions, and resolution rules remain unchanged, and the query versions recorded by the resolution impact evidence are checked in the same current environment view. The predicted control state is reused only if all recorded query versions have not changed; otherwise, it is re-resolved. The system predicts the control state and analyzes evidence of its impact. It employs a permission determination independent of the target operation itself, authorizing changes in the control source's effective state, resolution relationship, or valid permissions relative to the previous state according to the current authorization policy. Upon successful authorization, a new transition permission is generated, binding the target operation's identity, the previous state's state identifier and control generation, the complete state identifier of the predicted control state, the current environment version, and the versions of the resolution rules and authorization policy to this new transition permission. The transition permission corresponding to the original environment version remains valid even if the predicted control state is reused. Based on the current control source directory, a candidate control source is generated in the isolation area through the actual loading and resolution path. Select a control state, calculate a complete state identifier covering all state contents based on the actual loading results, retain the candidate control state and bind it to the new transition permission object at runtime, and prevent the candidate control state from entering the control context before verification is passed; in the same atomic operation, confirm that the binding of the current environment version, previous state identifier and control generation, target operation identity, parsing rule version and authorization policy version with the new transition permission is still consistent, the new transition permission is still valid and has not been consumed, the binding of the retained candidate with the new transition permission object is valid, and recalculate the complete state identifier of the retained candidate to confirm that it is consistent with the complete state identifier of the predicted control state;The system refuses to replace the candidate with an object that was not generated and registered in this actual loading and parsing path. Only when all the above conditions are met will the retained actual candidate be directly published to the control context, the control generation advanced, and the new transition permission recorded as consumed. During publication, the candidate is not reloaded according to the variable location; otherwise, publication is blocked.
2. The method according to claim 1, characterized in that, A directory bucket is established for control sources according to the normalized scope. When adding, deleting, or changing the content, scope, conditions, import information, permission description, or capability set of a control source, the source version, the version of the affected directory bucket, and the environment version are updated. When the scope is changed, the versions of the original scope directory bucket and the new scope directory bucket are updated. When the directory bucket is empty, its version is still saved or can be obtained, so that the addition of a control source can invalidate the parsing effect evidence of the previous empty query.
3. The method according to claim 1, characterized in that, Record the version of the imported source by the control source identity, and expand the import for the source that meets the activation conditions; build a relation query index and version by the endpoint of the parsed relation, and still record the query version when the relation query is empty, and update the query version of the relevant endpoint when the relation is added, deleted or changed. Prevent the generation of submitable candidates when the import source is missing, there is a loop that is not supported by the parsing rules, or the source identity cannot be determined.
4. The method according to claim 1, characterized in that, The complete state identifier is calculated through standardized encoding, and the mapping and unordered set are sorted according to determined rules. The consumption sequence of the contributing source maintains the consumption order. The environment version is individually bound to the new transition permission, and the semantic content of the predicted control state is not changed due to only unrelated directory updates. For states with the same content but different source identities, valid permissions, or consumption orders, the complete state identifier is not determined to be consistent based on the same content.
5. The method according to claim 1, characterized in that, If the current published control state, control generation, target operation parameters, parsing conditions, or parsing rules change, the original prepared result will be rejected. The query version check will only be performed if the directory environment changes but the above bindings remain unchanged. If the directory update is not fully registered, the predicted control state will not be reused based on the unchanged query version. Instead, the system will re-parse after obtaining a trusted and consistent directory snapshot. If the snapshot cannot be obtained, the commit will be blocked.
6. The method according to claim 1, characterized in that, The version update entry and the submission module share a synchronization lock. In the same atomic operation, the submission module also re-parses the complete control source directory and verifies that the complete status identifier of the retained candidates is consistent with the complete parsing result. After all verifications are passed, the release reference replacement, control generation advancement and license consumption status recording are completed within the synchronization lock.
7. The method according to claim 1, characterized in that, The new transition license is also bound to a validity period and an authorization revocation status. The validity period, authorization revocation status, and environment version are verified before loading and before release. For concurrent transitions prepared based on the same released control state and its control generation, the previous state is checked and the control generation is advanced in the same atomic operation, so that at most one concurrent transition is successfully released for the previous state and control generation.
8. An artificial intelligence agent control context generation system, characterized in that, It includes a version management module, a prediction and parsing module, a reconfirmation module, an authorization module, an actual loading module, and a commit module. The version management module maintains the controlled registration directory status and version. The prediction and parsing module generates predicted control status and parses evidence of its impact. The reconfirmation module checks the query version and decides whether to reuse or re-parse it. The authorization module determines the control status change and generates a new transition permit. The actual loading module generates isolation candidates and retains their object bindings at runtime. The commit module performs atomic verification, directly publishes the retained candidates, advances the control generation, and records the consumption of the permit. The modules work together to execute the method described in claim 1.
9. An electronic device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the method of any one of claims 1 to 7.
10. A computer-readable storage medium storing a computer program thereon, characterized in that, When the computer program is executed by a processor, it implements the method of any one of claims 1 to 7.
