Runtime state management and process recovery method and system for multi-agent workflow in medical interactive task scenarios

CN123017430APending Publication Date: 2026-10-30ZHEJIANG UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611120247.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-07-27
Publication Date
2026-10-30

AI Technical Summary

Technical Problem

[0003]然而,在医疗长流程交互任务中,用户输入往往具有多轮次、非连续和补充式的特点,系统执行过程还可能涉及多个专家智能体协同分析以及外部工具的调用

Benefits of technology

(1)能够提高医疗多智能体工作流的连续执行能力,在用户中断交互或重新进入会话并补充信息的情况下,减少重复问诊和重复执行。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123017430A_ABST
    Figure CN123017430A_ABST
Patent Text Reader

Abstract

The application discloses a runtime state management and process recovery method and system of multi-agent workflow in a medical interactive task scenario, and the method comprises the following steps: loading a predefined workflow comprising a domain intention recognition node, an interactive diagnosis node, an expert collaboration node, a tool calling node and a result output node; after receiving a user request, querying a historical runtime state object, and creating or loading a runtime state object meeting a recovery condition; the runtime state object comprises a user information state, an expert collaboration execution state, a tool execution state, a supplementary information request state and a workflow control state; when the diagnosis or the expert collaboration needs the user to supplement information, a recovery entry node is set and the workflow is paused; after the user inputs again, the corresponding process is continued based on the recovery entry node. The application can reduce repeated diagnosis and repeated execution, and improve workflow continuity, stability and state consistency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to a method and system for runtime state management and process recovery of multi-agent workflow in medical interactive task scenarios. Background Technology

[0002] With the development of large language models and multi-agent technology, medical interaction systems based on multi-agent workflows are gradually being applied to scenarios such as intelligent consultation, assisted diagnosis and treatment, multi-departmental collaborative analysis, and medical information processing. Existing medical multi-agent systems typically complete tasks such as user consultation, information analysis, tool invocation, and result generation through the division of labor and cooperation among multiple agents, and combine external tools and knowledge bases to improve the system's processing capabilities.

[0003] However, in long-process medical interactions, user input is often multi-round, discontinuous, and supplementary. The system execution process may also involve collaborative analysis by multiple expert agents and the invocation of external tools. Existing solutions have the following problems: First, during multi-agent collaborative execution, different agents generate consultation states, expert analysis states, tool invocation states, and intermediate inference results, respectively. Existing systems lack a unified runtime state representation and synchronization mechanism, which can easily lead to inconsistencies in context information and task progress between different agents. Second, during cross-round medical interactions, users may leave midway, delay supplementing symptom information, or subsequently uploading examination results. Existing systems have difficulty accurately identifying the historical task stage corresponding to this supplementary information, which can easily lead to repeated consultations, re-analysis, or context connection errors. Third, during expert agents requesting supplementary information or the execution of external tools, existing systems lack structured records of waiting states, request sources, supplementary content, and recovery locations. This can easily lead to difficulties in restoring the supplementary information to the corresponding expert task or accurately returning the tool execution results to the expert agent that initiated the tool invocation request.

[0004] Therefore, how to uniformly maintain the runtime state of multi-agent workflows in medical interactive task scenarios, and continue the corresponding process based on the saved state information in the event of task interruption or user-added information return, thereby improving the execution stability, state consistency and process continuity of medical multi-agent collaborative tasks, has become an urgent technical problem to be solved. Summary of the Invention

[0005] To address the aforementioned problems and difficulties in existing technologies, this invention proposes a method and system for runtime state management and process recovery of multi-agent workflows in medical interactive task scenarios.

[0006] This invention addresses multi-agent collaborative workflow scenarios in medical interactive tasks, constructing a predefined workflow that includes domain intent recognition nodes, interactive consultation nodes, expert collaboration nodes, tool invocation nodes, and result output nodes. During the execution of this predefined workflow, user information status, expert collaboration execution status, tool execution status, supplementary information request status, and workflow control status are uniformly abstracted into runtime state objects, which characterize the execution progress, waiting status, intermediate results, and process recovery position of the medical interactive task in the current round.

[0007] During runtime state management, the system updates the corresponding runtime state based on the execution results of each node to uniformly record the execution progress, waiting status, and intermediate processing results of medical interaction tasks. When the workflow is paused due to waiting for user supplementary information, or when the current medical interaction task is completed, the system saves the current runtime state object to provide a state basis for subsequent process resumption.

[0008] During the process recovery, when supplementary information from the user is received or the recovery conditions are met, the system loads the saved runtime state object and determines the process recovery position based on the workflow control state in the runtime state object, and continues to execute the corresponding workflow node, thereby avoiding repeated consultations, repeated tool calls or loss of context information, and realizing the continuous execution of medical multi-agent workflow.

[0009] This invention provides a method for runtime state management and process recovery of multi-agent workflows in medical interactive task scenarios, comprising the following steps: S1: Load a predefined medical multi-agent workflow, including a domain intent recognition node, an interactive consultation node, an expert collaboration node, a tool invocation node, and a result output node.

[0010] S2: Receive user requests and determine workflow entry points; receive user interaction requests, obtain user identifiers, session identifiers, and user input content; query historical runtime state objects based on the user identifiers and session identifiers, and determine whether the historical runtime state objects meet the process recovery conditions; when no historical runtime state object meets the process recovery conditions, create and initialize a runtime state object, update the runtime state object based on the current user input, and proceed to the domain intent recognition node; when a historical runtime state object meets the process recovery conditions, load the historical runtime state object and execute process recovery; including the following steps: S2-1: Receive user interaction requests and obtain user identifier, session identifier and user input content; S2-2: Query the historical runtime state object based on the user identifier and session identifier, and determine whether the historical runtime state object meets the process recovery conditions; S2-3: When there is no historical runtime state object that meets the process recovery conditions, create and initialize the runtime state object, update the runtime state object according to the current user input, and proceed to step S3; S2-4: When a historical runtime state object that meets the process recovery conditions exists, load the historical runtime state object and proceed to step S8.

[0011] S3: Determine the current task type based on the domain intent recognition node, and perform workflow splitting according to the task type; S3-1: Enter the domain intent recognition node and update the current execution node; S3-2: Invoke the domain intent recognition module to determine the current task type; S3-3: When the task type is non-medical general question and answer processing, proceed to step S7; S3-4: When the task type is medical problem handling, proceed to step S4.

[0012] S4: Based on the interactive consultation node, perform consultation information collection and status update, determine whether the preset consultation end conditions are met based on the acquired user information, and update the user information status and supplementary information request status when the user needs to supplement information, save the runtime state object and pause the current workflow execution; including the following steps: S4-1: Enter the interactive consultation node and update the currently executing node; S4-2: When there is no request for supplementary information to be responded to initiated by the interactive consultation node, determine whether the preset consultation completion conditions are met based on the obtained user information; S4-3: When the preset consultation completion conditions are met, update the user information status, reset the entry node to empty, and proceed to step S5; S4-4: When the preset consultation completion conditions are not met, generate consultation questions based on the currently acquired user information and return them, update the user information status and supplementary information request status, set the recovery entry node as the interactive consultation node, save the runtime state object and pause the workflow; S4-5: When there is a request for supplementary information to be responded to initiated by the interactive consultation node, determine whether the current user input is supplementary information in response to the request for supplementary information; S4-6: When the current user inputs supplementary information, update the user information status and the corresponding supplementary information request status, and return to step S4-2; S4-7: When the current user input is not supplementary information, close the corresponding supplementary information request, end the recovery process of the current interactive consultation task, and transfer the current user input as a new interactive request to step S3; S5: Based on expert collaboration nodes, build or restore expert agent teams, handle supplementary information requests or tool call requests generated during the analysis process of each expert agent, generate the final expert response for each expert agent, and maintain the corresponding expert collaboration execution status for each expert agent. S5-1: Enter the expert collaboration node and update the current execution node; S5-2: Based on the current medical problem and runtime state object, determine whether an expert intelligent agent team and its expert collaborative execution state already exist; if they already exist, load the expert intelligent agent team and its expert collaborative execution state; if they do not exist, form an expert intelligent agent team based on the current medical problem and the acquired user information, and initialize the expert collaborative execution state corresponding to each expert intelligent agent. S5-3: When there is a request for supplementary information to be responded to initiated by an expert collaboration node, determine whether the current user input is supplementary information in response to the supplementary information request; when the current user input is supplementary information, update the user information status, the supplementary information request status and the corresponding expert collaboration execution status; when the current user input is not supplementary information, end the recovery processing of the current medical interaction task and process the current user input as a new interaction request. S5-4: Invoke the expert agent to be executed, or resume the expert task corresponding to the expert agent that has not yet completed processing, and analyze the current medical problem respectively; when the expert analysis process needs to obtain supplementary information from the user or call external tools, generate the corresponding supplementary information request or tool call request, and update the corresponding expert collaborative execution status; S5-5: When the expert agent generates a supplementary information request, update the expert collaborative execution state and the supplementary information request state, set the recovery entry node to the expert collaborative node, return the supplementary information request, save the runtime state object and pause the workflow. S5-6: When the expert agent generation tool is invoked, create the corresponding tool execution state, update the corresponding expert collaborative execution state, and proceed to step S6; S5-7: When the user supplementary information and tool execution results required by the expert agent have been obtained, or when the expert agent does not need to obtain user supplementary information and call external tools, continue to execute the analysis task corresponding to the expert agent, generate the final expert reply, save the final expert reply, and update the corresponding expert collaborative execution status to completed. S5-8: When all expert agents in the expert agent team have generated their final expert responses, proceed to step S7.

[0013] S6: When the expert agent generates a tool call request, it executes the tool call based on the tool call node, and maintains the tool execution status and tool execution result according to the tool call result; S6-1: Enter the tool invocation node and update the currently executing node; S6-2: Determine the tool to be invoked and its input parameters based on the tool invocation request; S6-3: Invoke the corresponding tool and update the tool execution status; S6-4: Based on the tool call result, save the tool execution result or tool exception information, and update the corresponding tool execution status; S6-5: Return the tool execution result or tool exception information to the expert agent that initiated the tool call request, update the corresponding expert collaborative execution status, and proceed to step S5.

[0014] S7: Summarize workflow processing results based on result output nodes, generate and output interaction results; when the current task type is non-medical general question and answer processing, generate general question and answer results based on the current user input; when the current task type is medical question processing, generate medical interaction results based on the current medical question, the acquired user information, and the final expert responses from each expert agent; specifically including the following steps: S7-1: Enter the result output node and update the currently executing node; S7-2: Generate interactive results based on the current task type and user input; when the current task type is non-medical general question and answer processing, generate general question and answer results based on the current user input; when the current task type is medical question processing, generate medical interactive results based on the current medical question, the acquired user information, and the final expert responses from each expert agent. S7-3: Return the interaction result, set the recovery entry node to null, update and save the runtime state object, and end the current interaction task.

[0015] S8: Restore the medical multi-agent workflow based on the loaded historical runtime state object; determine the workflow node to be restored according to the restoration entry node recorded in the historical runtime state object, and pass the current user request and the historical runtime state object to the corresponding processing step to continue execution.

[0016] Preferably, the multi-agent workflow interacts with the user through a front-end interactive terminal, which is used to receive user requests, display user requests for supplementary information, and return interaction results.

[0017] Preferably, the runtime state object includes user information state, expert collaborative execution state, tool execution state, supplementary information request state, and workflow control state.

[0018] Preferably, the user information status is used to record user-related information obtained during the execution of medical interaction tasks, including user input records and acquired user information; wherein, the user input records include user input content and user-uploaded materials, and the acquired user information includes at least one of the following extracted from the user input content or user-uploaded materials: symptom information, medical history information, medication information, examination information, and medical image information.

[0019] Preferably, the expert collaborative execution status is used to record the execution status of each expert agent, including expert agent identifier, expert execution status, expert input information, expert output results, associated supplementary information request identifier, and associated tool call identifier; wherein, the expert execution status includes pending execution status, executing status, paused status, and completed status.

[0020] Preferably, the tool execution status is used to record the execution status during the tool invocation process, including tool invocation record identifier, tool identifier, tool invocation parameters, tool execution status, tool execution result, and tool exception information; wherein, the tool execution status includes pending invocation status, in-process execution status, successful invocation status, and failed invocation status.

[0021] Preferably, the supplementary information request status is used to record user supplementary information requests initiated by interactive consultation nodes or expert collaboration nodes, including request identifier, request source node, request initiator identifier, request information type, request content, request response status, and user response content reference; wherein, the request response status includes pending response status, responded status, and closed status.

[0022] Preferably, the workflow control status is used to record the process control information of the medical multi-agent workflow, including the current execution node and the recovery entry node; wherein, the current execution node is used to record the workflow node that is currently being executed by the medical multi-agent workflow, and the recovery entry node is used to record the workflow node that needs to be continued after the medical multi-agent workflow is paused due to waiting for user supplementary information.

[0023] Preferably, in S2-2, when a historical runtime state object corresponding to the user identifier and session identifier is found and its recovery entry node is not empty, the historical runtime state object is determined to be a historical runtime state object that meets the process recovery conditions; otherwise, it is determined that there is no historical runtime state object that meets the process recovery conditions.

[0024] Preferably, the domain intent recognition module in S3-2 is implemented based on a large language model. By inputting the current user input content and the historical input records in the user information status into the large language model, it is determined whether the corresponding task type is medical problem processing.

[0025] Preferably, the preset consultation termination conditions in S4-2 include at least one of the following: the acquired user information covers the current preset required information items; the consultation module determines, based on the current medical problem and the acquired user information, that there is no key information that needs to be asked of the user again; the current consultation round reaches the preset maximum consultation round.

[0026] Preferably, in S4-4, the consultation module determines the supplementary information that has not yet been obtained and is related to the current medical problem based on the current medical problem, the user information already obtained, and the preset consultation information requirements, and generates the corresponding consultation question based on the supplementary information.

[0027] Preferably, in steps S4-5, the current user input, the request content of the supplementary information request to be responded to, and the request information type are input into the large language model, and the large language model is used to determine whether the current user input is supplementary information in response to the supplementary information request to be responded to.

[0028] Preferably, in S4-7, when the current user input is not supplementary information, the request response status of the corresponding supplementary information request is updated to closed, the recovery entry node in the current runtime state object is set to null and saved; the runtime state object is reinitialized for the current user input, and domain intent recognition is performed.

[0029] Preferably, in S4, a preset maximum number of consultation rounds is set, and the number of consultation rounds during the interactive consultation process is statistically analyzed; the consultation module generates a consultation question and receives supplementary information from the user regarding the consultation question as a consultation round; when the current consultation round reaches the preset maximum number of consultation rounds, even if the user information obtained has not yet covered all the preset required information items, the generation of new consultation questions is stopped, and the process is transferred to the expert collaboration node based on the currently obtained user information.

[0030] Preferably, the expert intelligent agent team formed in step S5 is divided according to medical specialties or disease fields, including one or more of the following: health management expert intelligent agents, specialist diagnosis and treatment expert intelligent agents, and disease management expert intelligent agents.

[0031] Preferably, in step S5, an expert agent team is formed or restored based on the current medical problem and runtime state object, and the expert collaboration execution state corresponding to each expert agent is maintained; during the process of calling an expert agent to be executed or restoring the expert task corresponding to an expert agent that has not yet been processed, when an expert agent generates a user supplementary information request, the supplementary information request state is updated, the restoration entry node is set to the expert collaboration node, the user supplementary information request is returned, the runtime state object is saved, and the current workflow execution is paused; when an expert agent generates a tool call request, the corresponding tool execution state is created and the process is transferred to the tool call node; after the user supplementary information, tool execution result, or tool exception information required by the expert agent has been obtained, or when the expert agent does not need to obtain user supplementary information or call external tools, the expert task of the corresponding expert agent continues to be executed, the final expert reply is generated, and the process is transferred to the result output node after all expert agents have generated the final expert reply.

[0032] Preferably, in S5-2, when entering the expert collaboration node for the first time, an expert intelligent agent team is formed and the expert collaboration execution state corresponding to each expert intelligent agent is initialized; when entering the expert collaboration node again based on the historical runtime state object, the saved expert intelligent agent team and expert collaboration execution state are loaded, the expert intelligent agents that have not yet completed processing are identified, and the corresponding expert tasks are continued to be executed.

[0033] Preferably, the preset set of expert agents in S5-2 is configured according to medical specialties, disease areas, or medical task types, including one or more of the following: health management expert agents, specialist diagnosis and treatment expert agents, and disease management expert agents.

[0034] Preferably, in S5-3, each expert agent is implemented based on a large language model, and its scope of responsibility, processing requirements and output format are configured by prompt words corresponding to each expert agent, so that different expert agents can analyze the current medical problem from their respective professional fields.

[0035] Preferably, in S5-3, the intermediate requests generated by the expert agent during the analysis process include at least one of supplementary information requests and tool call requests; when there is a supplementary information request, the supplementary information request is processed first; when there is no supplementary information request but there is a tool call request, the tool call request is processed; when there are no pending supplementary information requests and tool call requests, the expert analysis continues based on the current medical problem, the acquired user information, and the obtained tool execution results, and a final expert response is generated.

[0036] Preferably, in S5-4, the supplementary information request is uniquely identified by the supplementary information request identifier, the workflow node that initiates the supplementary information request is determined by the request source node, and the expert agent that initiates the supplementary information request is determined by the request initiating object identifier, so as to establish the association between the supplementary information request and the corresponding workflow node and expert agent.

[0037] Preferably, in S5-5, the tool call is uniquely identified by the tool call record and the associated tool call record in the expert collaborative execution state is used to establish the association between the tool call and the expert agent that initiated the tool call request.

[0038] Preferably, in S5, when there is no prior dependency between the expert agents, the corresponding expert agents are called in parallel to generate the corresponding expert processing results; when there is a prior dependency between the expert agents, the corresponding expert agents are called in sequence according to the prior dependency; after generating the final expert response, each expert agent updates the corresponding expert collaborative execution status to completed.

[0039] Preferably, the tools mentioned in S6 include one or more of the following: medical knowledge retrieval tools, medical image analysis tools, test indicator analysis tools, and report parsing tools; different expert agents can be associated with different tool sets and generate corresponding tool call requests based on the current medical problem and the expert collaborative execution status.

[0040] Preferably, in step S6, the corresponding tool execution status is updated according to the tool call result; when the tool call is successful, the tool execution status is updated to the call success status and the tool execution result is saved; when the tool call fails, the tool execution status is updated to the call failure status and the tool exception information is saved; the tool execution result or tool exception information is returned to the expert agent that initiated the tool call request.

[0041] Preferably, in S7-2, when the current task type is non-medical general question-and-answer processing, the current user input is input into the large language model, and a general question-and-answer result is generated through the large language model; when the current task type is medical question processing, the current user input, the acquired user information, and the final expert responses of each expert agent are input into the large language model, and the final expert responses of each expert agent are summarized through the large language model to generate a medical interaction result for the current user's question.

[0042] Preferably, in S7-3, by setting the recovery entry node in the runtime state object to null, it is indicated that the current medical interaction task has been completed, so as to avoid the runtime state object being identified again as a historical runtime state object that meets the process recovery conditions.

[0043] This invention also provides a runtime state management and process recovery system for multi-agent workflows in medical interactive task scenarios, comprising: The workflow management module is used to load predefined medical multi-agent workflows and maintain the execution relationships between workflow nodes. The predefined medical multi-agent workflows include domain intent recognition nodes, interactive consultation nodes, expert collaboration nodes, tool invocation nodes, and result output nodes.

[0044] The status management module is used to query historical runtime status objects based on user identifiers and session identifiers in medical interaction requests, determine whether the historical runtime status objects meet the process recovery conditions, and create, initialize, load, store, and update runtime status objects. The runtime status objects include user information status, expert collaborative execution status, tool execution status, supplementary information request status, and workflow control status.

[0045] The intent recognition and node routing module is used to determine the current task type based on user input when there is no historical runtime state object that meets the process recovery conditions, and to pass the medical interaction request to the corresponding workflow node according to the task type; when the task type is medical problem processing, the medical interaction request is passed to the interactive consultation node; when the task type is non-medical general question and answer processing, the medical interaction request is passed to the result output node.

[0046] The consultation interaction module is used to execute the consultation processing tasks corresponding to the consultation node, determine whether the preset consultation completion conditions are met based on the acquired user information; when the preset consultation completion conditions are not met, determine the user information to be supplemented, generate the corresponding consultation questions and return them to the front end, and update the user information status and supplementary information request status according to the user input; when the preset consultation completion conditions are met, the medical interaction task is passed to the expert collaboration node.

[0047] The expert collaboration module is used to assemble an expert agent team based on the current medical problem, or to load a saved expert agent team and its expert collaboration execution state when resuming execution based on historical runtime state objects. It schedules multiple expert agents to analyze the current medical problem and maintains the expert collaboration execution state corresponding to each expert agent. When an expert agent needs to obtain supplementary information from the user or call external tools during the analysis process, it generates a corresponding supplementary information request or tool call request, and continues to execute the corresponding expert task after the supplementary information request or tool call request is processed. After each expert agent completes its analysis, it generates the corresponding final expert response.

[0048] The tool invocation module is used to receive tool invocation requests generated by expert agents, invoke the corresponding tools to perform processing tasks, maintain the tool execution status, and return the tool execution results or tool exception information to the expert agent that initiated the tool invocation request.

[0049] The result output module is used to generate corresponding interaction results according to the current task type. When the current task type is non-medical general question and answer processing, it generates general question and answer results based on the current user input. When the current task type is medical question processing, it generates medical interaction results based on the current user input, the acquired user information, and the final expert replies from each expert agent, and returns the interaction results.

[0050] The state recovery module is used to determine the workflow node to be recovered based on the recovery entry node recorded in the historical runtime state object when there is a historical runtime state object that meets the process recovery conditions, and to pass the current interaction request and the historical runtime state object to the corresponding workflow node to continue execution.

[0051] The present invention also relates to a computer-readable storage medium having a program stored thereon, which, when executed by a processor, implements the method of the present invention.

[0052] The innovation of this invention is: (1) A runtime state modeling mechanism for multi-agent workflows oriented towards medical interactive tasks is proposed. User information state, expert collaborative execution state, tool execution state, supplementary information request state, and workflow control state are uniformly organized into runtime state objects to record the execution progress, intermediate results, waiting requests, and process recovery positions of the medical multi-agent workflow in a structured manner.

[0053] (2) A process recovery mechanism based on a recovery entry node is proposed. When the medical multi-agent workflow is paused due to waiting for user supplementary information or interruption of user interaction, a corresponding recovery entry node is set and the runtime state object is saved; when a subsequent request arrives, the workflow node to be recovered is determined according to the recovery entry node, and the corresponding process continues to be executed.

[0054] (3) A fine-grained state maintenance mechanism for multi-expert analysis process is proposed. The collaborative execution state of each expert agent is maintained separately, and the expert agent is associated with the supplementary information request identifier and the tool call record identifier by association. This enables the system to continue to execute the analysis task of the corresponding expert agent after the supplementary information or tool execution result is returned, without having to repeat the completed expert task.

[0055] The present invention has the following advantages: (1) It can improve the continuous execution capability of medical multi-agent workflow and reduce repeated consultations and repeated executions when the user interrupts the interaction or re-enters the session and supplements the information.

[0056] (2) It can improve the state consistency in the multi-agent collaboration process and reduce the context confusion caused by the asynchronous state of user information, expert execution state or tool call state.

[0057] (3) It can enhance the system's scalability. Different expert agents and tools can access and collaborate under a unified runtime state mechanism, which is suitable for complex medical interaction scenarios such as multi-round consultations, multi-department collaboration, and external tool calls. Attached Figure Description

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

[0059] Figure 1 This is the overall flowchart of the method of the present invention.

[0060] Figure 2 This is a structural diagram of the system of the present invention. Detailed Implementation

[0061] Exemplary embodiments of this disclosure will now be described in more detail with reference to the accompanying drawings. The technical solutions in the embodiments of the present invention will be clearly and completely described below. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art based on the present invention are within the scope of protection of the present invention.

[0062] Example 1

[0063] like Figure 1 As shown, the present invention provides a method for runtime state maintenance and process recovery of multi-agent workflow in medical interactive task scenarios, including steps S1-S8.

[0064] S1: Load a predefined medical multi-agent workflow, including a domain intent recognition node, an interactive consultation node, an expert collaboration node, a tool invocation node, and a result output node; S2: Receive frontend requests and determine the workflow entry point.

[0065] S2-1: Receive front-end medical interaction requests and obtain user identifier, session identifier and user input content; S2-2: Query the historical runtime status based on the user identifier and session identifier; wherein, the runtime status object includes user information status, expert collaborative execution status, tool execution status, supplementary information request status, and workflow control status, and the workflow control status includes the current execution node and the recovery entry node; if the recovery entry node in the historical runtime status object is not empty, then the historical runtime status object is determined as a historical runtime status object that meets the process recovery conditions; S2-3: When there is no recoverable historical runtime state object, create a runtime state object, initialize the user information state, expert collaborative execution state, tool execution state, supplementary information request state and workflow control state, update the runtime state object according to the current user input, and proceed to step S3; S2-4: When a recoverable historical runtime state object exists, load the historical runtime state object and proceed to step S8.

[0066] S3: Determine the current task type based on the domain intent recognition node, and perform workflow splitting according to the task type; S3-1: Enter the domain intent recognition node and update the current execution node in the workflow control state to the domain intent recognition node; S3-2: Call the domain intent recognition module to determine the current task type; S3-3: When the task type is non-medical general question and answer processing, proceed to step S7; S3-4: When the task type is medical problem handling, proceed to step S4; S4: Perform consultation information collection and status updates based on the interactive consultation node; S4-1: Enter the interactive consultation node, update the current execution node in the workflow control state to the interactive consultation node, and read the user information status and supplementary information request status in the runtime state object; S4-2: When there is no request for supplementary information to be responded to initiated by the interactive consultation node, based on the user information already obtained in the user information status, determine whether at least one of the following consultation termination conditions is met: the obtained user information covers the current preset required information items; the consultation module determines, based on the current medical problem and the obtained user information, that there is no key information that needs to be asked of the user again; the maximum consultation round is reached.

[0067] S4-3: When the preset consultation completion conditions are met, update the user information status, set the consultation completion flag in the user information status to completed, set the recovery entry node to empty, and proceed to step S5. S4-4: When the preset consultation completion conditions are not met, the consultation module is invoked to determine the information to be supplemented based on the currently collected user information, and the corresponding consultation question is generated and returned to the front end; the consultation round in the user information status is updated, a supplementary information request initiated by the interactive consultation node is created, the request content of the supplementary information request is set to the consultation question, the request response status is set to pending response, the recovery entry node in the workflow control status is set to the interactive consultation node, the current runtime state object is saved, and the current workflow execution is paused to wait for user input; S4-5: When there is a request for supplementary information to be responded to initiated by the interactive consultation node, the consultation intent recognition module is called to determine whether the current user input is supplementary information in response to the request for supplementary information to be responded to. S4-6: When the current user input is supplementary information, write the current user input into the user input record, write the information extracted from the current user input into the acquired user information, set the request response status of the corresponding supplementary information request to be responded, return to step S4-2, and re-determine whether the preset consultation completion conditions are met based on the updated user information. S4-7: When the current user input is not supplementary information, determine that the current user input will not continue the current interactive consultation process, set the request response status of the corresponding supplementary information request to closed, clear the recovery entry node and save the current runtime state object; reinitialize the runtime state object for the current user input, and go to step S3 to redetermine the task type corresponding to the current user input; S5: Based on expert collaboration nodes, build or restore expert intelligent agent teams, call each expert intelligent agent to analyze the current medical problem, process supplementary information requests or tool call requests generated during the analysis process, and generate the final expert response corresponding to each expert intelligent agent; S5-1: Enter the expert collaboration node and update the current execution node in the workflow control state to the expert collaboration node; S5-2: When the expert agent team and its expert collaborative execution status are recorded in the runtime state object, load the expert agent team and its corresponding expert collaborative execution status; when the expert agent team is not recorded in the runtime state object, determine the expert agents participating in the analysis of the current medical problem based on the acquired user information in the current medical problem and user information status, form an expert agent team, create a corresponding expert collaborative execution status for each expert agent, initialize the expert execution status to the pending execution status, and write the expert agent team and its expert collaborative execution status into the runtime state object; S5-3: When there is a request for supplementary information to be responded to initiated by an expert collaboration node, determine whether the current user input is supplementary information in response to the supplementary information request; when the current user input is supplementary information, update the user information status, the supplementary information request status and the corresponding expert collaboration execution status; when the current user input is not supplementary information, end the recovery processing of the current medical interaction task and process the current user input as a new interaction request. S5-4: Invoke the expert agent to be executed, or resume the expert task corresponding to the expert agent that has not yet completed processing, and analyze the current medical problem respectively; when the expert analysis process needs to obtain supplementary information from the user or call external tools, generate the corresponding supplementary information request or tool call request, and update the corresponding expert collaborative execution status; S5-5: When an expert agent generates a supplementary information request, a corresponding supplementary information request record is created. The request initiator identifier in the supplementary information request record is set to the corresponding expert agent identifier, the request source node is set to the expert collaboration node, and the request content is set to the user information requested by the expert agent. The request response status is set to pending response. The expert execution status of the corresponding expert agent is set to paused, the associated supplementary information request identifier is recorded, and the recovery entry node in the workflow control status is set to the expert collaboration node. The supplementary information request is returned to the front end, the current runtime state object is saved, and the current workflow execution is paused to wait for user input. S5-6: When the expert agent generates a tool call request, create a corresponding tool execution state according to the tool call request, set the tool execution state to be called; set the expert execution state of the corresponding expert agent to paused, record the associated tool call identifier, and proceed to step S6; S5-7: When the user supplementary information and tool execution results required by the expert agent have been obtained, or when the expert agent does not need to obtain user supplementary information and call external tools, continue to execute the analysis task corresponding to the expert agent, generate the final expert reply, save the expert reply result to the corresponding expert collaborative execution status, and update the corresponding expert collaborative execution status to completed. S5-8: When all expert agents in the expert agent team are in the completed state, proceed to step S7.

[0068] S6: Execute tool calls based on tool call nodes and update relevant statuses according to tool execution results; S6-1: Enter the tool invocation node and update the current execution node in the workflow control state to the tool invocation node; S6-2: Determine the tool to be invoked and its input parameters based on the tool invocation request generated by the expert agent; S6-3: Invoke the corresponding tool and set the tool's execution status to "in execution". S6-4: Obtain the tool call result and update the corresponding tool execution status according to the tool call result; when the tool call is successful, set the tool execution status to successful call and save the tool execution result; when the tool call fails, set the tool execution status to failed call and save the tool exception information. S6-5: Determine the expert agent that initiated the tool call request based on the associated tool call identifier, provide the tool execution result or tool exception information to the corresponding expert agent, set the expert execution status of the corresponding expert agent to "in execution", and proceed to step S5.

[0069] S7: Summarize the processing results of the medical multi-agent workflow based on the result output node, generate and output the interaction results; S7-1: Enter the result output node and update the current execution node in the workflow control state to the result output node; S7-2: Generate interaction results based on the current task type; when the current task type is non-medical general question and answer processing, generate general question and answer results based on the current user input; when the current task type is medical question processing, generate medical interaction results based on the current medical question, the acquired user information, and the final expert responses from each expert agent. S7-3: Return the interaction result to the front end, set the recovery entry node in the workflow control state to null, save the updated runtime state object, and end the current interaction task.

[0070] S8: Restore the medical multi-agent workflow based on the loaded historical runtime state object; read the workflow control state in the historical runtime state object, determine the workflow node to be restored according to the recovery entry node recorded in the workflow control state, and pass the current front-end request and the historical runtime state object to the corresponding processing step to continue execution.

[0071] Example 2

[0072] The invention will be further explained below in the context of traditional Chinese medicine health consultation.

[0073] A user submitted a consultation request to the medical interactive system: "I've been experiencing frequent insomnia, dry mouth, and fatigue lately. What could be the cause?"

[0074] The system first performs domain intent recognition processing to determine that the current task belongs to medical and health consultation, and then enters the interactive consultation process.

[0075] The intelligent consultation agent generates initial consultation questions based on the user's current input, such as inquiring about symptom duration, sleep patterns, dietary habits, past medical history, and recent physical examination results. After the user provides additional information, the system continuously updates the user information status in the runtime state object and generates subsequent consultation questions based on the current consultation results. After multiple rounds of consultation, the system obtains information on the user's symptom presentation, duration, and related lifestyle habits, and determines that the preset consultation completion conditions have been met. Therefore, the interactive consultation process ends, and the process enters the expert collaboration phase.

[0076] An expert intelligent agent team is formed based on the current user information. In this embodiment, the expert intelligent agent team includes a traditional Chinese medicine health expert intelligent agent and a nutrition management expert intelligent agent. The traditional Chinese medicine health expert intelligent agent, after analyzing the current user information, determines that further diagnostic analysis is difficult to complete based solely on the existing text information; therefore, it generates a request for supplementary information from the user, requesting the user to upload a tongue diagnosis image.

[0077] Upon receiving the supplementary information request, the system sets the corresponding expert collaboration execution status to a paused state and updates the supplementary information request status in the runtime status object. The supplementary information request status includes the identifier of the requesting agent, the type of request information, and the request content.

[0078] Subsequently, the system restores the entry node to the expert collaboration node and saves the current runtime state object. The runtime state object includes user information status, expert collaboration execution status, tool execution status, supplementary information request status, and workflow control status. After saving, the system pauses the current workflow execution and waits for the user to provide supplementary information.

[0079] In this embodiment, the user temporarily leaves the system after receiving the request to upload a tongue diagnosis image, at which point the current medical interaction task is paused.

[0080] After a period of time, the user re-enters the system and uploads a tongue diagnosis image. The system detects a historical runtime state for the corresponding session, eliminating the need to re-execute the domain intent recognition and interactive consultation process. It only needs to read the most recent runtime state object and restore it. Based on the restored entry node, the system resumes execution at the expert collaboration node. The TCM health expert agent receives the uploaded tongue diagnosis image and generates an image analysis tool invocation request. The system invokes the tongue diagnosis image analysis tool according to the request to analyze the tongue diagnosis image and obtain analysis results such as tongue quality, tongue coating, and tongue appearance characteristics.

[0081] After the tool completes its execution, the system synchronizes the image analysis results to the runtime state object and resumes the TCM health expert agent to continue performing the analysis task. The TCM health expert agent combines user text information and tongue diagnosis analysis results to complete the syndrome differentiation analysis and generate corresponding expert analysis results.

[0082] Once all expert agents have completed their analysis tasks, the system enters the results output node, summarizes the expert analysis results, and returns the final medical interaction results to the user.

[0083] Example 3

[0084] like Figure 2 As shown, the present invention also provides a runtime state management and process recovery system for multi-agent workflows in medical interactive task scenarios.

[0085] The system includes a workflow management module, a status management module, an intent recognition and node routing module, a consultation interaction module, an expert collaboration module, a tool invocation module, a result output module, and a status recovery module.

[0086] The workflow management module is used to load predefined medical multi-agent workflows and maintain the execution relationships between workflow nodes. The predefined medical multi-agent workflow includes a domain intent recognition node, an interactive consultation node, an expert collaboration node, a tool invocation node, and a result output node.

[0087] The state management module is used to query historical runtime state objects based on user identifiers and session identifiers in front-end medical interaction requests, determine whether the historical runtime state objects meet the process recovery conditions, and create, initialize, load, store, and update runtime state objects. The runtime state objects include user information state, expert collaboration execution state, tool execution state, supplementary information request state, and workflow control state. The workflow control state includes the current execution node and the recovery entry node.

[0088] The intent recognition and node routing module is used to determine the current task type based on user input when no historical runtime state object that meets the process recovery conditions exists, and to pass the medical interaction request to the corresponding workflow node according to the task type. When the task type is medical problem processing, the medical interaction request is passed to the interactive consultation node; when the task type is non-medical general question and answer processing, the medical interaction request is passed to the result output node.

[0089] The consultation interaction module is used to execute the consultation processing tasks corresponding to the interactive consultation nodes. It determines whether the preset consultation completion conditions are met based on the acquired user information in the user information status. When the preset consultation completion conditions are not met, it determines the information to be supplemented based on the currently acquired user information, generates the corresponding consultation question and returns it to the front end, and updates the user information status and supplementary information request status according to user input. When the preset consultation completion conditions are met, the medical interaction task is passed to the expert collaboration module.

[0090] The expert collaboration module is used to assemble an expert agent team based on the current medical problem, or to load a saved expert agent team and its expert collaboration execution state when resuming execution based on historical runtime state objects, to schedule multiple expert agents to analyze the current medical problem, and to maintain the expert collaboration execution state corresponding to each expert agent; when an expert agent needs to obtain supplementary information from the user or call external tools during the analysis process, it generates a corresponding supplementary information request or tool call request, and continues to execute the corresponding expert task after the supplementary information request or tool call request is processed; after each expert agent completes the analysis, it generates the corresponding final expert response.

[0091] The tool invocation module is used to determine the tool to be invoked and its input parameters based on the tool invocation request generated by the expert agent, invoke the corresponding tool to execute the processing task, and maintain the corresponding tool execution status. When the tool invocation is completed, the tool execution result or tool exception information is saved to the tool execution status and returned to the expert agent that initiated the tool invocation request to continue executing the corresponding expert collaborative processing task.

[0092] The result output module is used to generate corresponding interaction results according to the current task type; when the current task type is non-medical general question and answer processing, it generates general question and answer results based on the current user input content; when the current task type is medical question processing, it generates medical interaction results based on the current user input content, the acquired user information and the final expert replies of each expert agent, and returns the interaction results.

[0093] The state recovery module is used to determine the workflow node to be recovered based on the recovery entry node recorded in the workflow control state of the historical runtime state object when there is a historical runtime state object that meets the process recovery conditions, and to pass the current front-end medical interaction request and the historical runtime state object to the corresponding workflow node to continue executing the medical multi-agent workflow.

[0094] Example 4

[0095] The present invention also relates to a computer-readable storage medium having a program stored thereon that, when executed by a processor, implements the method of embodiment 1.

[0096] The embodiments described in this specification are merely examples of implementations of the inventive concept. The scope of protection of this invention should not be considered as limited to the specific forms stated in the embodiments. The scope of protection of this invention also extends to equivalent technical means that can be conceived by those skilled in the art based on the inventive concept.

Claims

1. A method for runtime state management and process recovery of multi-agent workflow in medical interactive task scenarios, characterized in that, Includes the following steps: S1: Load a predefined medical multi-agent workflow, which includes a domain intent recognition node, an interactive consultation node, an expert collaboration node, a tool invocation node, and a result output node; S2: Receive user interaction requests and determine workflow entry points; obtain user identifier, session identifier, and user input content; query historical runtime state objects based on the user identifier and session identifier; and determine whether the historical runtime state objects meet the process recovery conditions. If no historical runtime state object meets the process recovery conditions, create and initialize a runtime state object; update the runtime state object based on the current user input; and proceed to the domain intent recognition node. If a historical runtime state object meets the process recovery conditions, load the historical runtime state object and execute process recovery. S3: Call the domain intent recognition module to determine the current task type, and determine the corresponding workflow node based on the task type; S4: Based on the interactive consultation node, perform consultation information collection and status update, determine whether the preset consultation end conditions are met based on the acquired user information, update the user information status and supplementary information request status when the user needs to supplement information, save the runtime state object and pause the execution of the current workflow; S5: Based on expert collaboration nodes, an expert agent team is formed to handle supplementary information requests or tool call requests generated during the analysis process of each expert agent, generate the final expert response for each expert agent, and maintain the corresponding expert collaboration execution status for each expert agent. S6: When the expert agent generates a tool invocation request, it invokes the corresponding tool based on the tool invocation node, and maintains the tool execution status and tool execution result according to the tool invocation result; S7: Summarize workflow processing results based on result output nodes, generate and output interaction results; when the current task type is non-medical general question and answer processing, generate general question and answer results based on the current user input; when the current task type is medical question processing, generate medical interaction results based on the current medical question, the acquired user information and the final expert replies of each expert agent. S8: Restore the medical multi-agent workflow based on the loaded historical runtime state object; determine the workflow node to be restored according to the restoration entry node recorded in the historical runtime state object, and pass the current user request and the historical runtime state object to the corresponding processing step to continue execution.

2. The method according to claim 1, characterized in that, The runtime state object mentioned in step S2 includes user information state, expert collaborative execution state, tool execution state, supplementary information request state, and workflow control state; The user information status is used to record user-related information obtained during the execution of medical interaction tasks, including user input records and acquired user information; wherein, the user input records include user input content and user-uploaded materials, and the acquired user information includes at least one of the following extracted from the user input content or user-uploaded materials: symptom information, medical history information, medication information, examination information, and medical image information; The expert collaborative execution status is used to record the execution status of each expert agent, including expert agent identifier, expert execution status, expert input information, expert output results, associated supplementary information request identifier, and associated tool call identifier; wherein, the expert execution status includes pending execution status, executing status, paused status, and completed status; The tool execution status is used to record the execution status during the tool invocation process, including tool invocation record identifier, tool identifier, tool invocation parameters, tool execution status, tool execution result, and tool exception information; wherein, the tool execution status includes pending invocation status, in-process status, successful invocation status, and failed invocation status; The supplementary information request status is used to record user supplementary information requests initiated by interactive consultation nodes or expert collaboration nodes, including request identifier, request source node, request initiator identifier, request information type, request content, request response status, and user response content reference; wherein, the request response status includes pending response status, responded status, and closed status; The workflow control status is used to record the process control information of the medical multi-agent workflow, including the current execution node and the recovery entry node; wherein, the current execution node is used to record the workflow node that is currently being executed in the medical multi-agent workflow, and the recovery entry node is used to record the workflow node that needs to be continued after the medical multi-agent workflow is paused due to waiting for user supplementary information.

3. The method according to claim 1, characterized in that, In step S4, when there is no request for supplementary information to be responded to initiated by the interactive consultation node, it is determined whether the preset consultation end condition is met based on the user information already obtained in the runtime state object. When the preset consultation end conditions are not met, a consultation question is generated based on the current medical problem and the acquired user information and returned to the front end. The user information status and supplementary information request status are updated. The recovery entry node is set as the interactive consultation node. The runtime state object is saved and the current workflow execution is paused to wait for user input. When the preset consultation end conditions are met, the user information status is updated. The recovery entry node is set to null and the process is transferred to the expert collaboration node. When there is a request for supplementary information initiated by the interactive consultation node, it is determined whether the current user input is supplementary information in response to the request. If the current user input is supplementary information, the user information status and the corresponding supplementary information request status are updated, and the preset consultation termination condition is re-evaluated based on the updated user information. If the current user input is not supplementary information, the corresponding supplementary information request is closed, the recovery process of the current interactive consultation task is terminated, and the current user input is treated as a new interactive request.

4. The method according to claim 3, characterized in that, The preset consultation termination conditions include at least one of the following: the acquired user information covers the preset necessary information items corresponding to the current medical problem; the consultation module determines, based on the current medical problem and the acquired user information, that there is no key information that needs to be asked of the user again; the current consultation round reaches the preset maximum consultation round.

5. The method according to claim 4, characterized in that, In step S4, a preset maximum number of consultation rounds is set, and the number of consultation rounds during the interactive consultation process is counted. The consultation round is defined as the consultation module generating a consultation question and receiving supplementary information from the user regarding the consultation question. When the current consultation round reaches the preset maximum number of consultation rounds, the generation of new consultation questions is stopped, and the user is transferred to the expert collaboration node based on the currently acquired user information.

6. The method according to claim 1, characterized in that, The expert intelligent agent team formed in step S5 is divided according to medical specialties or disease areas, including one or more of the following: health management expert intelligent agents, specialty diagnosis and treatment expert intelligent agents, and disease management expert intelligent agents.

7. The method according to claim 1, characterized in that, In step S5, an expert agent team is formed or restored based on the current medical problem and runtime state object, and the expert collaboration execution state corresponding to each expert agent is maintained. During the process of calling an expert agent to be executed or restoring the expert task corresponding to an expert agent that has not yet been processed, when an expert agent generates a user supplementary information request, the supplementary information request state is updated, the restoration entry node is set to the expert collaboration node, the user supplementary information request is returned, the runtime state object is saved, and the current workflow execution is paused. When an expert agent generates a tool call request, the corresponding tool execution state is created and the process is transferred to the tool call node. After the user supplementary information, tool execution result, or tool exception information required by the expert agent has been obtained, or when the expert agent does not need to obtain user supplementary information or call external tools, the expert task of the corresponding expert agent continues to be executed, the final expert reply is generated, and the process is transferred to the result output node after all expert agents have generated the final expert reply.

8. The method according to claim 1, characterized in that, The tools mentioned in step S6 include one or more of the following: medical knowledge retrieval tools, medical image analysis tools, test indicator analysis tools, and report parsing tools; different expert agents are associated with different sets of tools, and corresponding tool call requests are generated according to the current medical problem and the expert collaborative execution status.

9. The method according to claim 1, characterized in that, In step S6, the corresponding tool execution status is updated according to the tool call result; when the tool call is successful, the tool execution status is updated to the call success status and the tool execution result is saved; when the tool call fails, the tool execution status is updated to the call failure status and the tool exception information is saved; the tool execution result or tool exception information is returned to the expert agent that initiated the tool call request.

10. A runtime state management and process recovery system for multi-agent workflows in medical interactive task scenarios, characterized in that, include: The workflow management module is used to load predefined medical multi-agent workflows and maintain the execution relationships between workflow nodes; The predefined medical multi-agent workflow includes a domain intent recognition node, an interactive consultation node, an expert collaboration node, a tool invocation node, and a result output node. The status management module is used to query historical runtime status objects based on user identifiers and session identifiers in medical interaction requests, determine whether the historical runtime status objects meet the process recovery conditions, and create, initialize, load, store, and update runtime status objects. The runtime status objects include user information status, expert collaborative execution status, tool execution status, supplementary information request status, and workflow control status. The intent recognition and node routing module is used to determine the current task type based on user input when there is no historical runtime state object that meets the process recovery conditions, and to pass the medical interaction request to the corresponding workflow node according to the task type; when the task type is medical problem processing, the medical interaction request is passed to the interactive consultation node; when the task type is non-medical general question and answer processing, the medical interaction request is passed to the result output node. The consultation interaction module is used to execute the consultation processing tasks corresponding to the interactive consultation nodes, and to determine whether the preset consultation completion conditions are met based on the obtained user information. When the preset consultation completion conditions are not met, the user information to be supplemented is determined, the corresponding consultation question is generated and returned to the front end, and the user information status and supplementary information request status are updated according to the user input; when the preset consultation completion conditions are met, the medical interaction task is passed to the expert collaboration node. The expert collaboration module is used to assemble an expert agent team based on the current medical problem, or to load a saved expert agent team and its expert collaboration execution state when resuming execution based on historical runtime state objects. It schedules multiple expert agents to analyze the current medical problem and maintains the expert collaboration execution state for each agent. When an expert agent needs to obtain supplementary information from the user or call external tools during the analysis process, it generates a corresponding supplementary information request or tool call request, and continues to execute the corresponding expert task after the supplementary information request or tool call request is processed. After each expert agent completes its analysis, it generates a corresponding final expert response. The tool invocation module is used to receive tool invocation requests generated by expert agents, invoke the corresponding tools to perform processing tasks, maintain the tool execution status, and return the tool execution results or tool exception information to the expert agent that initiated the tool invocation request. The result output module is used to generate corresponding interaction results according to the current task type. When the current task type is non-medical general question and answer processing, it generates general question and answer results based on the current user input. When the current task type is medical question processing, it generates medical interaction results based on the current user input, the acquired user information, and the final expert replies from each expert agent, and returns the interaction results. The state recovery module is used to determine the workflow node to be recovered based on the recovery entry node recorded in the historical runtime state object when there is a historical runtime state object that meets the process recovery conditions, and to pass the current interaction request and the historical runtime state object to the corresponding workflow node to continue execution.