A local digital employee task processing method and system based on cross-channel conversation mapping and recoverable orchestration
By employing cross-channel session mapping and recoverable orchestration, the problems of session mapping failure for multi-platform task access, skill loading overload, and system restart deadlock were resolved, thus achieving continuity and stability in task processing.
Patent Information
- Application Number
- CN202611283996.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-08-24
- Publication Date
- 2026-11-24
AI Technical Summary
Existing technologies suffer from issues such as failed session mapping for multi-platform task access, context overload caused by skill loading, lack of security control for high-risk local actions, and task state deadlock caused by system restarts.
By using cross-channel session mapping and recoverable orchestration, we can accurately locate and continue cross-platform sessions, control the scale of model context usage, and combine isolation environment readiness state detection and asynchronous permission confirmation mechanisms to prevent high-risk actions from unauthorized damage to the local system. We also use database persistence and startup scanning cleanup mechanisms to eliminate the deadlock of runtime markers left by abnormal program exits.
It improves the continuity of task processing and system recovery capabilities, reduces the probability of skill misrouting, prevents cross-channel session confusion, and ensures the continuity and stability of task processing.
Smart Images

Figure CN123157364A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer data processing and intelligent agent task scheduling technology, and in particular to a local digital employee task processing method and system based on cross-channel session mapping and reversible orchestration. Background Technology
[0002] With the integration of artificial intelligence technology and desktop automation systems, task processing systems based on digital employees are widely used in various business scenarios. These systems typically require access to requests from different instant messaging platforms, invoking language models for reasoning and executing corresponding actions.
[0003] In existing task processing workflows, there is a lack of a stable mapping mechanism between session identifiers on different access platforms and internal system sessions. When the underlying model session expires due to timeout or abnormality, it can easily lead to continuous failure of subsequent requests or session deadlock. At the same time, when assembling the model context, the system usually loads all the full instructions of all installed skills into the context indiscriminately. This can lead to the model context exceeding its limits and incorrect selection of similar skills.
[0004] Furthermore, when digital employees perform operations in their local working directory or isolated runtime environments, there is a lack of a dynamic mechanism to assess the readiness status of the isolated runtime environment. When performing high-risk actions, the existing system cannot initiate asynchronous security confirmation to the original requesting platform, posing a risk of unauthorized access and accidental operations. Moreover, the task status management mechanism cannot automatically clear residual running markers after application restarts, resulting in incomplete task records being abnormally suspended, affecting the reliability of task scheduling.
[0005] It should be noted that the information disclosed in the background section above is only used to enhance the understanding of the background of the present invention, and therefore may include information that does not constitute prior art known to those skilled in the art. Summary of the Invention
[0006] In view of this, the present invention provides a local digital employee task processing method and system based on cross-channel session mapping and recoverable orchestration, aiming to solve the problems of multi-platform task access session mapping failure, skill loading causing context overload, lack of security control for local high-risk actions, and task state deadlock caused by system restart in the prior art.
[0007] This invention provides a local digital employee task processing method based on cross-channel session mapping and reversible orchestration, comprising: Receive request messages from multiple different access platforms, extract the platform identifier and the intra-platform session identifier from the request message and concatenate them into a composite session key, query the database based on the composite session key to obtain the corresponding internal task session identifier, and append the request message after verifying the validity of the internal task session identifier. Parse the skill metadata in the skill catalog, write the enabled skills into the available skill list, and when generating the model context, explicitly write the constraint instruction on the number of prerequisite skills to be selected into the model context, and assemble the request message and the available skill list into a task execution package. The system detects the readiness status of the isolated runtime environment, executes the task execution package in the local working directory or the isolated runtime environment, and suspends the tool execution handle when a preset risk action is detected. It asynchronously sends the permission request to the access platform that sent the request message and decides to resume or terminate the tool execution handle based on the returned response or timeout status. Persistently store session messages and task running status, and scan the database for remaining running markers when the application restarts, setting incomplete records to abnormal termination and clearing the running markers.
[0008] In some optional embodiments, after retrieving the corresponding internal task session identifier from the database based on the composite session key, the method further includes: If the query results show that the mapping exists but the corresponding internal task session has been cleaned up in the database, then delete the old mapping record of the composite session key and the internal task session identifier, create a new internal task session, and write the new internal task session identifier and composite session key into the database.
[0009] In some optional embodiments, after appending the request message to the corresponding internal task session, the method further includes: Submit the internal task session to the downstream model interface; when the downstream model interface returns an error response indicating that the model session is invalid, delete the mapping relationship of the composite session key, create a new internal task session and update the mapping relationship, and retry the submission only once.
[0010] In some optional embodiments, before extracting the platform identifier and in-platform session identifier from the request message, the method further includes: The request message is converted into a unified task object containing text, file attachments, platform identifier, platform session identifier, sender identity, and source metadata; the file attachments are downloaded or copied and saved to the local file system path, and the media type of the file attachments is written into the message metadata.
[0011] In some optional embodiments, the constraint instruction on the number of prerequisite skills to be selected includes: The generated model context explicitly includes routing directives, limiting a single request to selecting at most one prerequisite skill, and prohibiting the unconditional addition of all installed skill content to the model context.
[0012] In some optional embodiments, the assembly of the task execution package further includes: The configured Model Context Protocol (MTP) server is assembled into the task execution package. The MTP server communicates using standard input / output, server-sent events, or streaming hypertext transfer protocol. When the runtime environment is a packaged client program, the executable file path of the MTP server is rewritten according to the current runtime environment.
[0013] In some alternative embodiments, executing the task execution package in a local working directory or isolated runtime environment includes: When the runtime environment configuration mode is automatic, read the probe status of the isolated runtime environment; if the isolated runtime environment is not ready, or if the task execution package contains local file attachments that cannot be pushed to the isolated runtime environment, return to the local working directory constrained by the security authorization directory to execute the task execution package; when the runtime environment configuration mode is the explicitly specified isolation mode and the isolated runtime environment is not ready, block execution and return an environment unavailable response.
[0014] In some optional embodiments, suspending the tool execution handle upon detecting a preset risk action includes: The system detects the target action type of the tool's execution command. When the target action type is a file deletion action or a file system authorized working directory out-of-bounds action, it suspends the tool execution handle, generates a permission request with an internal task session identifier, and sends the permission request to the access platform that sent the request message. When the set timer reaches the preset confirmation timeout threshold and no reply is received, the authentication result is determined as a denial and the tool execution handle is terminated.
[0015] In some optional embodiments, a timed task scheduling process is also included, which includes: The wake-up event is triggered according to the preset wake-up cycle. The expiration query predicate is executed in the database: the enabled status is true, the next run timestamp is less than or equal to the current timestamp, the running_at_ms timestamp field is empty, and the expiration time has not been reached; when a task record that meets the expiration conditions is found, the execution process corresponding to the task record is started.
[0016] In some optional embodiments, the timed task scheduling process further includes: Before starting the execution flow corresponding to the task record, query the active task set in the current process; when it is determined that the active task set does not contain a task record, write the current timestamp into the running_at_ms field of the task record in the database, and write the task record into the active task set; for tasks with fixed time intervals, take the larger of the sum of the previous running timestamp and the time interval and the current timestamp as the next running timestamp.
[0017] In some optional embodiments, the timed task scheduling process further includes: When a task fails to execute, an error message is recorded and the consecutive failure counter is incremented. When the consecutive failure counter reaches a preset threshold, the enabled status of the task is changed to disabled. After the task is completed, a summary of the execution result is sent back to the configured notification target session.
[0018] In some optional embodiments, a multi-agent conference orchestration process is also included, which includes: Read the meeting task status and schedule meeting participants to execute in sequential, parallel, or debate mode; after each participant finishes speaking, write the current round index, the current participant index, and the list of completed participants to the database; when restarting after an execution interruption, read the current round index and the current participant index stored in the database and continue execution from the position of the participant corresponding to the interruption.
[0019] In some optional embodiments, the multi-agent conference orchestration process further includes: The context size is estimated by performing a character-weighted calculation on the meeting history messages. The calculation formula is as follows: Where C represents the estimated size, Indicates the number of Chinese characters. Indicates the number of non-Chinese characters; The context strategy is switched based on the estimated size C: when C does not exceed the first preset threshold, all historical messages are used; when C exceeds the first preset threshold but does not exceed the second preset threshold, sliding window messages are used; when C exceeds the second preset threshold but does not exceed the third preset threshold, a hybrid strategy of early message compression plus the original text of the most recent message is used; when C exceeds the third preset threshold, only the latest speeches of each conference participant are retained to form the summary context.
[0020] In some optional embodiments, a user long-term memory retrieval process is also included, which includes: Filter code blocks, greetings, and temporary instructions from the text of internal task sessions; score the filtered candidate text according to rules regarding factuality, personal preferences, and timeliness, and limit the number of candidate records to be implicitly extracted and written to the database in a single instance to no more than a preset upper limit.
[0021] In some optional embodiments, the user's long-term memory retrieval process further includes: For candidate records whose scores fall within a preset critical range, the model is invoked to determine their confidence level. The candidate records that pass the confidence level determination are then written into the memory database table along with their content hash fingerprints, confidence values, and source session identifiers. Deduplication is performed using the content hash fingerprints.
[0022] This invention provides a local digital employee task processing system based on cross-channel session mapping and reversible orchestration, comprising: The session mapping unit is used to receive request messages from multiple different access platforms, extract the platform identifier and the session identifier within the platform from the request message and concatenate them into a composite session key, query the database according to the composite session key to obtain the corresponding internal task session identifier, and append the request message after verifying the validity of the internal task session identifier. The skill assembly unit is used to parse the skill metadata in the skill catalog, write the enabled skills into the available skill list, and when generating the model context, explicitly write the selection quantity constraint instruction of the prerequisite skills into the model context, and assemble the request message and the available skill list into a task execution package. The execution orchestration unit is used to detect the readiness status of the isolated runtime environment, execute the task execution package in the local working directory or the isolated runtime environment, and suspend the tool execution handle when a preset risk action is detected. It asynchronously sends the permission request to the access platform that sent the request message, and decides to resume or terminate the tool execution handle based on the returned response or timeout status. The persistence unit is used to persistently store session messages and task running status, and scan the database for remaining running markers when the application restarts, setting incomplete records as abnormally terminated and clearing the running markers.
[0023] In some optional embodiments, the session mapping unit is further configured to: When the database is queried based on the composite session key and the corresponding internal task session identifier is displayed, indicating that the mapping exists but the corresponding internal task session has been cleared from the database, the old mapping record between the composite session key and the internal task session identifier is deleted, a new internal task session is created, and the old mapping record is updated. When an error response indicating an invalid model session is received from the model interface, the mapping relationship of the composite session key is deleted, a new internal task session is created and the mapping relationship is updated, and the resubmission is performed only once.
[0024] In some optional embodiments, the execution orchestration unit is specifically used to: When the runtime environment configuration mode is automatic, read the probe status of the isolated runtime environment; if the isolated runtime environment is not ready, or the task execution package contains local file attachments that cannot be pushed to the isolated runtime environment, return to the local working directory constrained by the security authorization directory to execute the task execution package; When the runtime environment is configured in an explicitly specified isolation mode and the isolated runtime environment is not ready, execution is blocked and an environment unavailable response is returned.
[0025] In some optional embodiments, the persistence unit is also used to control the scheduler to trigger wake-up events according to a preset wake-up cycle and execute an expiration query predicate in the database: When a task record that meets the expiration criteria is found and it is determined that the current active task set does not contain any task records, the current timestamp is written to the running_at_ms field of the task record in the database, and the task record is written to the active task set. For tasks with fixed time intervals, the next running timestamp is calculated using the following formula: It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and are not intended to limit the invention.
[0026] The local digital employee task processing method and system based on cross-channel session mapping and reversible orchestration of the present invention has the following beneficial effects: Accurate location and continuation of cross-platform sessions are achieved through composite session keys; the scale of model context occupancy is controlled based on the number of prerequisite skills to reduce the probability of skill misrouting; the isolation environment readiness status detection and asynchronous permission confirmation mechanism are combined to prevent high-risk actions from unauthorized damage to the local system; and database persistence and startup scanning and cleanup mechanisms are used to eliminate the problem of runtime flag lock-up left by abnormal program exit, thereby improving the continuity of task processing and system recovery capabilities. Attached Figure Description
[0027] Other features, objects, and advantages of the invention will become more apparent from the following detailed description of non-limiting embodiments with reference to the accompanying drawings.
[0028] Figure 1 This is an overall architecture diagram of a local digital employee task processing system based on cross-channel session mapping and resumable orchestration, according to an embodiment of the present invention. Figure 2This is a flowchart of a local digital employee task processing method based on cross-channel session mapping and resumable orchestration according to an embodiment of the present invention; Figure 3 This is a flowchart of multi-entry normalization and cross-channel session mapping according to an embodiment of the present invention; Figure 4 This is a flowchart illustrating the skill constraints, runtime environment routing, and permission closed-loop process according to an embodiment of the present invention. Figure 5 This is a flowchart of the persistent scheduling and exception recovery status of a timed task according to an embodiment of the present invention; Figure 6 This is a flowchart of multi-agent meeting execution and adaptive context pruning according to an embodiment of the present invention; Figure 7 This is a persistent data entity and association diagram according to an embodiment of the present invention; Figure 8 This is a schematic diagram of the structure of a local digital employee task processing system based on cross-channel session mapping and resumable orchestration according to an embodiment of the present invention. Detailed Implementation
[0029] Exemplary embodiments will now be described more fully with reference to the accompanying drawings. However, these exemplary embodiments can be implemented in many forms and should not be construed as limited to the examples set forth herein; rather, they are provided so that the invention will be more comprehensive and complete, and will fully convey the concept of the exemplary embodiments to those skilled in the art. The described features, structures, or characteristics may be combined in any suitable manner in one or more embodiments.
[0030] Furthermore, the accompanying drawings are merely illustrative of the invention and are not necessarily drawn to scale. The same reference numerals in the drawings denote the same or similar parts, and therefore repeated descriptions of them will be omitted. Some block diagrams shown in the drawings are functional entities and do not necessarily correspond to physically or logically independent entities. These functional entities can be implemented in software, in one or more hardware modules or integrated circuits, or in different network and / or processor devices and / or microcontroller devices.
[0031] The flowchart shown in the attached diagram is merely an illustrative example and does not necessarily include all steps. For example, some steps may be broken down, while others may be combined or partially combined. Therefore, the actual execution order may change depending on the specific circumstances.
[0032] To address the challenges faced by desktop terminals in handling complex cross-platform tasks, including session interruption deadlocks, context resource overload, privilege escalation risks, and state legacy issues caused by system crashes, this solution is built upon distributed identifier mapping, context state dimensionality reduction, dynamic environment probe routing, asynchronous handle suspension mechanisms, and state ledger crash recovery. Distributed identifier mapping transforms heterogeneous channel identifiers from different source platforms into composite primary keys with deterministic retrieval capabilities and establishes a synchronous liveness verification relationship between these primary keys and internal context session handles. This logic ensures automatic decoupling and reconstruction of the mapping relationship when heterogeneous input sources fail at the underlying communication link, eliminating deadlocks in cross-platform communication. Context state dimensionality reduction utilizes metadata parsing and state constraint instructions to achieve bounded convergence of the action space of available tools and skills. This logic decouples computational resource consumption from the candidate instruction set by limiting the scale of search and routing branches during the model context assembly stage, reducing context space occupancy and the probability of incorrect selection. Dynamic environment probe routing… The asynchronous handle suspension mechanism refers to the real-time detection of the reachability of isolated containers and host file systems, combined with cross-platform asynchronous callback channels, to transfer control of high-risk side-effect actions to external decision-making entities. Defensive blocking is executed when timeout or trigger rejection occurs. This logic forms a security boundary between the terminal system and the physical environment while ensuring the continuity of task execution. State ledger crash recovery refers to the convergence of uncertain runtime intermediate states to a definite final state based on persistent relational ledger and system startup state scanning. This logic ensures automatic unlocking of legacy locked states and task recovery in the event of abnormal process interruption or device restart, improving the system's engineering stability and operational autonomy.
[0033] See Figure 1 This invention first provides a local digital employee task processing system based on cross-channel session mapping and reversible orchestration, running on a local terminal device. The system includes: an input access unit 100, an input normalization and cross-channel session mapping unit 200, a skill and model context protocol assembly unit 300, an execution orchestration unit 400, a persistent state unit 500, a multi-agent conference orchestration unit 600, a user memory unit 700, and a result aggregation and output unit 800. The input access unit 100 is configured with multiple heterogeneous entry points, including: a local workbench entry point 111, an enterprise instant messaging entry point 112, a scheduled task entry point 113, and a multi-agent conference entry point 114.
[0034] See Figure 2 This invention provides a local digital employee task processing method based on cross-channel session mapping and reversible orchestration, executed by the aforementioned system. The method includes the following core steps. Step S100: Receive request messages from multiple different access platforms, extract the platform identifier and the intra-platform session identifier from the request message and concatenate them into a composite session key, query the database according to the composite session key to obtain the corresponding internal task session identifier, and append the request message after verifying the validity of the internal task session identifier.
[0035] Specifically, the system receives task call request messages from various external communication channels, desktop workstations, or schedulers. It reads the source channel type and the session index number within the channel carried in the request message, and generates a composite key name that uniquely identifies the external session through string combination operations. Using this composite key name, it retrieves the session mapping relationship recorded in the local persistent relational database table and extracts the corresponding internal task session handle. After confirming that the internal task session is available in the database, it appends the content of the current request message and its metadata to the context record of the internal task session. In some alternative implementations, the composite session key can be generated by hashing at least two of the tenant identifier, group identifier, and user identifier.
[0036] Step S200: Parse the skill metadata in the skill catalog, write the enabled skills into the available skill list, and when generating the model context, explicitly write the selection quantity constraint instruction of the prerequisite skills into the model context, and assemble the request message and the available skill list into a task execution package.
[0037] Specifically, the system scans the preset skill configuration directory in the local disk storage, reads the configuration header information of each skill definition file, and obtains the skill name, function description, and enable status identifier. Skills not in an enabled state are filtered out, and the meta-information of skills that meet the enable conditions is summarized and written into the available skill structure list in memory. When constructing the system prompt text submitted to the inference engine, constraint control text limiting the number of prerequisite skills loaded is embedded in the context structure, and the context appended with the current request information and the available skill structure list are packaged together into a task processing package to be executed. In some other optional implementations, skill configuration information can be obtained from a local database or a remote configuration server.
[0038] Step S300: Detect the readiness status of the isolated runtime environment, execute the task execution package in the local working directory or the isolated runtime environment, and suspend the tool execution handle when a preset risk action is detected. Asynchronously send the permission request to the access platform that sent the request message, and decide whether to resume or terminate the tool execution handle based on the returned response or timeout status.
[0039] Specifically, a communication status probe is initiated to the local container engine or sandbox daemon to obtain a readiness indication for the isolated runtime environment. Based on this indication and task execution requirements, it is decided whether to directly call the executable program under the restricted working path on the host machine, or to distribute the execution instructions to the isolated runtime environment for execution. During the execution of the task processing package, the security policy interception module performs type review on the specific instructions called by the tool; when the instruction touches the preset sensitive action control rules, the current tool execution thread handle is interrupted and suspended, and a permission confirmation notification is constructed and asynchronously sent to the external platform session that initiated the original request through the access gateway. A time counter is maintained locally; if a permission instruction is received from the sender within a predetermined time range, the handle suspension state is lifted and the execution of the tool instruction is resumed; if a denial instruction is received or the time counter reaches the preset timeout threshold, authentication is directly deemed to have failed, the tool execution handle is terminated, and an error response is returned to the inference process. In some other optional implementations, the isolated runtime environment can be replaced by a virtual machine, a restricted subprocess, or an edge computing node.
[0040] Step S400: Persistently store session messages and task running status, and scan the database for remaining running markers when the application restarts, set incomplete records to abnormal termination and clear the running markers.
[0041] Specifically, throughout the entire task execution lifecycle, session interaction text, tool call logs, and task node state changes are written to the database ledger in real time. When the host process restarts or the service initializes, a startup self-check scan is performed to retrieve task records and session records in the database that are marked as running. Records that were not completed due to abnormal system exit are updated to an abnormal interruption state, and the corresponding running timestamps or exclusive markers are cleared, restoring the system to a ready-to-schedule state. In other optional implementations, the database can be an embedded relational database or a stand-alone database service.
[0042] During the coordinated execution of the aforementioned steps, the composite session key established in step S100 and the mapping between the internal task session ensure that requests from heterogeneous entry points can be accurately collected and bound to fixed communication channels. This provides a location basis for accurately backtracking and asynchronously sending permission requests to the original access platform after suspending the tool handle in step S300. Step S200 filters available skills and injects quantity constraints, controlling the context size of the assembled task processing package and reducing the probability of misrouting when executing tool calls in step S300. Step S400 performs real-time persistent accounting of session messages and task running status from steps S100 to S300, and scans and resets residual running markers upon restart. This ensures that the execution process interrupted by abnormal exit in step S300 will not cause persistent state deadlock, guaranteeing system self-healing and recoverability. Through the organic coordination of the above steps, while maintaining local security constraints of physical devices and a closed loop of cross-channel asynchronous authentication, state deadlock caused by session failures and system crashes is eliminated, reducing context overhead and misrouting rate.
[0043] Through the above solutions, this embodiment can achieve unified mapping and persistent management of heterogeneous platform request sessions, preventing cross-channel session errors; by injecting skill selection constraint instructions into the model context, it controls the overhead of prompt words and reduces the misselection of tool calls; by introducing isolation environment probes and cross-channel asynchronous permission confirmation mechanisms, it blocks the risk of physical damage; and by combining the initiation of self-healing scan to clean up residual running marks, it eliminates the state deadlock phenomenon after system crash interruption, ensuring the continuity and stability of task processing.
[0044] In one specific implementation, after retrieving the corresponding internal task session identifier from the database based on the composite session key in step S100, the process of further verifying and updating the mapping relationship is as follows: First, after querying the heterogeneous session mapping table through the composite session key and obtaining the corresponding internal task session identifier, the system does not directly append the request message, but instead initiates a liveness status check on the internal task session master table.
[0045] Specifically, the system uses the internal task session identifier obtained from the query to further query the corresponding session record in the internal task session master table. If the query result shows that there is no corresponding record for the internal task session identifier in the master table, or if the status field of the record in the master table is marked as cleared or deleted, the system determines that the currently obtained mapping record is an invalid mapping.
[0046] Then, the system performs a mapping record cleanup operation, deleting the mapping record between the composite session key and the old internal task session identifier from the heterogeneous session mapping table.
[0047] Next, the system calls the session creation interface to generate a brand new internal task session, obtains the identifier of the newly created internal task session, writes the newly created internal task session into the internal task session master table, and sets it to an active state.
[0048] Finally, the system binds the composite session key to the newly created internal task session identifier, writes the generated new mapping relationship into the heterogeneous session mapping table, and appends the received request message to the newly created internal task session.
[0049] In some other alternative implementations, the liveness status verification of internal task sessions can be compared with the session status list in the memory cache; the operations of deleting old mapping records and writing new mapping records can be atomically wrapped by database transactions, or automatically triggered by the database's foreign key cascading update mechanism.
[0050] In the specific implementation process, please refer to Figure 3 The cross-channel input normalization and session self-healing control process in step S100 is elaborated in detail, including steps S101 to S106: Step S101 (receiving input): The input access unit 100 receives task request messages from the local workbench entry 111, the enterprise instant messaging entry 112 (including platform gateways such as Lark, DingTalk, WeChat Work, QQ, Telegram, Discord, etc.), the scheduled task entry 113, or the multi-agent conference entry 114. Step S102 (Forming a unified task object): Convert the original request message into a unified task object containing text, image attachments, file attachments, platform identifier, platform in-platform session identifier, sender identity and source metadata. After downloading or copying the attachments, save them to the local physical path and write the media type into the metadata. Step S103 (Formulating a composite session key): Extract the platform and conversationId, and generate a composite session key using a string concatenation formula. : Step S104 (Query and Verify Mapping): Based on the composite session key Query the instant messaging session mapping table im_session_mappings in the database to obtain the corresponding internal task session identifier; then query the task session main table cowork_sessions to verify its physical liveness status. If the mapping exists but the internal session has been cleared, delete the old mapping record immediately. Step S105 (Reuse or Rebuild): If the mapping is valid, append the message to the same internal task session; if the mapping does not exist or is invalid, create a new internal task session and write back the mapping. When the downstream model interface returns an error response indicating that the underlying model session is invalid, delete the old mapping, create a new internal session and retry only once to prevent infinite retries; Step S106 (Binding Return Channel): Link the internal task session, permission request, and final result to the composite session key. Binding enables the remote user's "allow" or "deny" response to be accurately passed to the waiting handle.
[0051] Through the above solution, this embodiment can effectively solve the problem of session freezing caused by the failure of external mapping to be synchronously cancelled after the client's historical sessions are cleared, and achieve dynamic consistency and automatic repair of cross-platform mapping relationship and actual session state.
[0052] In one specific implementation, after appending the request message to the corresponding internal task session in step S100, the system submits the internal task session to the downstream model interface, and performs mapping cleanup, session reconstruction, and single retry submission when a model session failure response is captured.
[0053] First, after appending the transformed request message to the corresponding internal task session, the system packages the internal task session and its accompanying context data and submits it to the downstream model interface. During the submission process, the system reads and records the model session identifier associated with the internal task session, and simultaneously initializes the retry counter, setting its initial value to zero.
[0054] Specifically, the system listens for response messages returned by the downstream model interface. When the downstream model interface returns an error response indicating that the model session is invalid, such as returning a response message containing a preset error code that indicates that the session has expired or that the session identifier is invalid, the system triggers the session self-healing logic.
[0055] Then, the system queries the retry counter value corresponding to the current task. When the retry counter value is determined to be zero, the system performs an update on the mapping relationship and internal session: deletes the old mapping relationship record between the current composite session key and the original internal task session identifier in the database; calls the database generation algorithm to create a new internal task session and initializes the model session identifier field of the new internal task session to empty; subsequently, establishes a new mapping relationship between the current composite session key and the identifier of the new internal task session and writes it to the database; then, rebinds the original request message to the new internal task session.
[0056] Finally, the system updates the retry counter to one and resubmits the newly created internal task session to the downstream model interface for a retry. If the downstream model interface returns an invalid model session error response again after the retry submission, the system determines that the retry counter has reached the set maximum retry threshold, terminates the retry process, and returns an abnormal status to the outside to avoid infinite retry loops.
[0057] In some other alternative implementations, the method for determining the invalid model session error response returned by the downstream model interface is not limited to parsing a specific string. It can also be replaced by recognizing the standard response status code of the HTTP protocol, a specific numerical code in the JSON format error message, or a custom error flag bit in the remote procedure call protocol. In addition to being based on process memory records, the retry counter can also be stored persistently in the task status table of a relational database.
[0058] Compared with existing technologies, this embodiment introduces a mapping cleanup and single-retry mechanism to capture model session failures, which automatically clears failed session mappings and rebuilds internal task sessions, eliminating call deadlocks and infinite retries caused by underlying model session timeouts, and ensuring the continuity of cross-channel task processing and system stability.
[0059] In one specific implementation, before extracting the platform identifier and the session identifier within the platform in step S100, the received heterogeneous request message is first preprocessed for normalization and attachment localization is performed on disk.
[0060] First, receive raw request messages from different access platforms.
[0061] Specifically, the data structure in the original request message is parsed to extract the original text content, file attachments, platform identifier, platform session identifier, sender identity information, and source metadata.
[0062] Then, for file attachments included in the message, the corresponding network transmission protocol or local file interface is invoked to download or copy the file attachments and save them to a preset path in the local file system. Simultaneously, file type detection is performed on the file attachments to obtain their corresponding media type, and this media type and the local save path of the file attachments are written into the message metadata.
[0063] Next, the extracted text, local save path, media type, platform identifier, platform session identifier, sender identity information, and source metadata are structurally encapsulated to generate a task object with a uniform format.
[0064] In some other alternative implementations, the media type of file attachments can be obtained not only by parsing the file extension, but also by reading the byte sequence of the file header or by parsing the protocol response header provided by the access platform; the local file system's save path can also be dynamically allocated to a temporary memory file system or isolated storage area according to the storage policy.
[0065] Through the above solution, this embodiment eliminates the differences in data format of request messages from heterogeneous platforms, and realizes unified encapsulation and decoupling of the processing flow for different input sources; at the same time, it downloads remote attachments from the network in advance and converts them into local file system paths and standardized media type metadata, ensuring the accessibility and reliability of attachment resources in subsequent execution stages.
[0066] In one specific implementation, in step S200, when the skill and model context protocol assembly unit constructs system prompts, it explicitly constrains and limits the skill information injection mechanism in the model context.
[0067] Specifically, the assembly unit first scans the configuration files under the skill directory and extracts a list of skills that have passed the enabled status verification. For enabled skills, the assembly unit only extracts the skill name and brief description information to form a candidate skill list containing skill identifiers and brief functions, rather than directly loading detailed operation documents, code implementations, or complete call prompts for all skills into the context.
[0068] Then, the assembly unit dedicates a skill routing constraint instruction block within the generated system prompt text structure and injects explicit constraint instruction text into this block. This constraint instruction text contains strong constraints on the language model's decision-making behavior: first, it explicitly declares routing instructions, limiting the model to selecting at most one prerequisite skill for the current single request; second, it explicitly declares prohibitions, setting a restriction on unconditionally loading all complete operation instructions, specifications, or prompt text documents of all installed skills in the system into the model context.
[0069] Next, the assembly unit combines the system prompt containing the candidate skill list and skill routing constraint instructions, along with the received request message, into a task execution package and sends it to the large language model agent interface. Based on these constraint instructions, the large language model evaluates and decides whether to call, and at most call, a matching skill only from the candidate skill list. When the skill is needed, the system loads the detailed documentation for that single skill as required.
[0070] In some other alternative implementations, the skill routing constraint instruction can be encapsulated using a structured markup language, which transmits selection restrictions to the model by defining strict syntax nodes in the system prompt words; or, the candidate skill selection method can be combined with similarity retrieval based on vector embedding, where the local retrieval module first pre-selects candidate skill summaries with semantic similarity higher than a preset threshold, and then injects the restriction instruction of selecting at most one prerequisite skill per request together with the pre-selected list into the prompt word context.
[0071] In the specific implementation process, please refer to Figure 4 The execution flow of skill constraints, runtime environment routing, and permission closure in steps S200 and S300 is elaborated in detail, including steps S107 to S112: Step S107 (Generate Skill Constraint Context): The skill and model context protocol assembly unit 300 traverses the SKILL.md file in the skill directory, parses the header metadata and combines it with the start / stop configuration, and only writes the skills that are enabled into the available skill list; at the same time, it explicitly writes the routing instruction "Select at most one prerequisite skill according to the request and comply with the prohibition conditions" in the system prompt words to avoid unconditionally adding all skills to the prompt words. Step S108 (Assemble the Execution Package): Assemble the Unified Task Object, system prompts, available skill list, and Model Context Protocol (MCP) server into a task execution package. When the runtime environment is a packaged client program, rewrite the absolute path of the MCP server's startup command; Step S109 (Determine the runtime environment): Read the configured local, sandbox, or auto mode. In auto mode, a probe is sent to the sandbox daemon. If the sandbox is not ready or there are external attachments that cannot be pushed locally, it automatically returns to the local working directory constrained by the security authorization directory. In sandbox mode, if the isolation environment is not ready, execution is blocked and an explicit error is reported. Step S110 (Streaming Execution and Security Determination): The execution orchestration unit 400 receives streaming model events, and the security policy engine matches the target action type of the tool call command to identify risky actions such as file deletion or directory out-of-bounds access. Step S111 (Complete permission loop): When a risky action is matched, suspend the tool execution handle, generate a permission request with a session identifier, and send it asynchronously to the enterprise instant messaging session that initiated the original request through the gateway. Combined with the timeout timer, if there is no response or a rejection reply is received after the timeout, it is determined to be a rejection and the tool handle is terminated. Step S112 (Persistent Execution Results): Persistently store message streams, tool results, and session states. When system prompts or skill configurations undergo substantial changes, clear incompatible underlying model session handles to trigger a secure rebuild.
[0072] Through the above solution, this embodiment can significantly reduce the overhead of model context bytes and identifiers, avoid the problem of prompt word expansion caused by the increase in the number of skills, and effectively prevent large language models from making incorrect routes and selections when faced with multiple tools with similar functions, thus ensuring the accuracy and efficiency of task orchestration and execution.
[0073] In one specific implementation, based on the above embodiments, the process of assembling the task execution package in step S300 further includes scanning the model context protocol server, matching the communication protocol, and rewriting the path resolution based on the client runtime environment.
[0074] Specifically, first, the skill and model context protocol assembly unit reads the server configuration items in the local configuration file, parsing the startup instructions, command-line argument lists, environment variables, and specified communication transmission protocol modes defined for each model context protocol server. The communication transmission protocol mode is configured as one of the following: standard input / output (stdio) mode, server-sent events (SSE) mode, or HTTP streaming mode. When the communication transmission protocol mode is standard input / output mode, the system establishes bidirectional JSON-RPC message transmission through standard input and standard output pipes in a subprocess; when the communication transmission protocol mode is server-sent events mode or HTTP streaming mode, the system creates a corresponding network client handle, binds it to a remote or local network port for event stream listening and command issuance.
[0075] Then, the skill and model context protocol assembly unit obtains the runtime environment status parameters of the current client program and determines whether the current execution environment belongs to the packaged client program environment. When it is detected that the current runtime environment is a packaged client environment, the system triggers the executable file path rewriting logic, extracting the relative path strings from the original startup command and parameter list in the configuration file. The system obtains the actual physical root directory path of the resources after the packaged client is decompressed or installed, and concatenates and rewrites the executable program name in the original startup command and the relative file path in the parameter list into a complete file system path including the absolute path. The rewritten startup command, parameter list, and established communication channel handle are packaged into a task execution package for subsequent task execution process scheduling and invocation.
[0076] In some other alternative implementations, the detection of the current runtime environment is not limited to checking the packaging identifier, but can also be determined by querying system environment variables, registry paths, or the mount point of the physical directory where the executable file is located; the rewriting of the executable file path can also be replaced by creating system symbolic links, dynamically updating the path environment variables of the current process, or redirecting the runtime path through the virtual file system mapping table.
[0077] Through the above solution, this embodiment can avoid the problem of model context protocol server loading failure and communication interruption caused by changes in physical directory structure after the client program is packaged and released, and ensure that various extension tools and external services can achieve adaptive assembly and stable communication in different terminal operating modes.
[0078] In one specific implementation, the process of executing the task execution package in step S300, in the local working directory or isolated runtime environment, is carried out according to the following steps: First, the orchestration unit reads the pre-set runtime environment configuration mode, which includes automatic mode (auto), isolated mode (sandbox), and local mode (local).
[0079] When the runtime environment configuration mode is automatic, the execution orchestration unit sends physical status probe messages to the isolated runtime environment daemon to obtain the readiness status response of the isolated runtime environment. Simultaneously, the execution orchestration unit scans the file attachment path information contained in the task execution package to verify whether the attachments exist on the host machine's local physical disk and cannot be pushed or mounted to the isolated runtime environment. If the physical status probe returns a not-ready signal, times out, or the verification result shows that there are unreachable local file attachments in the task execution package, the execution orchestration unit triggers routing degradation logic, automatically switching the execution environment of the task execution package to the local working directory constrained by the security-authorized directory prefix.
[0080] When the runtime environment configuration mode is explicitly specified as isolation mode, the execution orchestration unit sends physical status probe messages to the isolated runtime environment. If the probe returns a not ready signal or a communication error, the execution orchestration unit terminates the distribution of task execution packets, intercepts related instruction calls, and generates a response message containing an environment not ready error code to send back to the original initiator.
[0081] In other alternative implementations, the isolated runtime environment can be replaced with a Linux KVM virtual machine, a WebAssembly runtime sandbox, an operating system-restricted child process, or a remote edge computing node. The probe detection method can be replaced with UNIX domain socket connectivity testing, TCP port heartbeat verification, system process liveness queries, or shared memory status bit reading. The secure authorized directory constraint mechanism can be replaced with a file system access control list, path whitelist matching, or relative path baseline restrictions.
[0082] Through the above scheme, this embodiment can perform adaptive routing selection by combining the physical readiness of the isolated operating environment with the accessibility of local attachments, avoiding execution crashes caused by blindly sending tasks when the isolated environment is not ready or the files are unreachable, while providing deterministic blocking protection under explicit isolation requirements.
[0083] In one specific implementation, based on the above embodiments, when executing a task package, the orchestration unit executes the tool execution instructions issued by the parsing model to determine the security of the tool execution instructions. First, the target action type and the target path in the tool execution instructions are extracted. Specifically, the extracted target action type is matched against a preset high-risk action rule base. High-risk action types include file deletion actions and file system authorized working directory boundary violations. A file system authorized working directory boundary violation action refers to an action where the target path exceeds the pre-defined physical boundary of the authorized working directory. Then, if the target action type is determined to be a file deletion action or a file system authorized working directory boundary violation action, the orchestration unit suspends the current tool execution handle, pausing the physical execution of the tool code; simultaneously, it obtains the internal task session identifier bound to the current task and generates a permission request message containing the internal task session identifier, the target action type, and the target path. Next, the permission request message is asynchronously sent to the access platform that initially sent the request message through the input access unit, and a timer is started synchronously for a countdown. If a permission response is received from the access platform before the set timer reaches the preset confirmation timeout threshold, the suspended tool execution handle is restored after matching the internal task session identifier, and the tool instructions continue to be executed; if the set timer reaches the preset confirmation timeout threshold and no reply is received, or a rejection response is received, the execution orchestration unit will determine the authentication result as rejection, terminate the suspended tool execution handle, and send a message indicating that the operation was rejected back to the model context.
[0084] In other alternative implementations, the identification of high-risk action types can be expanded from rule-based matching and directory boundary comparison to a determination mechanism based on access control lists or dynamic permission policy trees; the interactive form of sending permission requests to the access platform can be replaced by client pop-up prompts, one-time Hypertext Transfer Protocol confirmation links, or standard authorization callback interfaces, in addition to rich text interactive cards; the preset confirmation timeout threshold can be set within the range of 10 seconds to 300 seconds depending on the type of access platform.
[0085] Through the above scheme, this embodiment can intercept unauthorized high-risk operations on the file system, prevent physical files from being accessed or damaged beyond their boundaries, and complete asynchronous permission confirmation through the original request channel. When there is no response after timeout or explicit rejection, the default rejection policy is automatically executed, thereby ensuring the security and unauthorized access protection capabilities of the terminal device's physical file system.
[0086] In one specific implementation, based on the above embodiments, the method further includes a triggering and filtering process for implementing automatic scheduling of timed tasks.
[0087] First, the scheduler built into the system is configured to trigger wake-up events at preset wake-up intervals, such as 500 milliseconds, without having to maintain long-term timed wait objects in memory.
[0088] Specifically, each time the task is woken up, the scheduler sends a predicate query instruction containing specific composite conditions to the database to filter out task records that meet the execution conditions from the database table storing the scheduled task configurations. This expiration query predicate requires that the task records to be triggered must simultaneously meet the following conditions: The task's enabled status field is in an active indication state, for example, the enabled flag is set to 1; The scheduled next execution timestamp of the task is less than or equal to the physical Unix timestamp currently obtained by the system; The timestamp field is empty during task execution, indicating that no other thread or task instance is currently occupying and executing the task. The task's expiration timestamp field is not set, or the current physical Unix timestamp has not yet reached the limit set by the expiration timestamp.
[0089] Then, when the database returns one or more task records that fully meet the above predicate filtering conditions, the scheduler extracts the task parameters and target configuration from the task record and starts the specific task execution process corresponding to that task record.
[0090] In some other alternative implementations, the preset wake-up period can be set to any fixed value between 100 milliseconds and 2000 milliseconds according to the system's computing power requirements, or an adaptive wake-up interval based on the expected expiration time of the next task can be adopted; predicate queries in the database can also be implemented through in-memory relational database index matching, file database range scanning, or range retrieval of embedded key-value storage systems.
[0091] In the specific implementation process, please refer to Figure 5 It further includes the persistent scheduling of timed tasks and the process of exception recovery, corresponding to steps S113 to S117: Step S113 (Expiration Query): The persistent state unit 500 controls the scheduler to wake up according to a preset short period (e.g., 500ms) and executes an SQL query in the database containing a compound condition expiration predicate: Step S114 (mutually exclusive execution and recording): After finding the expired task, check the active task set active_tasks in the current process; if it does not exist, atomically write the running_at_ms field to the database (forming a DB-level lock), add it to the memory set (forming a process-level lock), and create an independent running record; Step S115 (Calculate the next run): For loop tasks with a fixed time interval (interval milliseconds), calculate the next trigger timestamp according to the following anti-rush formula to prevent intensive reruns after sleep / wake-up: Step S116 (Failure Management and Startup Recovery): When a task fails, increment the consecutive failure counter failed_count. When the count reaches a preset threshold (e.g., 5 times), the task is automatically stopped. When the client application starts, it scans for any remaining non-empty running_at_ms records, clears the exclusive flag, and sets it to abnormal termination to remove the deadlock. Step S117 (Result Notification): After the task is completed, read the configured target notification session identifier target_conversation_id, and send the status and summary back to the designated enterprise instant messaging channel.
[0092] Through the above scheme, this embodiment utilizes lightweight periodic wake-up combined with database-level state predicate query, eliminating the dependence on long-term resident memory timers and avoiding the loss of task trigger state due to application process restart, suspension or system hibernation, thus ensuring the accuracy of task expiration verification and the atomicity of state determination.
[0093] In one specific implementation, based on the above embodiments, before initiating the execution process corresponding to the selected expired task record, the system first queries the active task set maintained in the memory of the current process. Specifically, this active task set is implemented using an exclusive set structure in memory. If the query result shows that the active task set already contains the unique identifier of the task record to be executed, it indicates that the task is already running in the current process, and the system directly terminates the repeated restart operation for the task record; if it is determined that the active task set does not contain the unique identifier of the task record to be executed, the system obtains the physical timestamp of the current terminal device, writes the timestamp as an atomic update value into the running_at_ms field of the corresponding task record in the database to complete the database-level locking mark, and simultaneously writes the unique identifier of the task record into the active task set of the current process to complete the memory-level locking mark, and then officially starts the asynchronous execution thread or coroutine corresponding to the task record.
[0094] Specifically, for timed tasks with a preset execution type of fixed time interval, when the system completes execution or updates the task status, it reads the last actual start timestamp `lastRun` and the user-configured time interval in milliseconds `interval` from the task record. The system adds `lastRun` and `interval` to obtain the scheduled next execution timestamp, and simultaneously obtains the current system physical timestamp `now`. The system uses a numerical comparison function to take the larger of the scheduled next execution timestamp (the sum of `lastRun` and `interval`) and the current timestamp `now`, and uses this as the updated next execution timestamp `nextInterval`, which is then persistently written to the `next_run_at_ms` field of the task record in the database. The specific calculation logic is expressed as follows: In other alternative implementations, the set of active tasks within the current process can also be stored using a ConcurrentHashMap or a thread-safe atomic bitmap; the update operation of the database field running_at_ms can also be combined with a conditional update predicate in the SQL statement, such as WHERE running_at_ms IS NULL, to achieve optimistic locking concurrency control; in addition to milliseconds, the unit of timestamp calculation can also be adjusted to microseconds or seconds according to the system precision requirements.
[0095] Through the above scheme, this embodiment can establish a dual mutex lock mechanism by using the in-process memory set and the database atomic field, which can effectively prevent the same timed task from being repeatedly re-entered in the same process and from being concurrently preempted across cycles. At the same time, the introduction of the current timestamp to participate in the maximum value verification of the next running time blocks the phenomenon of intensive make-up running caused by historical backlog tasks after the terminal device has been in a long period of sleep, shutdown or pause wake-up, and eliminates the impact of computing resource surge on the local system.
[0096] In one specific implementation, based on the above embodiments, the scheduled task process further includes a task execution exception handling and result notification mechanism: Specifically, when a task record that has been awakened throws an uncaught exception or returns a failure status instruction during execution, the error log information in the current context is captured. A run log with an end timestamp of `finished_at_ms` and a status marker of 'failed' is written to the `scheduled_task_runs` table, and the `error_message` field is assigned the specific error stack trace. Then, an atomic increment operation is performed on the `failed_count` field of the task record in the `scheduled_tasks` table, incrementing the current value by one. Next, the latest `failed_count` value of the task record is read and compared with a preset failure count threshold, for example, set to 5. If the `failed_count` value reaches or exceeds this threshold, a deactivation action is automatically triggered. The database update command `UPDATE scheduled_tasks SET enabled = 0 WHERE id = task_id;` is executed, modifying the enabled status field of the task record to 0, thereby terminating the continued scheduling of the abnormal task in subsequent cycles. If the task is executed successfully, the failed_count will be reset to zero, and the running log status will be marked as 'success'.
[0097] Next, during the task completion phase (regardless of whether the execution result is success or failure), the task execution result data or failure exception summary is extracted and assembled to generate a result notification message containing the task name, execution time, final status, and output artifact links. The target notification identifier field `target_conversation_id` configured in the `scheduled_tasks` table is read, and the message gateway is invoked to asynchronously send the result notification message to the target session channel corresponding to `target_conversation_id`, completing the closed-loop notification of task scheduling.
[0098] In some other alternative implementations, the threshold determination logic of the consecutive failure counter can be replaced by a fixed value comparison with a dynamic probability decay calculation based on task priority or task type; in addition to directly sending the result notification message back to the chat window corresponding to the internal session identifier, the transmission channel can also be replaced by sending a JSON message to the configured external Webhook address, triggering the system's native notification pop-up, or sending an email.
[0099] Through the above scheme, this embodiment can automatically identify and isolate abnormal timed tasks that repeatedly fail to execute, preventing meaningless consumption of system computing power and log bursts caused by faulty tasks. At the same time, by accurately sending the execution results back to the designated session, the traceability of the entire scheduling process and the right of operation and maintenance to know are guaranteed.
[0100] In one specific implementation, based on the above embodiments, the task processing process further includes a multi-agent meeting orchestration process. Specifically, the system first reads the meeting task status stored in the database, obtains the pre-configured meeting collaboration mode, and schedules multiple meeting participants to execute sequentially or in parallel according to sequential mode, parallel mode, or debate mode. During the execution of sequential mode or debate mode, after each meeting participant node completes its speech or task processing in the current round, the multi-agent meeting orchestration unit updates the persistent record in the meeting status table in the database in real time, writing the current round index (currentRound), the current participant index (currentParticipantIndex), and the list of completed participants (completedParticipants).
[0101] During system operation, if multi-agent collaboration is interrupted due to abnormal process exit, network interruption, or device restart, the system will read the aforementioned meeting status fields stored in the database during the restart initialization phase. Based on the read current round index and current participant index, the system will locate the specific node where the interruption occurred, automatically restore the historical speaking records of completed participants, and directly resume execution from the position of the interrupted participant, without needing to rerun the previously completed participants.
[0102] In some other alternative implementations, the list of completed participants can be stored not only as a JSON array string in a single status table field, but also as atomic transactions written one by one through an associated detail table; in addition to sequential, parallel and debate modes, the meeting scheduling mode can also be extended to a moderator arbitration mode or a role pipeline mode.
[0103] See Figure 6 In the specific implementation process, it further includes multi-agent meeting execution and adaptive context pruning processes, corresponding to steps S118 to S122: Step S118 (Resume Meeting Progress): The multi-agent meeting orchestration unit 600 reads the meeting status from the database and obtains the current round index currentRound, the current participant index currentParticipantIndex, and the list of completed participants completedParticipants. Step S119 (Scheduling Participants by Mode): Schedule conference participants to execute sequentially or concurrently according to sequential mode, parallel mode, or debate mode; Step S120 (Estimate context size): Traverse the historical message text and count the number of Chinese characters for each message. Number of non-Chinese characters Calculate the estimated token size using a character-weighted formula. : Step S121 (Selecting a trimming strategy): Based on the estimated size Adaptive switching between fourth-order policies: when Use the full history strategy when; Use the most recent 3 rounds of sliding window strategy; when When using a hybrid strategy of early message compression plus the original text from the last two rounds; Use a minimalist summary strategy that retains only the most recent remarks from each participant; Step S122 (Save recoverable state): The progress is persisted immediately after each participant finishes speaking. After an abnormal interruption and restart, the index is read directly and execution is resumed from the specific participant position where the interruption occurred, without replaying the successfully spoken speech.
[0104] Through the above scheme, this embodiment persists the progress status of the multi-agent meeting to the database in real time at the participant level, realizing precise breakpoint continuation of the multi-agent collaborative process in the face of system crashes or unexpected interruptions. This avoids repeated calculations and inference calls to previously successfully executed nodes when restarting the meeting, reduces computing resource consumption and interface call overhead, and improves the reliability and recovery efficiency of multi-agent collaborative tasks.
[0105] In one specific implementation, the estimation of the context size of historical messages in a multi-agent conference and the dynamic switching process of the context policy are refined, including: First, the multi-agent conference orchestration unit extracts all text content from the current conference's historical messages. Specifically, the multi-agent conference orchestration unit iterates through the historical message strings and counts the number of Chinese characters in each string. and the number of non-Chinese characters Among them, the number of Chinese characters This represents the total number of characters within the preset Unicode character set range \u4e00-\u9fa5, and the number of non-Chinese characters. This represents the total number of English letters, numbers, and punctuation marks excluding Chinese characters.
[0106] Next, the multi-agent conference orchestration unit estimates the token size of the current context based on a character-weighted calculation formula. : Based on the estimated context size The multi-agent conference orchestration unit adaptively and dynamically switches between preset fourth-order context strategies. Specifically, the first preset threshold is set to 2000, the second preset threshold to 5000, and the third preset threshold to 8000. when At that time, the multi-agent conference orchestration unit adopts the full historical message strategy to completely splice together the original text of the speeches of all conference participants in all rounds and write it into the model context; when When switching to the sliding window message strategy, the multi-agent conference orchestration unit extracts the original text of the participants' speeches from the three most recent rounds from the historical messages and discards earlier historical speeches; when When switching to a hybrid strategy, the multi-agent conference orchestration unit compresses early historical messages into background summary text using a lightweight model, while retaining the original text of the last two rounds of speeches. The background summary text and the original text of the most recent speeches are then merged to construct the model context. when When switching to a minimalist summary strategy, the multi-agent conference orchestration unit discards all speeches from the intermediate discussion process and extracts only the latest summary speech from each conference participant, combining them in the order of the participants to generate a summary context.
[0107] In some other optional implementations, the weight coefficient of Chinese characters in the estimation formula can be adjusted within the range of 1.0 to 2.0 according to the segmentation characteristics of the specific large language model, and the weight coefficient of non-Chinese characters can be adjusted within the range of 0.1 to 0.5; the estimation method of context size can also be replaced by direct conversion based on the byte length of historical text; the values of the first preset threshold, the second preset threshold and the third preset threshold can also be scaled proportionally according to the maximum context window limit of the corresponding large language model.
[0108] The above approach enables rapid estimation of context size with low computational cost without frequent calls to high-overhead tokenizers. It also automatically matches appropriate text compression strategies for different context sizes, preserving the discussion context while keeping token consumption within a preset response range, thus reducing the computational cost of inference for large language models.
[0109] In one specific implementation, the user's long-term memory retrieval process is configured to perform controlled extraction and analysis of text content generated during internal task sessions.
[0110] First, the system pre-filters the raw text in internal task sessions. By parsing the text structure and content features, it identifies and filters out information that does not have long-term storage value. Specifically, this includes: using syntax parsing or pattern matching to identify and filter code blocks containing code segment markers; matching high-frequency social polite phrases to filter everyday greetings; and matching system-level operation command rules to filter temporary commands such as clearing caches and configuring temporary environments.
[0111] Then, the filtered candidate texts are scored using multi-dimensional rules. The scoring mechanism includes factual, personal preference, and timeliness dimensions: for the factual dimension, it assesses whether the text contains definitive statements about the user's identity, profession, or knowledge background; for the personal preference dimension, it assesses whether the text contains expressions of the user's format, language, or operating habits; for the timeliness dimension, it assesses whether the information contained in the text has long-term validity across sessions, reducing the scoring weight of short-term information that is only effective in the current session. The scoring module calculates the comprehensive score of the candidate texts based on the preset weights of each dimension.
[0112] Furthermore, after completing the rule scoring, the system sets up an extraction quantity control mechanism to limit the number of candidate records implicitly extracted and prepared for writing to the database in a single instance to no more than a preset upper limit. When the number of candidate texts with a comprehensive score reaching a preset threshold exceeds the preset upper limit, the system sorts them according to their comprehensive scores from high to low, and only extracts the high-scoring records that meet the preset upper limit for subsequent processing.
[0113] In some other alternative implementations, code block recognition in text pre-filtering can be replaced by text entropy value calculation or semantic label classifier; weight allocation in rule scoring mechanism can be dynamically adjusted according to different interaction scenarios; the preset upper limit of candidate records can also be dynamically scaled according to the total number of characters in the current conversation text or the number of interaction rounds.
[0114] Through the above scheme, this embodiment can automatically identify and remove useless noise text in the conversation, reducing the pollution of the long-term database by low-value data; at the same time, through multi-dimensional rule scoring and quantity limit control, while ensuring that high-value preferences and factual information are accurately extracted, the scale of data writing is effectively controlled, reducing the overhead of subsequent processing and storage resources.
[0115] In one specific implementation, based on the above embodiments, when the score obtained by scoring a candidate record falls within a preset critical range, which in a specific example is set to the range of 0.4 to 0.7 (inclusive of 0.4 but exclusive of 0.7), the user memory unit combines the candidate record into a structured prompt and sends it to the large language model for confidence assessment. The large language model receives the prompt containing candidate text and contextual information, and returns a structured response message containing a Boolean decision field and a floating-point confidence value. When the decision field in the response message indicates that the candidate text belongs to the user's long-term memory and the confidence value reaches a preset confidence threshold, such as 0.6, the candidate record is determined to pass the confidence assessment; if the preset confidence threshold is not reached or it is determined to be temporary information, the candidate record is discarded.
[0116] For candidate records that pass the confidence level decision, the user memory unit first performs a standardized format conversion on their text content, then calls a digest algorithm such as SHA-256 to calculate a fixed-length hash value for the converted text content, generating a unique corresponding content hash fingerprint. Next, the user memory unit extracts the internal task session identifier corresponding to the current task as the source session identifier, and assembles the content hash fingerprint, confidence value, source session identifier, and memory text content into a relational database instruction, which is then submitted to the persistent state unit. The persistent state unit performs an insert operation with unique index constraints in the database table user_memories, using the hash_fingerprint field for deduplication verification. If a record with the same content hash fingerprint already exists in the database, conflict update logic is executed, only refreshing the timestamp field and confidence value of the existing record; if the same content hash fingerprint does not exist in the database, a new data row is written.
[0117] In other alternative implementations, the algorithm for calculating the content hash fingerprint can be replaced with MD5, SHA-1, SHA-512, or MurmurHash3 algorithms; the confidence determination model can be replaced with a lightweight neural network classifier deployed locally on the client, or a similarity distance calculation module based on a vector database; the deduplication verification mechanism can also adopt the method of performing a database condition query before writing, or adopt a memory pre-verification mechanism based on a Bloom filter.
[0118] The above scheme enables secondary intelligent adjudication of texts with scores in the medium uncertainty range, improving the accuracy of memory retrieval while controlling computing power allocation; the deduplication mechanism based on content hash fingerprint effectively eliminates the physical storage of duplicate information and provides the ability to trace back to the original generation session from long-term memory.
[0119] See Figure 7 This illustrates the relationships (ER diagram) among database entities in persistent state unit 500. Table 1 shows the entity groups, main relational database tables, and the specific state problems they address: Table 1 Comparison of Persistent Data Structures and State Issues
[0120] The module mapping relationship of the above processing method steps in the electronic device software architecture is shown in Table 2: Table 2 Mapping Table of Task Processing Steps and Software Functional Modules
[0121] like Figure 8 As shown, this embodiment of the invention also provides a local digital employee task processing system based on cross-channel session mapping and resumable orchestration. The system includes: a session mapping unit M100, a skill assembly unit M200, an execution orchestration unit M300, and a persistence unit M400.
[0122] The session mapping unit M100 is configured to receive request messages from multiple different access platforms, extract the platform identifier and the intra-platform session identifier from the request message, and concatenate the platform identifier and the intra-platform session identifier to generate a composite session key. The session mapping unit M100 queries the database based on the composite session key to obtain the corresponding internal task session identifier, and after verifying that the internal task session identifier is valid, appends the request message to the corresponding internal task session. In some optional implementations, the concatenation rule for generating the composite session key can use a specific delimiter to connect the platform identifier and the intra-platform session identifier, or use a specified hash algorithm to perform a digest calculation on the extracted multi-field identifier combination to generate a fixed-length session key.
[0123] The skill assembly unit M200, connected to the session mapping unit M100, is configured to scan and parse skill metadata in the skill catalog, read configuration attributes from the skill metadata, and write enabled skills into the available skill list. When generating the model context, the skill assembly unit M200 explicitly writes a constraint instruction limiting the number of candidate skills that can be loaded into the system prompt, and combines the received request message with the available skill list to assemble a task execution package. In some optional implementations, the parsing of skill metadata can be based on a structured configuration file or a formatted text document, and the constraint instruction for the number of prerequisite skills selected can be set to a maximum of one prerequisite skill per interaction.
[0124] The execution orchestration unit M300 is connected to the skill assembly unit M200 and is configured to receive task execution packages and detect the physical readiness status of the isolated runtime environment. Based on the readiness status and task configuration, it routes the task execution package to the local working directory or the isolated runtime environment for execution. During task execution, the execution orchestration unit M300 monitors instruction actions in real time. When a preset risk action is detected, it pauses the issuance of tool instructions and suspends the tool execution handle, constructs a permission request message, and asynchronously sends it to the original access platform that sent the request message. Based on the confirmation response returned by the original access platform or the timeout status of the internal timer, the execution orchestration unit M300 decides whether to resume or terminate the tool execution handle. In some optional implementations, the isolated runtime environment can be a container sandbox, a virtualization environment, or a restricted subprocess. The permission request message can be transmitted to the original access platform through interactive card messages, callback interfaces, or message push channels.
[0125] The persistence unit M400 is connected to the session mapping unit M100, the skill assembly unit M200, and the execution orchestration unit M300, and is configured to persistently store session messages, task execution status, and runtime ledgers in a local database. When the client application restarts, the persistence unit M400 scans the local database for remaining running markers, identifies incomplete task records caused by unexpected interruptions, updates the status of the corresponding incomplete task records to "abnormally terminated," and clears the remaining running markers in the local database to restore the system state. In some optional implementations, the local database may employ an embedded relational database or a file-based storage engine.
[0126] The aforementioned session mapping unit M100, skill assembly unit M200, execution orchestration unit M300, and persistence unit M400 work together in concert. The session mapping unit M100 normalizes and parses request messages from heterogeneous platforms, constructing composite session keys to map different access channels to a unified internal task session, eliminating the impact of cross-platform interface differences on underlying task location. The skill assembly unit M200 receives the mapped task requests, parses skill metadata, and injects pre-selection constraint instructions to control the model context volume of the assembled task execution package, avoiding context overload and selection chaos when a large number of tools are accessed. The execution orchestration unit M300 receives the task execution package, combines it with isolated runtime environment probes to achieve dynamic routing of execution paths, and suspends handles for asynchronous cross-channel permission verification when high-risk actions are triggered, ensuring the security of the local terminal file system and runtime environment. The persistence unit M400 records the task status throughout the entire process and scans and cleans up residual running markers when the application restarts, eliminating the task status lock-up problem caused by crashes or abnormal exits. The various units work together to form a closed-loop task processing mechanism that covers access mapping, context assembly, secure routing execution, and crash self-healing recovery.
[0127] Compared with existing technologies, this embodiment achieves unified location and validity verification of multi-source heterogeneous requests through a composite session key and internal task session mapping mechanism, ensuring session continuity for cross-platform interaction; reduces model context overhead and lowers the probability of incorrect tool selection through skill metadata parsing and injection of pre-skill selection constraint instructions; establishes a security barrier for the local physical environment through environment detection and risk action handle suspension authentication mechanism, improving system execution security; and eliminates residual deadlocks after abnormal system exit through database state persistence and startup scan clearing mechanism, ensuring the recoverability of task state.
[0128] In one specific implementation, after receiving the composite session key, the session mapping unit M100 first queries the heterogeneous session mapping table in the database to obtain the corresponding internal task session identifier. If the mapping relationship exists, but further verification of the internal task session master table reveals that the record corresponding to the internal task session identifier has been physically deleted or the record's status field has been marked as cleaned up, the session mapping unit M100 triggers an invalidation cleanup and reconstruction procedure. The session mapping unit M100 executes a database deletion command, clearing the old mapping record corresponding to the composite session key in the heterogeneous session mapping table; subsequently, it calls the session generation interface to create a new internal task session record in the internal task session master table and assign a new internal task session identifier. Simultaneously, it writes the mapping relationship between the new internal task session identifier and the current composite session key into the heterogeneous session mapping table, completing the cleanup of invalid mappings and the rebinding of the new session.
[0129] Furthermore, when an internal task session is submitted to the downstream large language model interface, and the downstream large language model interface returns an error response indicating that the underlying model session has failed, the built-in security self-healing mechanism of the session mapping unit M100 is activated. The session mapping unit M100 identifies from the error message that the currently associated model session handle has timed out and been deregistered on the server side, and immediately physically deletes the mapping record corresponding to the composite session key from the heterogeneous session mapping table; subsequently, the session mapping unit M100 calls the database interface to generate a new internal task session, sets the model session handle field to null, rebinds the original task object to the new internal task session, and updates the heterogeneous session mapping table; based on this, the session mapping unit M100 sets the retry counter to 1, re-initiates a retry submission to the downstream large language model interface, and only initiates one retry submission; if the second submission still returns an error, the retry is terminated and a system exception is thrown, thus preventing an infinite retry loop.
[0130] In some other alternative implementations, the database used to store and verify session mapping relationships can be replaced by an embedded relational database with a key-value store database such as RocksDB or LevelDB; in addition to parsing JSON format error messages, the underlying model can also identify session failures by matching and parsing error text based on specific HTTP response header status codes such as 401 or 403 or based on regular expressions.
[0131] Compared with existing technologies, this embodiment can automatically identify and clear hanging mappings left over from historical cleanup, eliminate continuous errors and freezing caused by session timeouts or failures of the underlying model in cross-platform interaction, achieve automatic self-healing of sessions without manual user intervention, and prevent infinite retries and waste of computing resources in abnormal states by limiting single retries.
[0132] In one specific implementation, the execution orchestration unit M300 is equipped with an environment probe component and an authorization determination engine, which are used to dynamically select the runtime carrier before executing the task execution package.
[0133] When the runtime environment configuration mode is read as automatic (auto), the execution orchestration unit M300 first sends a status probe request to the daemon process of the isolated runtime environment. If the probe returns a timeout response, service not started, or interface abnormality, it is determined that the isolated runtime environment is in a pre-ready state; alternatively, the execution orchestration unit M300 scans the local file attachment paths contained in the task execution package. When it detects that the local file attachments are located outside the reachable path or mounted directory of the isolated runtime environment and cannot be pushed into the isolated runtime environment, the execution orchestration unit M300 automatically returns the task execution carrier from the isolated runtime environment to the local working directory. When executing the task in the local working directory, the authorization determination engine compares the target operation path with the preset secure authorization directory to ensure that file reading, writing, and command execution are strictly restricted to the scope of the secure authorization directory.
[0134] When the runtime environment configuration mode is read as the explicitly specified isolation mode (sandbox), the execution orchestration unit M300 triggers a status probe request to detect the isolated runtime environment. If the probe detection result shows that the isolated runtime environment is in an unready state, the execution orchestration unit M300 directly blocks the subsequent issuance of task execution packets, terminates the current tool execution handle, and generates a response message containing a description of environment unavailability for return.
[0135] In other alternative implementations, the isolated runtime environment can be replaced by a lightweight WebAssembly sandbox, a restricted operating system subprocess, or a remote edge computing node; the probe detection mechanism can also be replaced by process identifier liveness detection, local socket heartbeat detection, or shared memory status bit verification.
[0136] Through the above solution, this embodiment achieves collaborative awareness of the runtime environment readiness and the reachability of local file resources. Under the premise of ensuring secure isolation, it prevents indiscriminate execution failures caused by sandbox incompatibility and avoids the potential for unreachability of external local files after they enter the isolated environment.
[0137] In one specific implementation, the persistent unit M400 further includes a timed scheduling module and a memory lock management module, which are used to precisely control the execution cycle, concurrency mutual exclusion, and anti-burst flow triggering of timed tasks.
[0138] The timed scheduling module is configured to trigger wake-up events periodically according to a preset wake-up cycle. Upon each wake-up, the timed scheduling module sends a query instruction containing an expiration query predicate to the underlying database. The logical expression for the expiration query predicate is: in, This field indicates the task's enabled status and its value is logically true. Indicates the Unix timestamp for the next scheduled execution of the task; Represents the current system's physical Unix timestamp; This is a running status flag field; when its value is empty, it indicates that no process or thread is currently running the task. This indicates that the current time has not exceeded the preset task expiration timestamp. .
[0139] When the database returns a task record that satisfies the expiration query predicate, the persistence unit M400 first verifies the active task set maintained in the memory lock management module. If the active task set does not contain the task identifier for that task record, the persistence unit M400 will then use the current physical timestamp. The task record is atomically written to the database. The field forms the first layer of database-level lock; at the same time, the persistence unit M400 adds the task identifier to the active task set, forming the second layer of process memory-level lock.
[0140] For configuration with a fixed time interval duration For millisecond-based looping tasks, the persistent unit M400 recalculates the timestamp for the next execution time using the following formula when execution is triggered: in, This represents the Unix timestamp at the actual start time of this task; This indicates the preset loop interval in milliseconds; This represents the actual physical Unix timestamp at the time of the current wakeup. (Calculated) The task record was updated and written to the database. Field.
[0141] In some other alternative implementations, the preset wake-up period of the timed scheduling module can be configured between 100 milliseconds and 5000 milliseconds, or replaced with a wake-up mechanism triggered by operating system-level events or external network messages; the atomic write lock in the database can also be replaced with a file system exclusive lock, a named pipe lock, or a mutex key in a distributed cache system; the fixed interval parameter in timestamp calculation can also be dynamically calculated at discrete time points based on the Cron expression parser.
[0142] Through the above scheme, this embodiment utilizes a dual mutual exclusion mechanism combining database predicates and process memory locks to eliminate the task preemption problem of multiple processes or multiple threads in the same process under short-cycle wake-up; by using the anti-burst flow timestamp calculation formula, it avoids the risk of system resource overflow caused by high-frequency and intensive rerunning of historical tasks after the terminal device has experienced hibernation or shutdown wake-up, thus ensuring the stability and reliability of local timed task scheduling.
[0143] The above description, in conjunction with specific preferred embodiments, provides a further detailed explanation of the present invention. It should not be construed that the specific implementation of the present invention is limited to these descriptions. For those skilled in the art, various simple deductions or substitutions can be made without departing from the concept of the present invention, and all such modifications and substitutions should be considered within the scope of protection of the present invention.
Claims
1. A local digital employee task processing method based on cross-channel session mapping and resumable orchestration, characterized in that, include: Receive request messages from multiple different access platforms, extract the platform identifier and the intra-platform session identifier from the request message and concatenate them into a composite session key, query the database according to the composite session key to obtain the corresponding internal task session identifier, and append the request message after verifying the validity of the internal task session identifier. Parse the skill metadata in the skill catalog, write the enabled skills into the available skill list, and when generating the model context, explicitly write the selection quantity constraint instruction of the prerequisite skills into the model context, and assemble the request message and the available skill list into a task execution package. The readiness status of the isolated operating environment is detected, the task execution package is executed in the local working directory or the isolated operating environment, and the tool execution handle is suspended when a preset risk action is detected. The permission request is asynchronously sent to the access platform that sent the request message, and the tool execution handle is restored or terminated based on the returned response or timeout status. Persistently store session messages and task running status, and scan the database for remaining running markers when the application restarts, mark incomplete records as abnormally terminated and clear the running markers.
2. The method according to claim 1, characterized in that, After retrieving the corresponding internal task session identifier from the database based on the composite session key, the process further includes: If the query results show that the mapping exists but the corresponding internal task session has been cleaned up in the database, then delete the old mapping record of the composite session key and the internal task session identifier, create a new internal task session, and write the new internal task session identifier and the composite session key into the database.
3. The method according to claim 1, characterized in that, After appending the request message to the corresponding internal task session, the following is also included: Submit the internal task session to the downstream model interface; when the downstream model interface returns an error response indicating that the model session is invalid, delete the mapping relationship of the composite session key, create a new internal task session and update the mapping relationship, and retry the submission only once.
4. The method according to claim 1, characterized in that, Before extracting the platform identifier and intra-platform session identifier from the request message, the process also includes: The request message is converted into a unified task object containing text, file attachments, platform identifier, platform session identifier, sender identity, and source metadata; the file attachments are downloaded or copied and saved to the local file system path, and the media type of the file attachments is written into the message metadata.
5. The method according to claim 1, characterized in that, The constraint instructions for the number of prerequisite skills to be selected include: The generated model context explicitly includes routing directives that limit a single request to selecting at most one prerequisite skill and prohibit the unconditional addition of all installed skill content to the model context.
6. The method according to claim 1, characterized in that, When assembling the task execution package, the following are also included: The configured model context protocol server is assembled into the task execution package, wherein the model context protocol server communicates using standard input / output, server-sent events, or streaming hypertext transfer protocol; when the runtime environment is a packaged client program, the startup executable file path of the model context protocol server is rewritten according to the current runtime environment.
7. The method according to claim 1, characterized in that, The execution of the task execution package in the local working directory or the isolated runtime environment includes: When the runtime environment configuration mode is automatic, read the probe status of the isolated runtime environment; if the isolated runtime environment is not ready, or if the task execution package contains local file attachments that cannot be pushed to the isolated runtime environment, return to the local working directory constrained by the security authorization directory to execute the task execution package; when the runtime environment configuration mode is explicitly specified isolation mode and the isolated runtime environment is not ready, block execution and return an environment unavailable response.
8. The method according to claim 1, characterized in that, It also includes a user long-term memory retrieval process, which includes: Filter code blocks, greetings, and temporary instructions from the text of the internal task session; score the filtered candidate text according to rules regarding factuality, personal preference, and timeliness, and limit the number of candidate records implicitly extracted and written to the database in a single instance to no more than a preset upper limit.
9. The method according to claim 8, characterized in that, The user's long-term memory retrieval process also includes: For candidate records whose scores according to the rules fall within a preset critical range, the model is invoked to make a confidence determination; the candidate records that pass the confidence determination are combined with the content hash fingerprint, confidence value and source session identifier and written into the memory database table, and deduplication is performed using the content hash fingerprint.
10. A local digital employee task processing system based on cross-channel session mapping and resumable orchestration, characterized in that, include: The session mapping unit is used to receive request messages from multiple different access platforms, extract the platform identifier and the session identifier within the platform from the request message and concatenate them into a composite session key, query the database according to the composite session key to obtain the corresponding internal task session identifier, and append the request message after verifying the validity of the internal task session identifier. The skill assembly unit is used to parse the skill metadata in the skill catalog, write the enabled skills into the available skill list, and explicitly write the selection quantity constraint instruction of the prerequisite skills into the model context when generating the model context, and assemble the request message and the available skill list into a task execution package. An execution orchestration unit is used to detect the readiness status of the isolated operating environment, execute the task execution package in the local working directory or the isolated operating environment, suspend the tool execution handle when a preset risk action is detected, asynchronously send the permission request to the access platform that sent the request message, and decide to restore or terminate the tool execution handle based on the returned response or timeout status. The persistence unit is used to persistently store session messages and task running status, and scan the database for remaining running markers when the application restarts, setting incomplete records as abnormally terminated and clearing the running markers.
