Intelligent agent scheduling method and electronic device

CN122963741APending Publication Date: 2026-10-23HANGZHOU HIGH-TECH ZONE (BINJIANG) INSTITUTE OF BLOCKCHAIN & DATA SECURITY
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611416753.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-09-11
Publication Date
2026-10-23

AI Technical Summary

Technical Problem

[0005]本申请实施例提供了一种智能体调度方法及电子设备,可以解决现有技术无法合理地选择智能体执行对话任务的问题

Benefits of technology

[0031]第三方面,本申请实施例提供了一种计算机可读存储介质,计算机可读存储介质存储有计算机程序,计算机程序被处理器执行时实现如上述第一方面的方法。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122963741A_ABST
    Figure CN122963741A_ABST
Patent Text Reader

Abstract

Embodiments of the present application are applicable to the field of intelligent agents, and provide an intelligent agent scheduling method and an electronic device. The method comprises: obtaining a first execution cost corresponding to a current round of dialogue task when the dialogue task is executed by a master intelligent agent, and obtaining a first occupancy rate of a preset model context space after the master intelligent agent executes the current round of dialogue task; obtaining a second execution cost corresponding to the current round of dialogue task when the dialogue task is executed by a sub-intelligent agent, and obtaining a second occupancy rate of the model context space after the sub-intelligent agent sends a processing result text to the master intelligent agent; obtaining a task evaluation parameter when the current round of dialogue task is executed; calculating an intelligent agent decision score based on the first execution cost, the second execution cost, the first occupancy rate, the second occupancy rate, and the task evaluation parameter; and determining a target intelligent agent for executing the current round of dialogue task from the master intelligent agent and the sub-intelligent agent based on the intelligent agent decision score. By using the above method, the intelligent agent can be reasonably selected to execute the dialogue task.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application belongs to the field of intelligent agent technology, and in particular relates to an intelligent agent scheduling method and electronic device. Background Technology

[0002] When large language models are used to empower business scenarios such as coding, data analysis, document processing, and automated operation and maintenance, a collaborative architecture of main intelligent agent and sub-intelligent agents is commonly adopted. The main intelligent agent is responsible for user interaction and overall task planning, while the sub-intelligent agents are used to handle sub-tasks.

[0003] In existing agent scheduling methods, task execution subjects are simply divided based on task semantics, or all subtasks are enabled by default to be processed by sub-agents, and the billing overhead of repeated input is reduced based solely on prompt caching mechanisms.

[0004] However, the aforementioned existing technologies lack a unified and quantitative pre-assessment system, and do not separately quantify the comprehensive execution cost corresponding to the main intelligent agent and sub-intelligent agents performing the same task. They cannot determine whether it is more suitable to the overall cost control requirements to have the task executed directly by the main intelligent agent or executed in isolation by the sub-intelligent agents. Summary of the Invention

[0005] This application provides an agent scheduling method and electronic device, which can solve the problem that the prior art cannot reasonably select agents to perform dialogue tasks.

[0006] In a first aspect, embodiments of this application provide an agent scheduling method, the method comprising: For the current dialogue task input by the user, obtain the first execution cost corresponding to the current dialogue task when executed by the main agent, and obtain the first occupancy rate of the preset model context space after the main agent executes the current dialogue task; Obtain the second execution cost corresponding to the current dialogue task when it is executed by the sub-agent, and obtain the second occupancy rate of the model context space after the sub-agent sends the processing result text to the main agent; Obtain the task evaluation parameters during the execution of this round of dialogue tasks; The agent's decision score is calculated based on the first execution cost, the second execution cost, the first occupancy rate, the second occupancy rate, and the task evaluation parameters. Based on the agent's decision-making score, the target agent for performing this round of dialogue is determined from the main agent and sub-agents.

[0007] In the above technical solution, before the execution of this round of dialogue task, the first execution cost corresponding to the main agent executing this round of dialogue task and the first occupancy rate of the model context space after the main agent executes this round of dialogue task are quantitatively calculated. The second execution cost corresponding to the isolated execution of this round of dialogue task by the sub-agent and the second occupancy rate of the model context space after the sub-agent sends the processing result text to the main agent are also calculated. Simultaneously, a quantitative agent decision score is comprehensively calculated by combining task evaluation parameters describing the characteristics of this round of dialogue task execution. Based on this, automated selection of the execution subject can be completed based on a unified quantitative score. Compared with related technologies that rely solely on semantically coarse agent allocation and lack pre-quantitative evaluation, this solution can accurately measure the occupancy rate of the context model context space, various execution cost overheads, and the task's own constraint factors, autonomously determining whether the current round of dialogue task is more suitable for direct execution by the main agent or isolated execution by the sub-agent. Furthermore, it can not only avoid the additional startup and context reconstruction resource consumption caused by blindly activating sub-agents, but also avoid the problems of context model context space crowding and model inference attention dispersion caused by the main agent carrying massive redundant content, thus achieving coordinated optimization scheduling of context storage resources and computing resources.

[0008] In one embodiment, obtaining the first execution cost corresponding to the current round of dialogue task being performed by the main intelligent agent includes: The input cost required to obtain the input content in this round of dialogue task; Predict the scale of dialogue noise generated when the main agent performs the current dialogue task, and the number of interaction rounds the main agent will continue to interact after the current dialogue task is completed; The product of input cost, dialogue noise level, and number of interaction rounds is determined as the first execution cost.

[0009] In the above technical solution, the first execution cost is obtained by multiplying three key indicators: the input cost of the input content in this round of dialogue, the scale of dialogue noise generated by the main agent after executing this round of dialogue, and the estimated number of subsequent continuous interaction rounds after the task ends. This approach can simultaneously take into account both the computational cost of a single round of dialogue and the resource consumption accumulated over long-term, multi-round interactions. Furthermore, it can fully quantify the comprehensive resource consumption of the main agent independently undertaking the entire process of this round of dialogue, forming an objective and unified quantitative indicator of computational power. This provides an intuitive horizontal comparison with the second execution cost corresponding to the sub-agent solution, offering reliable data support at the computational power level for subsequent multi-dimensional fusion computational agent decision scoring.

[0010] In one embodiment, obtaining the first occupancy rate of the preset model context space by the main agent after performing the current round of dialogue task includes: Predict the scale of dialogue noise generated when the main agent performs this round of dialogue task; Get the character size of the historical dialogue records stored in the main agent; Calculate the sum of the dialogue noise scale and the character scale to obtain the first storage scale after the main agent processes this round of dialogue task; The ratio of the first storage size to the model context space is determined as the first occupancy rate.

[0011] In the above technical solution, by predicting the scale of dialogue noise generated by the main agent in executing the task in advance, and combining this with the character storage of historical dialogue records currently stored by the main agent, the overall initial storage scale after the current round of dialogue task execution can be accurately calculated. This initial storage scale is then quantified by comparing it with the capacity of the model context space to obtain a standardized initial occupancy rate. Furthermore, this allows for an intuitive and quantitative characterization of the congestion level of the context window after the main agent fully undertakes the current round of task, clearly quantifying the risk of redundant noise crowding out the storage resources of the model context space. This provides an objective and unified quantitative indicator for subsequent horizontal comparison of storage consumption differences between sub-agent execution schemes.

[0012] In one embodiment, obtaining the second execution cost corresponding to the current round of dialogue task being performed by the sub-agent includes: The input cost required to obtain the input content in this round of dialogue task, and the text size of the processed result text; Predict the number of interaction rounds the main agent will continue to interact after the current dialogue task is completed; Based on input cost, text size, and number of interaction rounds, calculate the second execution cost of the sub-agent performing this round of dialogue task.

[0013] In the above technical solution, the second execution cost is calculated based on the input cost, the text size of the processed result text, and the estimated number of interaction rounds. This allows for a complete quantification of the overall computing power consumption generated by the sub-agent in executing the task, considering the input content, output content (processed result text), and subsequent multi-round interactions. Furthermore, the first execution cost corresponding to the main agent forms a horizontally comparable quantitative indicator of computing power, providing an objective and complete computing power reference for comprehensively calculating the agent's decision-making score.

[0014] In one embodiment, the second execution cost of the sub-agent performing the current round of dialogue task is calculated based on input cost, text size, and number of interaction rounds, including: The third execution cost is obtained by multiplying the input cost, text size, and number of interaction rounds. The second execution cost is obtained by adding the third execution cost to the preset isolation cost required for the sub-agent to perform this round of dialogue.

[0015] In the above technical solution, the third execution cost is first calculated by multiplying the input cost, text size, and number of interaction rounds, and then a preset isolation cost is added to obtain the complete second execution cost. This not only covers the computational power consumption of the current dialogue task itself, but also takes into account the fixed overhead generated by the independent operation of the sub-agent. Furthermore, a comprehensive and standardized quantitative result of the computational power of the sub-agent executing the current dialogue task can be generated, providing complete computational power dimension data for calculating the agent's decision-making score.

[0016] In one embodiment, obtaining the second occupancy rate of the model context space after the sub-agent sends the processing result text to the main agent includes: Get the character size of the historical dialogue records stored in the main agent; The sum of the text size and character size of the processed text is calculated to obtain the second storage size that the main agent needs to use when the sub-agent processes this round of dialogue task; The ratio of the second storage size to the model context space is determined as the second occupancy rate.

[0017] In the above technical solution, the second storage size is obtained by superimposing the text size of the processed text onto the character size of the historical dialogue records already stored by the main agent. This second storage size is then calculated by combining it with the model context space capacity to obtain the second occupancy rate. This allows for accurate quantification of the resource consumption of the model context space in the main agent under the sub-agent isolated execution scheme. Furthermore, this provides a quantifiable benchmark for comparison with the first occupancy rate corresponding to the main agent directly processing the current round of dialogue tasks, offering an objective storage dimension evaluation basis for comprehensively calculating the agent's decision score.

[0018] In one embodiment, the input cost required to obtain the input content in the current dialogue task includes: Retrieve the stored historical dialogue records in the main intelligent agent; Predict the cache hit rate of input content matching historical dialogue records; Calculate input cost based on cache hit rate.

[0019] In the above technical solution, the stored historical dialogue records of the main intelligent agent are retrieved, and the cache hit rate corresponding to the input content is predicted. Finally, the input cost is calculated based on the cache hit rate, and the computational cost of the task input stage can be dynamically adjusted in combination with the reuse rate of historical dialogue records. This achieves refined quantification of input cost, providing accurate basic parameters for subsequent calculation of the first and second execution costs.

[0020] In one embodiment, calculating the input cost based on the cache hit ratio includes: Calculate the product of the cache hit ratio and the preset cache character cost coefficient to obtain the first input cost corresponding to the cache hit content in the input content; Calculate the product of the non-cache hit ratio and the preset standard character cost coefficient to obtain the second input cost corresponding to the non-cache hit content in the input content; the sum of the cache hit ratio and the non-cache hit ratio is 1; The sum of the first input cost and the second input cost is determined as the input cost.

[0021] In the above technical solution, by distinguishing between cached and reused content and newly parsed content in the input content and calculating the computing power cost separately, and by calculating the two types of costs in layers based on the cache hit ratio and non-cache hit ratio and corresponding character cost coefficients, and then adding them together to obtain the input cost, it is possible to achieve a refined breakdown and statistical analysis of the input computing power cost, thereby improving the accuracy of the input cost value measurement.

[0022] In one embodiment, the task evaluation parameters include the permission risk coefficient and response quality sensitivity during the execution of this round of dialogue task; Based on the first execution cost, the second execution cost, the first occupancy rate, the second occupancy rate, and the task evaluation parameters, the agent's decision score is calculated, including: Calculate the cost difference between the first execution cost and the second execution cost, and the utilization rate difference between the first utilization rate and the second utilization rate; The initial decision score is obtained by weighting and summing the cost difference, occupancy difference, access risk coefficient, and response quality sensitivity. The agent's decision score is obtained by subtracting the preset isolation score corresponding to the preset isolation cost required for the sub-agent to perform this round of dialogue task from the initial decision score.

[0023] In the above technical solution, the initial decision score is obtained by calculating the cost difference and occupancy difference when the main agent and sub-agents execute the current round of dialogue task, and then weighting and summing these differences with permission risk coefficients and response quality sensitivity. Finally, the agent decision score is obtained by subtracting the preset isolation score corresponding to the isolation cost of the sub-agents from the initial decision score, which can simultaneously take into account computing power consumption, resource consumption, task-related attributes, and the inherent operational losses of the sub-agents. Furthermore, by comprehensively quantifying the adaptability of different execution schemes from multiple dimensions, the comprehensiveness and accuracy of the target agent's judgment results can be improved.

[0024] In one embodiment, based on agent decision scoring, the target agent for performing the current round of dialogue task is determined from the main agent and sub-agents, including: The task boundary determination result for this round of dialogue task is generated. The task boundary determination result includes a first result indicating that the current round of dialogue task needs to complete reasoning based on the historical dialogue records stored in the main agent, and a second result indicating that the current round of dialogue task does not need to complete reasoning based on the historical dialogue records. If the agent's decision score is less than the preset score threshold, and / or the task boundary determination result is the first result, then the main agent is determined as the target agent; If the agent's decision score is greater than or equal to the preset score threshold, and the task boundary determination result is the second result, then the sub-agent is determined as the target agent.

[0025] In the above technical solution, generating task boundary determination results that distinguish whether a task relies on historical dialogue records clarifies the contextual reasoning requirements of the current dialogue task. Subsequently, when the agent's decision score is less than a preset score threshold, and / or the task boundary determination result is the first result, the main agent is identified as the target agent, avoiding the problems of insufficient sub-agent adaptation and missing context. Furthermore, when the agent's decision score is greater than or equal to the preset score threshold, and the task boundary determination result is the second result, the sub-agent is identified as the target agent, fully leveraging the execution advantages of the sub-agent. Based on this, using the above method to determine the target agent can comprehensively improve the judgment criteria for agent selection, adapting to overall control requirements.

[0026] In one embodiment, the task evaluation parameters include the permission risk coefficient during the execution of this round of dialogue task; After determining the target agent for this round of dialogue task from the main agent and sub-agents based on agent decision scoring, the process also includes: If the target agent is a sub-agent, then when the permission risk coefficient is greater than the preset risk threshold, the preset restricted sub-agent will be used to handle the current round of dialogue tasks; the restricted sub-agent will be executed in an isolated operating environment with preset safe operating boundaries. If the target agent is a sub-agent, then when the permission risk coefficient is less than or equal to the preset risk threshold, the preset summary sub-agent will be used to handle the current round of dialogue tasks; the operating environment of the summary sub-agent does not have a preset safe operating boundary.

[0027] In the above technical solution, after identifying the target intelligent agent as a sub-intelligent agent, the risk level can be classified by comparing the permission risk coefficient with a preset risk threshold. When the permission risk coefficient is greater than the preset risk threshold, the restricted sub-intelligent agent can be run in an isolated operating environment with a secure operating boundary to handle the current round of dialogue task, thereby controlling the risks during the execution of the current round of dialogue task. Furthermore, when the permission risk coefficient is less than or equal to the preset risk threshold, the current round of dialogue task can be handled by a summary sub-intelligent agent without security constraints, which can reduce the operational overhead of the sub-intelligent agent and achieve hierarchical and differentiated scheduling of the sub-intelligent agents.

[0028] In one embodiment, if the target agent is a sub-agent, then after using a preset summary sub-agent to process the current round of dialogue task when the permission risk coefficient is less than or equal to a preset risk threshold, the method further includes: After this round of dialogue is completed, generate a summary of this round of dialogue. The summary content is identified as the processing result text and sent to the main intelligent agent.

[0029] In the above technical solution, after the summary sub-agent completes the current round of dialogue task, it generates a summary content containing core information and pushes it to the main agent as the processing result text. This not only preserves the key interaction information of this task for the main agent and completely updates the local historical dialogue records, but also simplifies the transmission of data and reduces data transmission and storage overhead.

[0030] In a second aspect, embodiments of this application provide an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the method described in the first aspect above.

[0031] Thirdly, embodiments of this application provide a computer-readable storage medium storing a computer program that, when executed by a processor, implements the method described in the first aspect above.

[0032] Fourthly, embodiments of this application provide a computer program product that, when run on an electronic device, causes the electronic device to execute the method described in the first aspect. Attached Figure Description

[0033] To more clearly illustrate the technical solutions in the embodiments of this application, 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 this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0034] Figure 1 This is a flowchart illustrating the implementation of an agent scheduling method according to an embodiment of this application; Figure 2 This is a schematic diagram illustrating one implementation of an agent scheduling method for determining the first execution cost, provided in an embodiment of this application. Figure 3 This is a schematic diagram illustrating one implementation of an agent scheduling method for determining a second execution cost according to an embodiment of this application; Figure 4 This is a schematic diagram illustrating an implementation method for calculating input cost in an agent scheduling method provided in an embodiment of this application; Figure 5 This is a schematic diagram illustrating one implementation of calculating input cost in an agent scheduling method provided in another embodiment of this application; Figure 6 This is a schematic diagram illustrating an implementation method for calculating agent decision scores in an agent scheduling method provided in an embodiment of this application; Figure 7 This is a schematic diagram illustrating one implementation of a smart agent scheduling method for determining a target smart agent, as provided in an embodiment of this application. Figure 8 This is a schematic diagram illustrating one implementation method of executing the current round of dialogue task in an agent scheduling method provided in an embodiment of this application; Figure 9 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation

[0035] In the following description, specific details such as particular system architectures and techniques are set forth for illustrative purposes and not for limitation, in order to provide a thorough understanding of the embodiments of this application. However, those skilled in the art will understand that this application may also be implemented in other embodiments without these specific details. In other instances, detailed descriptions of well-known systems, apparatuses, circuits, and methods have been omitted so as not to obscure the description of this application with unnecessary detail.

[0036] It should be understood that, when used in this application specification and the appended claims, the term "comprising" indicates the presence of the described features, integrals, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, integrals, steps, operations, elements, components and / or a collection thereof.

[0037] It should be noted that the information collection process (such as patient information collection process, physiological information collection process, etc.) / feature extraction process involved in this application is carried out with the user's knowledge and permission. That is, the information collection process / feature extraction process complies with the requirements of laws and regulations and does not constitute an act that harms the public interest.

[0038] Furthermore, in the description of this application and the appended claims, the terms "first," "second," "third," etc., are used only to distinguish descriptions and should not be construed as indicating or implying relative importance.

[0039] With the widespread application of large language models in business scenarios such as code-assisted development, data analysis, batch document processing, and automated operation and maintenance, the main intelligent agent primarily undertakes the functions of requirement understanding, global task planning, and user interaction. If the main intelligent agent directly reads massive files, loads complete test logs, or parses long documents to generate output content, all of the above-mentioned original materials will be stored in the main intelligent agent's historical interaction context, continuously occupying the context window capacity (model context space) in subsequent rounds of dialogue. Even if existing technologies introduce prompt caching mechanisms, these mechanisms can only reduce the billing overhead corresponding to repeated inputs, but cannot reduce the occupation of context window capacity by materials, nor can they solve the problem of redundant noise distracting the model's inference attention.

[0040] Sub-agents can isolate and process subdivided tasks with independent completeness, such as extracting core conclusions after batch scanning files, returning key fault information after executing test tasks, outputting a summary of the root cause of the fault after parsing logs, or performing high-risk operations in a permission-controlled environment. However, if sub-agents are enabled indiscriminately for all tasks, it will generate additional resource overhead for agent startup, independent context reconstruction, and data interaction between master and slave agents. For lightweight tasks with small input and output text volumes, it is more efficient to let the master agent handle them directly.

[0041] Based on this, in order to rationally select the intelligent agent to perform the task and adapt to the overall cost control requirements, one embodiment of this application provides an intelligent agent scheduling method. This method can be applied to electronic devices such as tablet computers, laptops, ultra-mobile personal computers (UMPCs), and netbooks. This embodiment of the application does not impose any restrictions on the specific type of electronic device.

[0042] Please see Figure 1 , Figure 1 The following is a flowchart illustrating the implementation of an agent scheduling method provided in an embodiment of this application. The method includes the following steps: S101. For the current dialogue task input by the user, obtain the first execution cost corresponding to the current dialogue task when executed by the main agent, and obtain the first occupancy rate of the preset model context space after the main agent executes the current dialogue task.

[0043] In one embodiment, the aforementioned current-round dialogue task refers to a complete interactive task initiated by a single user input and processed by a large language model, covering scenarios such as coding assistance, data analysis, document processing, and automated operation and maintenance. The current-round dialogue task may include single or combined operations such as file reading, log retrieval, instruction execution, and data computation, and serves as the processing unit in the current agent scheduling process.

[0044] The aforementioned main intelligent agent is the core intelligent agent responsible for overall coordination of interactions. It is responsible for receiving user input, understanding task requirements, planning the overall execution process, and continuously handling multiple rounds of user interaction. The main intelligent agent maintains a long-term continuous interaction context window. All persistently retained dialogue records and final task summaries are stored in its dedicated storage space, without a separate sandbox permission isolation environment.

[0045] Furthermore, the first execution cost is the quantitative value of the comprehensive resource loss generated by the main intelligent agent independently executing the entire process of this round of dialogue task. It can comprehensively represent the token calculation overhead and long-term context accumulation overhead brought about by the main intelligent agent executing this round of dialogue task.

[0046] As an example, an electronic device can break down the current dialogue task into three segments: input parsing, material retrieval, and inference generation, and calculate the segment cost for each segment separately. The sum of these costs yields the first execution cost mentioned above.

[0047] In one embodiment, the aforementioned model context space is a context storage area pre-allocated by the main agent and has a fixed capacity limit. It is used to continuously retain historical dialogue records, interactive text, and task processing result text. It corresponds to the large model context window budget, and the capacity limit is the preset total dialogue storage capacity. The storage usage directly consumes the available context resources of the model.

[0048] The aforementioned first occupancy rate is the ratio of the total size of all contexts stored by the main agent after it has completed the current dialogue task to the preset total dialogue storage capacity (model context space). It is used to quantitatively evaluate the congestion level of the context window after the main agent has completed the current dialogue task. Generally, the higher the first occupancy rate, the less available context resources remain.

[0049] As an example, a preset context history decay coefficient can be introduced to reduce the total number of characters in old historical dialogue records by weight, resulting in an equivalent storage size. Then, the noise generated during the current dialogue task is added to obtain the equivalent total storage size, and the ratio of the equivalent total storage size to the model context space is used as the first occupancy rate.

[0050] As another example, the electronic device can predict the scale of dialogue noise generated when the main agent performs the current dialogue task, and obtain the character size of the historical dialogue records already stored in the main agent. Finally, the sum of the dialogue noise scale and the character size is calculated to obtain the first storage size after the main agent processes the current dialogue task, and the ratio of the first storage size to the preset total dialogue storage capacity is determined as the first occupancy rate.

[0051] In one embodiment, the aforementioned dialogue noise scale is the total number of text characters that will remain in the main agent's context during the complete execution of this round of dialogue task by the main agent, serving as an indicator to quantify the occupancy of context window resources. The dialogue noise scale is composed of the sum of the input noise scale and the output noise scale.

[0052] Specifically, the input noise level is the amount of redundant text characters within the user's current input. For example, batches of raw full-text files, complete test logs, and unfiltered long raw data—all unfiltered raw input materials—would be stored in the context if processed by the main agent.

[0053] In addition, the output noise scale is the amount of redundant intermediate content characters generated during the reasoning process of the main intelligent agent, including the complete retrieval process, original analysis logs, full tool execution records, original output text of long documents, etc., but does not include the refined conclusion summary.

[0054] As an example, an electronic device may include task type templates for matching and predicting pre-established task noise templates for various scenarios such as coding, data analysis, document processing, and automated operation and maintenance, storing the standard input and output noise averages corresponding to different task types. Then, the business type of the current dialogue task is identified, the noise average of the corresponding task noise template is retrieved, and the sums are used to obtain the noise scale of the current dialogue.

[0055] Alternatively, a regression prediction model can be trained using a massive amount of historical task samples. The text length, number of files read, number of log entries, and number of tool calls of the input content can be used as model inputs. The regression prediction model can directly output the input noise scale and output noise scale of the current round of dialogue task, and then sum them to obtain the dialogue noise scale.

[0056] The model input features for each task sample include one or more features such as the business scenario of the task, the length of the text input by the user, the number of files to be read, the number of log records, the number of external tool calls, and the cache hit rate. The model output consists of the input noise scale and output noise scale obtained from the actual statistics of the corresponding historical tasks. The regression prediction model can be trained under supervision using mean squared error as the loss function. The internal weight parameters of the model are continuously updated iteratively through the gradient descent algorithm. After each iteration, the validation set loss value is calculated. When the decrease in validation set loss is less than a preset loss threshold for several consecutive iterations, or when the total number of iterations reaches a preset maximum number of iterations, the model iteration training is terminated. The final output is the converged regression prediction model used to predict the dialogue noise scale of the current dialogue task in real time.

[0057] In one embodiment, the aforementioned historical dialogue records are stored in the model context space of the main agent, encompassing all historical interaction texts, including historical user inputs, historical task outputs, and past task processing content. This constitutes the initial context base before the main agent executes a new task, and is used for two scenarios: cache hit prediction and storage occupancy calculation.

[0058] In addition, the character scale is the total number of tokens corresponding to the text content / the total number of characters. As a basic unit of measurement for uniformly quantifying context storage usage and task overhead, any piece of interactive, material, or summary text can be characterized by its storage space usage through the character scale.

[0059] The aforementioned first storage scale is the total number of text characters that the main agent model's context space needs to carry after the current round of dialogue task is completed by the main agent. It is equal to the character scale of the existing historical dialogue records before execution plus the noise scale of the current round of complete dialogue, representing the total context load after task execution.

[0060] As an example, an electronic device can directly access all historical dialogue records stored in the context space of the main agent model, and iterate through and count the total number of characters in all text in real time, using this count as the character size of the current historical dialogue record. Alternatively, the electronic device can continuously maintain a global character counter, automatically accumulating newly added text characters and deleting expired text characters after each round of interaction. The character size of the current historical dialogue record can be quickly obtained by directly reading the counter value, without needing to iterate through the entire record.

[0061] As an example, the formula for calculating the first occupancy rate can be as follows: ; in, U represents the first occupancy rate, U represents the character size, Tk represents the dialogue noise size, and W represents the model context space.

[0062] In this embodiment, by predicting the scale of dialogue noise generated by the main agent during task execution in advance, and combining this with the character inventory of historical dialogue records currently stored by the main agent, the overall initial storage scale after the current round of dialogue task execution can be accurately calculated. This initial storage scale is then quantified by comparing it with the capacity of the model context space to obtain a standardized initial occupancy rate. Furthermore, this allows for a direct and quantitative characterization of the congestion level of the context window after the main agent fully undertakes the current round of task, clearly quantifying the risk of redundant noise encroaching on the storage resources of the model context space. This provides an objective and unified quantitative indicator for subsequent horizontal comparison of storage consumption differences between sub-agent execution schemes.

[0063] It should be noted that before assigning agents to execute the current round of dialogue tasks, the overhead indicators corresponding to the main agent independently processing the current round of dialogue tasks should be quantitatively calculated in advance: the comprehensive execution overhead at the computing resource level (first execution cost) and the window occupancy level at the context storage resource level (first occupancy rate). This can provide basic data for subsequent quantitative comparison with sub-agent schemes and for calculating scheduling decision scores.

[0064] S102. Obtain the second execution cost corresponding to the current dialogue task when it is executed by the sub-agent, and obtain the second occupancy rate of the model context space after the sub-agent sends the processing result text to the main agent.

[0065] In one embodiment, the aforementioned sub-agent is an independently operating auxiliary intelligent unit used to undertake subdivided subtasks with independent completeness. Enabling sub-agents will incur additional isolation overhead such as startup, context reconstruction, and master-slave communication.

[0066] The aforementioned second execution cost is the comprehensive and quantified resource consumption of the entire process of handing over the dialogue task to the sub-agents for isolated execution. Typically, the second execution cost includes not only the input and output costs of the dialogue task itself, but also the fixed isolation overhead required for sub-agent scheduling, used to uniformly measure the overall computational and communication resources consumed by the selected sub-agent scheme.

[0067] As an example, an electronic device can break down the entire process of a sub-agent: startup overhead, independent context construction overhead, task retrieval and analysis computing power overhead, master-slave communication overhead, and summary generation overhead. The various losses are calculated in segments and then summed up to directly obtain the second execution cost.

[0068] In one embodiment, the processing result text is the content returned by the sub-agent to the main agent after completing the task calculation. The processing result text can be a simplified summary text, containing only the core conclusions and key information of the task; alternatively, the processing result text can include the full log, original files, and complete intermediate inference steps.

[0069] The aforementioned second occupancy rate is the ratio of the overall storage size of the main agent to the model context space after the sub-agent processes the task in this round and sends the processing result text back to the main agent. It is used to quantify the main context window (model context space) when the sub-agent executes.

[0070] As an example, electronic devices can introduce a context decay coefficient to effectively reduce the number of long-standing historical dialogue characters in the main agent, resulting in an equivalent total number of existing characters. Then, the text size of the processed text is superimposed to calculate the equivalent storage size, and the ratio of the equivalent total storage size to the model context space is used as the second occupancy rate.

[0071] In another embodiment, the electronic device can obtain the character size of the historical dialogue records stored in the main agent, and calculate the sum of the text size and character size of the processed result text to obtain the second storage size required by the main agent when the sub-agent processes the current dialogue task. Finally, the ratio of the second storage size to the model context space is determined as the second occupancy rate.

[0072] In one embodiment, the aforementioned historical dialogue records and character size have already been explained in S101 above, and will not be described again.

[0073] The text size mentioned above refers to the total number of characters (total number of tokens) in the corresponding text content, which is a unified quantitative unit for measuring the amount of model context space occupied by the text content. The text size is typically much smaller than the scale of dialogue noise generated by the main agent in handling this round of dialogue.

[0074] The aforementioned second storage size represents the total number of text characters required to be carried by the main agent's model context space after the current round of dialogue task has been completed by the isolated execution of the sub-agents and the sub-agents have returned the processing result text to the main agent. The calculation logic involves adding only the text size corresponding to the processing result text to the current character size of the main agent's historical dialogue records, without adding the dialogue noise generated during the sub-agents' execution. This objectively reflects the actual total load on the main agent's model context space under the sub-agent scheduling scheme.

[0075] As an example, the formula for calculating the second occupancy rate can be as follows: ; in, U represents the second occupancy rate, Tk,sum represents the character size, and W represents the model context space.

[0076] In this embodiment, the second storage size is obtained by superimposing the text size of the processed result text onto the character size of the historical dialogue records already stored by the main agent. This second storage size is then calculated by combining it with the model context space capacity to obtain the second occupancy rate. This allows for accurate quantification of the resource consumption of the model context space in the main agent under the sub-agent isolated execution scheme. Furthermore, this provides a quantifiable benchmark for comparison with the first occupancy rate corresponding to the main agent directly processing the current round of dialogue tasks, offering an objective storage dimension evaluation basis for comprehensively calculating the agent's decision score.

[0077] It should be noted that by separately quantifying the computational overhead and main context storage overhead of the sub-agent isolation execution scheme, two sets of quantitative data can be formed for horizontal comparison with the main agent scheme. This provides a benchmark for subsequent computation agent decision scoring and intuitively reflects the differences between the two execution paths in terms of resource consumption and context usage.

[0078] S103. Obtain the task evaluation parameters when executing the current round of dialogue task.

[0079] Among them, the task evaluation parameters are used to quantitatively characterize the attributes and features of the task during this round of dialogue.

[0080] For example, the above task evaluation parameters include, but are not limited to, parameters such as permission risk coefficient and response quality sensitivity, and there are no restrictions on these parameters.

[0081] The permission risk coefficient quantifies the level of security risk when calling external tools, networks, files, and system commands in this round of dialogue tasks. The higher the value, the more likely the operation is to cause security risks such as data leakage and system tampering.

[0082] Response quality sensitivity characterizes the degree to which the current dialogue task depends on the complete context of the model and the details of the original material. A higher value means that the task reasoning cannot delete the original input and output information and is not suitable for excessive compression of the summary.

[0083] The permission risk coefficient and response quality sensitivity can be collected individually or simultaneously as task evaluation parameters in the scoring calculation.

[0084] As an example, electronic devices can pre-establish a mapping label library between task types and task evaluation parameter values. For scenarios such as coding, data analysis, document processing, and automated operation and maintenance, standard permission risk coefficients and response quality sensitivities are preset for various sub-tasks. The electronic device can identify the business type and operation instruction labels of the current dialogue task and directly look up the corresponding values ​​as task evaluation parameters.

[0085] In another embodiment, the electronic device can also parse the user-input task instructions, the name of the operation to be performed, and the tool call identifier, retrieve high-risk operation keywords and high-precision analysis requirement keywords in the text, and calculate the real-time permission risk coefficient and response quality sensitivity based on the keyword matching score weighting, and combine them to form task evaluation parameters.

[0086] In this embodiment, the method of obtaining task evaluation parameters is not limited.

[0087] S104. Calculate the agent's decision score based on the first execution cost, the second execution cost, the first occupancy rate, the second occupancy rate, and the task evaluation parameters.

[0088] In one embodiment, the aforementioned agent decision score is a standardized quantitative score obtained by integrating the resource overhead, context storage occupation, and task attribute characteristics of the two types of agent execution schemes. This score can intuitively quantify the comprehensive suitability of selecting the main agent and sub-agents to execute the current dialogue task.

[0089] Among them, the score of the agent decision score is used to distinguish the overall advantages and disadvantages of different execution paths, and serves as a unified judgment basis for automatically selecting the optimal execution subject.

[0090] As an example, an electronic device can use the first execution cost, the second execution cost, the first occupancy rate, the second occupancy rate, and the task evaluation parameters as input features of a scoring linear regression model, and directly output the normalized agent decision score by calling the pre-trained scoring linear regression model.

[0091] The electronic device can collect a large number of historical real scheduling samples to construct a supervised training dataset. Each set of scheduling samples is equipped with five complete input features and standard decision scores corresponding to the optimal execution subject, labeled manually or by the system. Using mean squared error as the loss function, a gradient descent algorithm is employed for supervised linear regression training, continuously iteratively updating the weight coefficients and bias terms corresponding to each feature of the model. Training stops when the decrease in loss on the validation set is less than a preset minimum loss threshold for multiple consecutive rounds, or when the total number of iterations reaches a preset maximum number of iterations. The convergent and stable weight parameters are then saved, completing the generation of the scoring linear regression model.

[0092] Alternatively, we can divide the system into resource consumption, storage usage, and task attribute dimensions, calculate the sub-scores for each dimension, and then combine the sub-scores with preset weights to obtain the agent decision score that integrates all indicators.

[0093] S105. Based on the agent decision score, determine the target agent to perform the current round of dialogue task from the main agent and sub-agents.

[0094] In one embodiment, the electronic device can pre-set a single preset scoring threshold and compare the calculated agent decision score with the preset scoring threshold. If the agent decision score is greater than or equal to the preset scoring threshold, the sub-agent is selected as the target agent for this round of dialogue. Otherwise, if the agent decision score is less than the preset scoring threshold, the main agent is determined as the target agent.

[0095] In this embodiment, before the execution of the current dialogue task, the first execution cost corresponding to the main agent executing the current dialogue task, and the first occupancy rate of the model context space after the main agent executes the current dialogue task are quantitatively calculated. The second execution cost corresponding to the isolated execution of the current dialogue task by the sub-agent, and the second occupancy rate of the model context space after the sub-agent sends the processing result text to the main agent are also quantitatively calculated. Simultaneously, the quantified agent decision score is comprehensively calculated by combining the task evaluation parameters describing the constraints of the current dialogue task execution. Based on this, the automatic selection of the execution subject can be completed based on a unified quantitative score. Compared with related technologies that rely solely on semantically coarse agent allocation without prior quantitative evaluation, this method can accurately measure the occupancy rate of the context model context space, various execution costs, and the task's own constraint factors, autonomously determining whether the current dialogue task is more suitable for direct execution by the main agent or isolated execution by the sub-agent. Furthermore, it can not only avoid the additional startup and context reconstruction resource consumption caused by blindly activating sub-agents, but also avoid the problems of context model context space crowding and model inference attention dispersion caused by the main agent carrying massive redundant content, thus achieving coordinated optimization scheduling of context storage resources and computing resources.

[0096] In another embodiment, the electronic device can be based on, for example... Figure 2 The steps S201-S203 shown below calculate the first execution cost, detailed as follows: S201. Obtain the input cost required for the input content in this round of dialogue task.

[0097] S202. Predict the scale of dialogue noise generated when the main agent performs the current dialogue task, and the number of interaction rounds the main agent will continue to interact after the current dialogue task is completed.

[0098] In one embodiment, the input content, the scale of dialogue noise, and its prediction method have been explained above and will not be described again.

[0099] Input cost is a standardized value that quantifies the computational resources required to process all input content in this round of dialogue task, and is calculated in characters / tokens. All input materials uploaded by users, such as original documents, logs to be retrieved, code files, and query commands, are included in the statistics to characterize the basic computational power consumption during the input phase of this round of dialogue task.

[0100] The aforementioned interaction rounds refer to the estimated number of consecutive interactions after the completion of the current dialogue task, during which the user continues to initiate follow-up questions, supplementary instructions, and iterative adjustments. The more interaction rounds, the longer the dialogue noise generated by the current task will remain in the context window, continuously amplifying storage and computing power consumption. Therefore, using it as a coefficient in the calculation of the first execution cost can measure the long-term cumulative resource consumption brought about by the task.

[0101] As an example, electronic devices can pre-build a historical average interaction round mapping table corresponding to various business tasks, distinguishing between scenarios such as code debugging, data analysis, document writing, and maintenance instructions. Then, the task type of the current dialogue task is identified, and the average value corresponding to the task type is directly retrieved as the predicted interaction round.

[0102] Alternatively, analyze the user input commands in this round of dialogue, identify high-frequency continuous interaction keywords such as iterative modification, multiple debugging, and step-by-step query, match the round weights corresponding to the keywords, and obtain the estimated number of interaction rounds through weighted calculation.

[0103] Alternatively, a regression model can be trained using the number of files in historical tasks, the number of tool calls, and the task complexity label as input features, and the actual subsequent interaction rounds as labels. After inputting the features of the current task, the predicted interaction rounds can be directly output.

[0104] In this embodiment, the method for predicting the number of interaction rounds is not limited.

[0105] S203. The product of input cost, dialogue noise level, and number of interaction rounds is determined as the first execution cost.

[0106] For example, the formula for calculating the first execution cost is as follows: ; in, The first execution cost, Let be the noise level of the dialogue in the k-th round of the dialogue task. For interactive rounds, The input cost of the k-th round of the dialogue task.

[0107] In this embodiment, the first execution cost is obtained by multiplying three key indicators: the input cost of the input content in this round of dialogue, the scale of dialogue noise generated by the main agent after executing this round of dialogue, and the estimated number of subsequent continuous interaction rounds after the task ends. This approach can simultaneously take into account both the computational cost of a single round of dialogue and the resource consumption accumulated over long-term, multi-round interactions. Furthermore, it can fully quantify the comprehensive resource consumption of the main agent independently undertaking the entire process of this round of dialogue, forming an objective and unified quantitative indicator of computational power. This provides an intuitive horizontal comparison with the second execution cost corresponding to the sub-agent scheme, offering reliable data support at the computational power level for subsequent multi-dimensional fusion computational agent decision scoring.

[0108] Similar to the method described above for calculating the first execution cost, in another embodiment, the electronic device can calculate the cost based on, for example... Figure 3 The steps S301-S303 shown calculate the second execution cost. Details are as follows: S301. Obtain the input cost required for the input content in this round of dialogue task, and the text size of the processed result text.

[0109] S302. Predict the number of interaction rounds that the main agent will continue to interact after the current dialogue task is completed.

[0110] S303. Based on input cost, text size, and number of interaction rounds, calculate the second execution cost of the sub-agent performing this round of dialogue task.

[0111] In one embodiment, the input cost, text size, and number of interaction rounds have already been explained above and will not be described again.

[0112] As an example, electronic devices can calculate the second execution cost of a sub-agent performing the current round of dialogue by weighting and summing the input cost, text size, and number of interaction rounds.

[0113] In this embodiment, the second execution cost is calculated based on the input cost, the text size of the processed result text, and the estimated number of interaction rounds. This allows for a complete quantification of the overall computing power consumption generated by the sub-agent in executing the task, considering the input content, output content (processed result text), and subsequent multi-round interactions. Furthermore, the first execution cost corresponding to the main agent forms a horizontally comparable quantitative index of computing power, providing an objective and complete computing power reference for comprehensively calculating the agent's decision-making score.

[0114] In another embodiment, the electronic device may also calculate the product of input cost, text size, and number of interaction rounds to obtain a third execution cost. Then, the third execution cost is summed with a preset isolation cost required for the sub-agent to perform this round of dialogue to obtain a second execution cost.

[0115] The aforementioned preset isolation cost is the basic quantitative overhead incurred by the independent context initialization, cross-module data transmission, and sub-instance startup and maintenance processes when the dialogue task is run independently by the sub-agent. It is a pre-set fixed value.

[0116] As an example, the formula for calculating the second execution cost can be as follows: ; in, As the second execution cost, To pre-set isolation costs, Let k be the text size corresponding to the k-th round of the dialogue task. For interactive rounds, The input cost of the k-th round of the dialogue task.

[0117] In this embodiment, the third execution cost is first calculated by multiplying the input cost, text size, and number of interaction rounds, and then a preset isolation cost is added to obtain the complete second execution cost. This not only covers the computational power consumption of this round of dialogue task itself, but also takes into account the fixed overhead generated by the independent operation of the sub-agent. Furthermore, a comprehensive and standardized quantitative result of the computational power of the sub-agent executing this round of dialogue task can be formed, providing complete computational power dimension data for the calculation of agent decision-making scores.

[0118] In another embodiment, the electronic device can be based on, for example... Figure 4 The steps S401-S403 shown are used to obtain the input cost. Details are as follows: S401. Obtain the historical dialogue records stored in the main intelligent agent.

[0119] S402, Predict the cache hit rate of input content matching historical dialogue records.

[0120] In one embodiment, the historical dialogue records have already been explained above and will not be repeated here. It should be noted that the above-mentioned cache hit ratio represents the quantitative ratio of the degree of overlap and matching between the input content of the current dialogue task and the stored historical dialogue records. The value ranges from 0 to 1, and the higher the value, the more cached content can be reused.

[0121] As an example, electronic devices can calculate the text similarity between the input content and each historical dialogue record, and combine this with the proportion of similar samples to obtain the cache hit ratio. Alternatively, they can extract the core keywords from the input content, retrieve the number of historical records containing those keywords, and use the ratio of the number of historical records to the total number of historical dialogue records as the aforementioned cache hit ratio.

[0122] In this embodiment, the method for predicting the cache hit ratio is not limited.

[0123] S403. Calculate input cost based on cache hit ratio.

[0124] In one embodiment, the electronic device can pre-set a baseline input cost in an unbuffered state, and then calculate the product of the baseline input cost and the unbuffered hit ratio (1 minus the buffered hit ratio) to obtain the input cost.

[0125] Alternatively, multiple cache hit ratio ranges can be pre-defined, with each range matched with a corresponding cost discount factor. Finally, the product of the baseline input cost and the discount factor is used to determine the input cost.

[0126] In this embodiment, the method for calculating input costs is not limited.

[0127] In this embodiment, the system retrieves historical dialogue records stored by the main agent and predicts the cache hit rate corresponding to the input content. Finally, based on the cache hit rate, the input cost is calculated, and the computational cost of the task input stage can be dynamically adjusted in conjunction with the reuse rate of historical dialogue records. This enables refined quantification of input cost, providing accurate basic parameters for subsequent calculation of the first and second execution costs.

[0128] As an example, electronic devices can be based on, for example Figure 5 The steps S501-S503 shown below are for calculating the input cost, detailed as follows: S501. Calculate the product of the cache hit ratio and the preset cache character cost coefficient to obtain the first input cost corresponding to the cache hit content in the input content.

[0129] In one embodiment, the aforementioned cached character cost coefficient is a pre-set quantized value, representing the basic computing power cost required per unit character when reusing existing content in the cache.

[0130] Based on this, the first input cost can be considered as the computational overhead generated by the part of the input content that can match historical dialogue records and can be reused in the cache, which is calculated by multiplying the cache hit ratio by the cache character cost coefficient.

[0131] S502. Calculate the product of the non-cached hit ratio and the preset standard character cost coefficient to obtain the second input cost corresponding to the non-cached hit content in the input content.

[0132] The sum of the cache hit ratio and the non-cache hit ratio is 1.

[0133] In one embodiment, the aforementioned standard character cost coefficient is a pre-set quantified value, representing the basic computing power required for a unit character that cannot be reused from the cache and requires a completely new parsing operation.

[0134] Based on this, the second input cost can be considered as the computational overhead generated by the part of the input content that cannot match historical dialogue records and has no cached reusable content, which is calculated by multiplying the non-cache hit ratio by the standard character cost coefficient.

[0135] Based on the above, the computational cost (first input cost) of reusable cached content is calculated by multiplying the cache hit rate by the cache character cost coefficient. Furthermore, the second input cost for entirely new parsed content is calculated by multiplying the non-cache hit rate (which, when added to the cache hit rate, equals 1) by the standard character cost coefficient. By separately calculating the computational cost of each type of content, a tiered and refined measurement of input costs can be achieved.

[0136] S503. The sum of the first input cost and the second input cost is determined as the input cost.

[0137] As an example, the formula for calculating input costs can be as follows: ; in, Indicates input cost, Indicates the cache hit rate. This represents the standard character cost coefficient. This represents the cost coefficient for caching characters.

[0138] In this embodiment, by distinguishing between cached and reused content and newly parsed content in the input content and calculating the computing power cost separately, and by calculating the two types of costs in layers based on the cache hit ratio and non-cache hit ratio and corresponding character cost coefficients, and then adding them together to obtain the input cost, it is possible to achieve a refined breakdown and statistical analysis of the input computing power cost, thereby improving the accuracy of the input cost value measurement.

[0139] In another embodiment, taking the task evaluation parameters including the permission risk coefficient and response quality sensitivity during the execution of this round of dialogue task as an example, the electronic device can also base its evaluation on parameters such as... Figure 6 The steps S601-S603 shown are used to calculate the agent's decision score, and are described in detail below: S601. Calculate the cost difference between the first execution cost and the second execution cost, and the utilization rate difference between the first utilization rate and the second utilization rate.

[0140] S602. The initial decision score is obtained by weighting and summing the cost difference, occupancy difference, access risk coefficient, and response quality sensitivity.

[0141] In one embodiment, the permission risk coefficient and response quality sensitivity have already been explained above, and will not be described again.

[0142] The aforementioned cost difference is the difference between the overall execution cost of the main agent and the overall execution cost of the sub-agent; the occupancy difference is the difference between the resource occupancy index of the main agent and the resource occupancy index of the sub-agent. Since the cost difference and occupancy difference are numerical values ​​of different dimensions, both differences need to be normalized before being used in the calculation to eliminate computational bias caused by differences in numerical magnitude.

[0143] For example, the ratio of the cost difference to the preset normalized cost can be determined as the normalized cost difference.

[0144] It should be noted that the difference in occupancy rate is obtained by subtracting the first occupancy rate and the second occupancy rate, both of which are in the range of 0 to 1. The calculation result naturally falls in the range of [-1,1]. Since the magnitude of the indicator itself is uniform, it can be directly used in the calculation without additional normalization.

[0145] In one embodiment, the weights corresponding to cost difference, occupancy difference, response quality sensitivity, and permission risk coefficient can be preset, and there is no limitation on this.

[0146] It should be further explained that cost difference, occupancy difference, response quality sensitivity, and permission risk coefficient belong to multiple independent dimensions of resource consumption, resource usage, and task execution attributes, and each dimension has a different degree of influence on scheduling decisions. Based on this, by assigning dedicated weights and weighted summation, information from all dimensions can be integrated to obtain a unified quantitative score. This allows the initial decision score to comprehensively reflect the overall suitability of the sub-agent relative to the master agent in executing this round of tasks, under the condition of comparing only the resources and task attributes of the two types of agents themselves.

[0147] S603. Subtract the preset isolation score corresponding to the preset isolation cost required for the sub-agent to perform this round of dialogue task from the initial decision score to obtain the agent decision score.

[0148] In one embodiment, the aforementioned preset isolation score is a standardized correction score pre-calculated based on the isolation overhead required for the operation of the sub-agent, used to offset the interference of the inherent losses caused by the independent operation of the sub-agent on the scoring results.

[0149] As an example, the formula for calculating the agent's decision score can be as follows: ; in, This represents the agent's decision score. Indicates the first execution cost, Indicates the second execution cost, Indicates the first occupancy rate, Indicates the second occupancy rate. This indicates the permission risk factor. Indicates response quality sensitivity. Indicates the preset isolation score. These represent the corresponding weights.

[0150] In this embodiment, the initial decision score is obtained by calculating the cost difference and occupancy difference when the main agent and sub-agents execute the current round of dialogue tasks, and then weighting and summing these differences with permission risk coefficients and response quality sensitivity. Finally, the agent decision score is obtained by subtracting the preset isolation score corresponding to the isolation cost of the sub-agents from the initial decision score, which can simultaneously take into account computing power consumption, resource consumption, task-related attributes, and the inherent operational losses of the sub-agents. Furthermore, by comprehensively quantifying the adaptability of different execution schemes from multiple dimensions, the comprehensiveness and accuracy of the target agent's judgment results can be improved.

[0151] In another embodiment, the electronic device may also be based on, for example... Figure 7 Steps S701-S703, as shown, determine the target agent. Details are as follows: S701, the task boundary determination result of this round of dialogue task.

[0152] The task boundary determination results include a first result indicating that the current dialogue task needs to complete reasoning based on the historical dialogue records stored in the main agent, and a second result indicating that the current dialogue task does not need to complete reasoning based on the historical dialogue records.

[0153] In one embodiment, the complete reasoning process of the current dialogue task typically relies on the context, interaction information, and historical query data retained from past dialogues. Without this historical record, it is impossible to complete the task logic deduction completely and accurately. Therefore, the task boundary determination result can be considered the first result.

[0154] Furthermore, this round of dialogue is an independent, single-query task, and the reasoning process can be completed solely based on the current input, without needing to retrieve and reuse previously stored dialogue content. Therefore, the task boundary determination result can be considered the secondary result.

[0155] As an example, an electronic device can extract feature keywords representing contextual continuation and iterative questioning from the input content, output a first result after matching, and output a second result if no relevant keywords are found. Alternatively, it can calculate the similarity between the input content and the historical dialogue records in the main agent. If the similarity is greater than a preset similarity, the first result is output; otherwise, if the similarity is less than or equal to the preset similarity, the second result is output.

[0156] For example, if the historical dialogue record includes "Let the agent write a Python data statistics script," and the user's current input is "Optimize the previous code to reduce runtime," then this round of dialogue task can be considered to require the previously saved code record to complete the reasoning. In this case, the task boundary determination result can be determined as the first result. If the input content is "Explain the basic principles of bubble sort," and this problem can be handled independently based solely on the input content, without needing to retrieve any historical dialogue record for inference, then the task boundary determination result can be determined as the second result.

[0157] S702. If the agent's decision score is less than the preset score threshold, and / or the task boundary determination result is the first result, then the main agent is determined as the target agent.

[0158] S703. If the agent's decision score is greater than or equal to the preset score threshold, and the task boundary determination result is the second result, then the sub-agent is determined as the target agent.

[0159] In one embodiment, the aforementioned preset scoring threshold is a pre-set fixed score standard used to compare the decision scores of the intelligent agents, serving as a numerical dividing line for initially distinguishing the fit between the main intelligent agent and the sub-intelligent agents.

[0160] It should be noted that when the agent's decision score is lower than the preset score threshold, it means that the overall resource cost and adaptability of the sub-agent's execution are inferior to those of the master agent, making it more cost-effective to use the master agent. However, when the task boundary judgment result is the first result, it means that the reasoning of this round of dialogue task must retrieve the locally stored historical dialogue records, and the sub-agent cannot directly reuse the complete historical context of the master agent. Therefore, it can only be executed by the master agent. The master agent can be selected if either of the two conditions is met, balancing resource cost and context data dependency requirements.

[0161] Furthermore, when the agent's decision score is greater than or equal to a preset score threshold, it indicates that the sub-agent's overall resource consumption is more favorable. Simultaneously, the task boundary determination result is the second result, meaning that the current dialogue task can complete reasoning solely based on the current input, without needing to retrieve historical dialogue records, and there are no context reuse restrictions. Therefore, when both conditions are met simultaneously, it is safe to select a sub-agent to carry out the task, achieving optimal resource scheduling.

[0162] In this embodiment, generating task boundary determination results that distinguish whether a task relies on historical dialogue records clarifies the contextual reasoning requirements of the current dialogue task. Then, when the agent's decision score is less than a preset score threshold, and / or the task boundary determination result is the first result, the main agent is identified as the target agent, avoiding issues of insufficient sub-agent adaptation and missing context. Furthermore, when the agent's decision score is greater than or equal to the preset score threshold, and the task boundary determination result is the second result, the sub-agent is identified as the target agent, fully leveraging the sub-agent's execution advantages. Therefore, using the above method to determine the target agent improves the overall agent selection criteria to better suit overall control requirements.

[0163] In another embodiment, the task evaluation parameters include a permission risk coefficient during the execution of this round of dialogue task. The electronic device can also, based on, such as... Figure 8 The steps S801-S802 shown below are for processing this round of dialogue tasks, detailed as follows: S801. If the target agent is a sub-agent, then when the permission risk coefficient is greater than the preset risk threshold, the preset restricted sub-agent is used to handle the current round of dialogue task.

[0164] The aforementioned restricted sub-agents are executed in an isolated operating environment with preset safe operating boundaries.

[0165] In one embodiment, the aforementioned preset risk threshold is a pre-defined numerical boundary line used to distinguish the level of permission risk corresponding to a task. For example, the preset risk threshold can be 0.9.

[0166] The aforementioned restricted sub-agents are instances of sub-agents assigned to high-risk tasks, and their operation is subject to constraints and controls. For example, there are constraints on the safe operating boundaries of the restricted sub-agents, and rules that limit the scope of data reading, access, and output by the sub-agents to avoid risky operations.

[0167] For example, the list of callable tools, file access paths, external network access range, and executable instructions and commands of the restricted sub-agent can be limited to restrict its operational boundaries and avoid various security risks.

[0168] The aforementioned isolated operating environment is an independent operating space that does not fully communicate with the main intelligent agent, and is used to manage high-risk tasks.

[0169] It should be noted that when the permission risk coefficient exceeds the preset risk threshold, it indicates that the risk of this round of dialogue task is high, and the restricted sub-agent needs to run in an isolated environment with secure operating boundaries. This can constrain unauthorized operations by the sub-agent and reduce security risks.

[0170] S802. If the target agent is a sub-agent, then when the permission risk coefficient is less than or equal to the preset risk threshold, the preset summary sub-agent is used to handle the current round of dialogue task.

[0171] In particular, the operating environment of the abstract sub-agent does not have a preset safe operating boundary.

[0172] In one embodiment, the aforementioned summary sub-agent is a conventional sub-agent designed for low-risk tasks, without any additional security constraints.

[0173] For example, the abstracting agent can freely read massive amounts of reference materials, initiate data retrieval, and perform various operations such as log analysis within its own independent context, without being subject to constraints such as tools, paths, networks, and instructions.

[0174] It is understandable that when the permission risk coefficient is lower than the preset risk threshold, it indicates that the risk of this round of dialogue task is low and no additional security control is required. Using a summary sub-agent without security boundaries can reduce additional runtime overhead.

[0175] In this embodiment, after determining the target agent as a sub-agent, the risk level can be classified by comparing the permission risk coefficient with a preset risk threshold. When the permission risk coefficient is greater than the preset risk threshold, the restricted sub-agent can be run in an isolated operating environment with secure operating boundaries to handle the current round of dialogue tasks, thereby controlling the risks during the execution of the current round of dialogue tasks. Conversely, when the permission risk coefficient is less than or equal to the preset risk threshold, the current round of dialogue tasks can be handled by a summary sub-agent without security constraints, which can reduce the operational overhead of the sub-agent and achieve hierarchical and differentiated scheduling of the sub-agents.

[0176] In another embodiment, after the current round of dialogue task is processed by a preset summary sub-agent, the electronic device can also generate a summary of the current round of dialogue task after the current round of dialogue task is completed, and determine the summary content as the processing result text and send it to the main agent.

[0177] The above-mentioned summary content is a concise structured text extracted after the completion of this round of dialogue tasks. It may include, but is not limited to, six types of information: task conclusions, key evidence, necessary citations, reasons for failure, risk warnings, and a detailed index of materials not included in the main dialogue, thus fully preserving the core information of the task.

[0178] For example, when a user requests statistics on monthly sales data, the summary content can record the final revenue conclusion, the original data used in the calculation (key evidence), the reference address of the report file (necessary reference), the reasons for failure due to data missing causing local statistical deviations, the risk warning related to data leakage, and the material index of the complete original data table. The structured summary (summary content) is then sent back to the main intelligent agent as the processing result text.

[0179] In this embodiment, after the summary sub-agent completes the current round of dialogue task, it generates a summary containing core information and pushes it to the main agent as the processing result text. This not only preserves the key interaction information of this task for the main agent and completely updates the local historical dialogue records, but also simplifies the transmission of data and reduces data transmission and storage overhead.

[0180] In another embodiment, the electronic device can also statistically analyze the actual execution cost consumed in this round of dialogue. Using this actual cost data and the predicted execution cost (first execution cost or second execution cost) corresponding to the target agent, iteratively update parameters used for initial estimation, such as the cached character cost coefficient, the standard character cost coefficient, and the preset scoring threshold. This can correct the deviation between the estimated values ​​and the actual scenario, continuously improving the accuracy of subsequent calculations of various execution costs and agent decision-making scores, making the quantitative judgment basis for agent scheduling more closely aligned with actual operating conditions.

[0181] Furthermore, to address scenarios such as excessively long summary content, users repeatedly asking for details omitted in the summary, and sub-agents failing to execute tasks, electronic devices can reduce the tendency to assign dialogue tasks of the same type to restricted sub-agents, and can also adjust the generation format and content scope of the summary. Consequently, task allocation strategies and summary output logic can be specifically optimized to reduce the recurrence of similar problems.

[0182] Figure 9 This is a schematic diagram of the structure of an electronic device provided in one embodiment of this application. Figure 9 As shown, the electronic device 900 of this embodiment includes: a processor 910, a memory 920, and a computer program 930 stored in the memory 920 and executable on the processor 910, such as a program for an agent scheduling method. When the processor 910 executes the computer program 930, it implements the steps of each embodiment of the agent scheduling method described above, for example... Figure 1 S101 to S105 are shown.

[0183] For example, the computer program 930 can be divided into one or more modules, one or more of which are stored in the memory 920 and executed by the processor 910 to implement the intelligent agent scheduling method provided in the embodiments of this application. One or more modules can be a series of computer program instruction segments capable of performing specific functions, which describe the execution process of the computer program 930 in the electronic device 900. For example, the computer program 930 can implement the intelligent agent scheduling method provided in the embodiments of this application.

[0184] Electronic device 900 may include, but is not limited to, processor 910 and memory 920. Those skilled in the art will understand that... Figure 9 This is merely an example of electronic device 900 and does not constitute a limitation on electronic device 900. It may include more or fewer components than shown, or combine certain components, or different components. For example, electronic device may also include input / output devices, network access devices, buses, etc.

[0185] The processor 910 may be a central processing unit, or it may be other general-purpose processors, digital signal processors, application-specific integrated circuits, off-the-shelf programmable gate arrays or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor may be a microprocessor or any conventional processor, etc.

[0186] The memory 920 can be an internal storage unit of the electronic device 900, such as a hard disk or RAM of the electronic device 900. The memory 920 can also be an external storage device of the electronic device 900, such as a plug-in hard disk, smart memory card, flash memory card, etc., equipped on the electronic device 900. Furthermore, the memory 920 can include both internal storage units and external storage devices of the electronic device 900.

[0187] This application provides a computer-readable storage medium, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements the agent scheduling method as described in the above embodiments.

[0188] This application provides a computer program product that, when run on an electronic device, causes the electronic device to execute the agent scheduling method in the above embodiments.

[0189] The above embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this application, and should all be included within the protection scope of this application.

Claims

1. A method for scheduling intelligent agents, characterized in that, The method includes: For the current dialogue task input by the user, obtain the first execution cost corresponding to the current dialogue task when executed by the main agent, and obtain the first occupancy rate of the preset model context space after the main agent executes the current dialogue task; The second execution cost corresponding to the current round of dialogue task being executed by the sub-agent is obtained, and the second occupancy rate of the model context space after the sub-agent sends the processing result text to the main agent is obtained; Obtain the task evaluation parameters during the execution of the current round of dialogue task; Based on the first execution cost, the second execution cost, the first occupancy rate, the second occupancy rate, and the task evaluation parameters, calculate the agent decision score; Based on the agent's decision score, the target agent for performing the current round of dialogue task is determined from the main agent and the sub-agents.

2. The method according to claim 1, characterized in that, The acquisition of the first execution cost corresponding to the current round of dialogue task being executed by the main agent includes: The input cost required to obtain the input content in this round of dialogue task; Predict the scale of dialogue noise generated when the main agent performs the current round of dialogue task, and the number of interaction rounds the main agent will continue to interact after the current round of dialogue task is completed; The product of the input cost, the dialogue noise level, and the number of interaction rounds is determined as the first execution cost.

3. The method according to claim 1, characterized in that, The step of obtaining the first occupancy rate of the preset model context space after the main agent executes the current round of dialogue task includes: Predict the scale of dialogue noise generated when the main agent performs the current round of dialogue task; Obtain the character size of the historical dialogue records stored in the main intelligent agent; Calculate the sum of the dialogue noise scale and the character scale to obtain the first storage scale after the main agent processes the current round of dialogue task; The ratio of the first storage size to the model context space is determined as the first occupancy rate.

4. The method according to claim 1, characterized in that, The acquisition of the second execution cost corresponding to the current round of dialogue task being executed by the sub-agent includes: The input cost required to obtain the input content in the current round of dialogue task, and the text size of the processing result text; Predict the number of interaction rounds the main agent will continue to interact after the completion of the current round of dialogue task; Based on the input cost, the text size, and the number of interaction rounds, calculate the second execution cost for the sub-agent to perform the current round of dialogue task.

5. The method according to claim 1, characterized in that, The step of obtaining the second occupancy rate of the model context space after the sub-agent sends the processing result text to the main agent includes: Obtain the character size of the historical dialogue records stored in the main intelligent agent; Calculate the sum of the text size and the character size of the processed result text to obtain the second storage size that the main agent needs to use when the sub-agent processes the current round of dialogue task; The ratio of the second storage size to the model context space is determined as the second occupancy rate.

6. The method according to claim 2 or 4, characterized in that, The input cost required to obtain the input content in the current round of dialogue includes: Retrieve the historical dialogue records stored in the main intelligent agent; Predict the cache hit rate of the input content matching the historical dialogue record; The input cost is calculated based on the cache hit ratio.

7. The method according to claim 1, characterized in that, The task evaluation parameters include the permission risk coefficient and response quality sensitivity during the execution of the current round of dialogue task; The step of calculating the agent's decision score based on the first execution cost, the second execution cost, the first occupancy rate, the second occupancy rate, and the task evaluation parameters includes: Calculate the cost difference between the first execution cost and the second execution cost, and the utilization rate difference between the first utilization rate and the second utilization rate; The initial decision score is obtained by weighted summation of the cost difference, the occupancy rate difference, the permission risk coefficient, and the response quality sensitivity. The agent's decision score is obtained by subtracting the preset isolation score corresponding to the preset isolation cost required for the sub-agent to perform the current round of dialogue task from the initial decision score.

8. The method according to claim 1, characterized in that, The step of determining the target agent for performing the current round of dialogue task from the main agent and the sub-agents based on the agent's decision score includes: Generate the task boundary determination result for the current round of dialogue; the task boundary determination result includes a first result indicating that the current round of dialogue task needs to complete reasoning based on the historical dialogue records stored in the main agent, and a second result indicating that the current round of dialogue task does not need to complete reasoning based on the historical dialogue records; If the agent's decision score is less than a preset score threshold, and / or the task boundary determination result is the first result, then the main agent is determined as the target agent; If the agent's decision score is greater than or equal to a preset score threshold, and the task boundary determination result is the second result, then the sub-agent is determined as the target agent.

9. The method according to any one of claims 1-5, 7, or 8, characterized in that, The task evaluation parameters include the permission risk coefficient during the execution of the current round of dialogue task; After determining the target agent for performing the current round of dialogue task from the main agent and the sub-agents based on the agent's decision score, the method further includes: If the target intelligent agent is the sub-intelligent agent, then when the permission risk coefficient is greater than the preset risk threshold, a preset restricted sub-intelligent agent is used to handle the current round of dialogue task; the restricted sub-intelligent agent is executed in an isolated operating environment with preset safe operating boundaries; If the target agent is the sub-agent, then when the permission risk coefficient is less than or equal to the preset risk threshold, the current round of dialogue task is handled by a preset digest sub-agent; the operating environment of the digest sub-agent does not have the preset security operating boundary.

10. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the method as described in any one of claims 1 to 9.