A method, apparatus, and storage medium for executing a timed task.
By generating session identifiers, constructing session requests, and reading streaming responses line by line in the scheduling platform, the bridging problem between the scheduling platform and the agent's streaming interface is solved, ensuring the integrity of task results and the robustness of the execution process, and guaranteeing the traceability of call records.
Patent Information
- Application Number
- CN202611468247.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-09-20
- Publication Date
- 2026-11-17
AI Technical Summary
Existing technologies struggle to effectively bridge the scheduling platform and the intelligent agent's streaming interface in unattended, timed execution scenarios, resulting in incomplete task results, unstable execution processes, and untraceable call records.
By generating session identifiers in the scheduling platform, constructing session requests and initiating streaming session requests, reading streaming responses line by line, differentiating exception handling by stage, and using a content buffer to save results, the integrity of task results and the robustness of the execution process are ensured.
It ensures the integrity of task results, the robustness of the execution process, and the traceability of call records in unattended scenarios, avoiding content loss and resource waste.
Smart Images

Figure CN123114696A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of artificial intelligence technology, and in particular to a method, apparatus and storage medium for executing timed tasks. Background Technology
[0002] With the maturity of large language model technology, intelligent agents have taken on a large number of repetitive tasks that were originally done manually in scenarios such as data analysis, report generation, document review, and system inspection. Users expect these tasks to be completed automatically on time without human intervention, which requires the integration of timed scheduling capabilities with the ability to drive dialogue with intelligent agents using natural language.
[0003] The existing practices can be broadly divided into two categories: one is to use a mature distributed task scheduling framework, in which the scheduling center wakes up the executor at the trigger time according to the Cron expression, the executor runs the pre-compiled code logic and sends back the synchronous return value; the other is to attach a simple timing function to the AI platform, and call the dialogue interface once when the time comes.
[0004] However, the above solutions have significant limitations in practical applications. Traditional distributed scheduling frameworks are mainly designed for short-cycle synchronous request-response models, while intelligent agent dialogue typically relies on long-connection-based streaming output mechanisms (such as SSE). There is a natural gap between the two in terms of data flow and underlying communication protocols: the scheduler cannot construct session requests with session identifiers, encoding, and signatures as agreed, nor can it obtain the dynamic content continuously generated by the model completely and robustly. Reading in a request-response manner often only yields the first fragment or even empty content. On the other hand, although the platform's built-in simple timing function has established the call chain, it lacks the ability to manage anomalies for the characteristics of large language model inference: its retry strategy does not distinguish between the stages of anomaly occurrence. Instantaneous jitter when the connection has not yet been established is directly judged as failure, while cases where the model has already output a large amount of content and only interrupts at the end are judged as failures and restarted, discarding valid results and wasting computing power. At the same time, multiple executions and multiple retries often reuse the same set of session identifiers, and historical records are mixed together, making it difficult to meet the business-level requirements for independent backtracking and auditing of the automated task execution process.
[0005] Therefore, how to construct an execution mechanism that can effectively bridge the scheduling platform and the intelligent agent's streaming interface in unattended timed execution scenarios, while taking into account the integrity of task results, the robustness of the execution process, and the traceability of call records, has become an urgent problem to be solved in this field. Summary of the Invention
[0006] In view of this, embodiments of this application provide a method, apparatus, and storage medium for executing timed tasks, so as to at least partially solve the above problems.
[0007] In a first aspect, embodiments of this application provide a method for executing a scheduled task, comprising: Obtain the triggering rules and execution parameters of the scheduled task, wherein the execution parameters include the agent identifier and execution instructions; The execution is triggered at the triggering time indicated by the triggering rule through the scheduling platform, the execution parameters are parsed and a session identifier for this execution is generated; A session request is constructed based on the session identifier, the agent identifier, and the execution instruction, and a streaming session request is initiated to the agent backend based on the session request; The system receives a streaming response returned in response to the streaming session request. When the response status of the streaming response is successful, it reads the streaming response line by line, removes the data prefix from the lines that begin with a data prefix, and parses them into event objects. When the event type of the event object is a message event, it appends the text content of the event object to the content buffer. When the event type is an end event, it marks the end of the streaming response reception. If an exception occurs during the initiation of the streaming session request and the line-by-line reading process, the reception of the streaming response is stopped, and the exceptions occurring during the execution of the streaming session request are handled according to the stage at which the exception occurs: if the exception is a connection exception occurring during the connection establishment stage, the streaming session request is re-initiated after a delay, and the session identifier is regenerated before each re-initiation until the number of retries reaches a preset limit; if the exception is a transmission interruption exception occurring after the connection is established, it is treated as a successful execution if the content buffer is not empty; if the response status of the streaming response is unsuccessful or the response content is empty, the execution is determined to have failed, and the streaming session request is not re-initiated. When the streaming response is marked as received and the content buffer is not empty, the execution is determined to be successful, and the content in the content buffer is reported to the scheduling platform.
[0008] Secondly, based on the scheduled task execution method described in the first aspect of this application, this application embodiment also provides a scheduled task execution device, including a parameter acquisition module, a request construction module, a response collection module, an exception handling module, and a result reporting module, each module being used to implement the corresponding steps in the method described in the first aspect of this application.
[0009] Thirdly, embodiments of this application also provide a computer storage medium storing computer-executable instructions, which, when executed, implement any of the timed task execution methods described in the first aspect of this application.
[0010] The above-described solution provided in this application connects the triggering capability of timed scheduling with the streaming dialogue capability of the intelligent agent to the same link: the scheduling platform is responsible for when to execute, and the execution side is responsible for translating the execution instruction into a streaming session request that conforms to the intelligent agent's backend protocol, enabling the scheduling framework, which could originally only run predefined code, to have the ability to drive the intelligent agent to work on a timed basis. Based on this, this application uses a content buffer as a link to connect the collection process of streaming responses with the exception handling process: reading text line by line and accumulating it according to event type prevents content loss due to fragmentation; handling exceptions according to their stages ensures that only truly recoverable exceptions are re-initiated, interruptions that have already acquired content are not completely overturned, and clearly invalid failures do not waste computing power; a new session identifier is used before each re-initiation, ensuring that each attempt forms an independent session record in the intelligent agent's backend. Therefore, this application simultaneously ensures the integrity of results, the effectiveness of retries, and the traceability of the process in unattended scenarios. Attached Figure Description
[0011] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in the embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings.
[0012] Figure 1 A schematic diagram illustrating the workflow of a scheduled task execution method provided in this application embodiment; Figure 2 A flowchart illustrating the process of obtaining the triggering rules and execution parameters of a scheduled task, provided in an embodiment of this application; Figure 3 A schematic diagram illustrating a process for reading and collecting content from a streaming response line by line, provided in an embodiment of this application; Figure 4 This is a schematic diagram of an anomaly classification processing method provided in an embodiment of this application; Figure 5 This is a schematic diagram of the structure of a timed task execution device provided in an embodiment of this application. Detailed Implementation
[0013] To enable those skilled in the art to better understand the technical solutions in the embodiments of this application, the technical solutions in the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art should fall within the protection scope of the embodiments of this application.
[0014] It should be understood that the steps described in the method embodiments of this application may be performed in different orders and / or in parallel. Furthermore, the method embodiments may include additional steps and / or omit the steps shown. The scope of this application is not limited in this respect.
[0015] For ease of understanding, a brief explanation of some of the terms that appear repeatedly in the embodiments of this application is provided below: An intelligent agent is a conversational service unit that uses a large language model as its reasoning kernel and encapsulates specific prompts, a knowledge base, and tool invocation capabilities. Users give instructions to it in natural language, and it provides results in natural language. The intelligent agent backend refers to the server on which the intelligent agent resides. It provides a conversational interface to the outside world and is responsible for request decryption, intelligent agent routing, and streaming reasoning of the large model.
[0016] Streaming response refers to a response method in which the server continuously pushes data fragments in batches during the content generation process. In the embodiment of this application, the streaming response is carried by the SSE (Server-Sent Events) protocol. Its messages are organized in line units, and the lines carrying data are uniformly prefixed with the data prefix "data:". A complete response is split into several such lines and arrives one after another.
[0017] A scheduling platform is a service responsible for storing task definitions, calculating the next trigger time according to trigger rules, and triggering task execution at that time. In specific implementations, it can consist of two parts: a scheduling center and an executor. The scheduling center is responsible for adding, deleting, modifying, and querying tasks and for scheduling calculations, while the executor is responsible for running the task logic. The two interact through remote calls. In this embodiment, the side that actually undertakes the task logic is collectively referred to as the execution side. A content buffer is a variable string object used to temporarily store and concatenate the text content of a streaming response in the order of arrival.
[0018] This application provides a method for executing a scheduled task, such as... Figure 1 As shown, Figure 1 This paper illustrates a flowchart of a method for executing a timed task according to an embodiment of this application, including: Step S101: Obtain the triggering rules and execution parameters of the scheduled task. The execution parameters include an agent identifier and an execution instruction. In the actual application scenario of this application embodiment, for a scheduled task to be established, two things must be answered: when to do it and what to do. The triggering rules answer the former, and the execution parameters answer the latter. The reason why this application embodiment explicitly specifies the content of the execution parameters as including the agent identifier and the execution instruction at this step is that the object scheduled in this application embodiment is different from that of traditional scheduled tasks: the execution object of a traditional scheduled task is a piece of code that has been pre-written and compiled into the executor, which can be specified by the name of a task processor; while the execution object of this application embodiment is a dialogue with an agent, which is determined by "which agent to find" and "what to say to it", and both are indispensable. Among them, the agent identifier is used to uniquely locate an agent in the agent backend, and the execution instruction is a task content described in natural language, such as "query the summary of the net profit of all customers yesterday and list the top ten in descending order". Through this step, the scheduling object of the scheduled task changes from a piece of code to an agent plus a natural language instruction, and business personnel can add scheduled tasks without development.
[0019] Optionally, in one implementation of this application embodiment, step S101 can be completed by the front-end task configuration interface in conjunction with the scheduling platform. That is, the user fills in the task name, selects the intelligent agent, writes the execution instruction, selects the triggering rule, and then submits and saves the information on the interface. Figure 2 As shown, Figure 2 This application provides a flowchart illustrating the process of obtaining triggering rules and execution parameters for a scheduled task. Step S101 specifically includes: Step S1011: Determine the type of the triggering rule. The triggering rule includes a timed triggering mode and a fixed interval mode. The timed triggering mode refers to a task executing at a fixed time each day, week, or month, or executing only once at a specified time, described internally by a time expression (Cron expression) within the scheduling platform. The fixed interval mode refers to a task executing once every fixed interval after startup, described internally by seconds within the scheduling platform. These two modes are retained and determined here because their corresponding business requirements are different: "Publishing yesterday's daily business report at 8 AM every day" is a typical timed trigger, while "Checking the system status every two hours" is a typical fixed interval. If only one is provided, users would have to awkwardly try to achieve the other's meaning. In practice, users switch between the two modes via a drop-down list, and the interface dynamically displays the configuration controls corresponding to that mode, ensuring that the subsequent two branches only present input items related to the current mode.
[0020] Step S1012: When the triggering rule is the timed triggering mode, a time expression is generated according to the selected preset cycle template and execution time. The preset cycle template includes daily, weekly, monthly, and once-only options. In specific implementation, the interface displays these four templates as side-by-side buttons. The user first selects one to determine the cycle granularity, and the interface then displays a time selection control matching that granularity: selecting daily only requires specifying the hour and minute; selecting weekly adds the day of the week selection; selecting monthly adds the date selection; and selecting once-only provides a complete date and time selection. After the user selects, the system automatically assembles the corresponding time expression according to the selected preset cycle template and execution time. For example, 9:30 AM is assembled as "0 30 9". The reason why users are not allowed to directly write time expressions is that the field order and wildcard meanings are very difficult for business users to grasp. If one position is written incorrectly, the task will be executed at a completely unexpected time.
[0021] Step S1013: When the triggering rule is the fixed interval mode, the interval value is converted into seconds according to the conversion factor corresponding to the time unit. The time unit includes minutes, hours, and days, with conversion factors of 60, 3600, and 86400 respectively. When the time unit is minutes, the interval value is not less than a preset minimum interval value, which is exemplarily set to 30 minutes. This conversion is necessary because the scheduling platform only recognizes seconds as the fixed interval, while users describe task rhythm as "once every two hours" or "once a day." Asking users to manually convert 2 hours to 7200 seconds is prone to errors, such as adding or omitting a zero, and makes the numbers difficult for users to understand during editing. Setting a minimum interval value for minutes is to consider that a single intelligent agent dialogue consumes a considerable amount of inference computing power and typically takes between seconds and minutes. Too short an interval could result in the next triggering before the previous one has finished. Setting a minimum limit avoids such meaningless high-frequency triggering from the configuration source.
[0022] Step S1014: Encapsulate the user identifier, the agent identifier, the execution instruction, the application identifier, and the agent business identifier into execution parameters in JSON format. The user identifier indicates which account the current dialogue belongs to on the agent's backend, determining the agent's visible data range and permissions. The application identifier and agent business identifier identify the initiating application and the agent's business line, used by the agent's backend for routing and authentication. After encapsulation, the execution parameters, along with the time expression or number of seconds obtained in step S1012 or S1013, are submitted to the scheduling platform. The scheduling platform stores them separately in its database: the execution parameters are stored in the task's execution parameter field, and the triggering rules are stored in the scheduling platform's own scheduling field; the two are not mixed. In this embodiment, the execution parameters are consolidated into the aforementioned five business fields, and the trigger type field and scheduling configuration field of the triggering rule are not included. This is because the execution parameters are stored as strings in the scheduling platform and passed along with the task to the execution side; the more fields there are, the greater the exposure. Information describing when execution, such as trigger type and scheduling configuration, is already stored in independent fields by the scheduling platform and used by it; the execution side does not need them when constructing the session request. Including these in the execution parameters would not only create two copies of the same configuration, leading to inconsistencies during editing, but also cause the parsing logic of the execution parameters to be repeatedly modified as the scheduling configuration changes.
[0023] Step S1015: When editing the scheduled task, the stored time expression or the number of seconds is reverse-parsed to restore the corresponding preset cycle template and execution time, or the corresponding time unit and interval value, and then displayed. Specifically, the stored time expression is parsed segment by segment, and the preset cycle template and execution time to which it belongs are deduced from the value of each segment. Then, the template button is set to the selected state, and the time control is filled back with the corresponding value. The stored number of seconds is reverse-converted using the same conversion factor to restore the time unit and interval value initially entered by the user and then displayed. This embodiment of the application adds reverse parsing here because forward generation alone is not enough. When the user edits the task, they will see a string of naked expressions or an unfamiliar number of seconds, which they cannot understand and dare not modify, so they can only delete and rebuild. Through the bidirectional mapping of forward generation and reverse parsing, the user sees a visual template and time in both the configuration and editing stages. The time expression and the number of seconds only circulate within the system, thus greatly reducing the probability of configuration errors.
[0024] Step S102: At the trigger time indicated by the triggering rule, the current execution is triggered through the scheduling platform. The execution parameters are parsed and a session identifier for this execution is generated. After the task is saved, it enters a waiting-to-trigger state. The scheduling platform calculates the next trigger time according to the triggering rule. When the time arrives, the current execution is triggered, and the execution parameters are transmitted to the execution side. The execution side first parses the JSON-formatted string of execution parameters into an object and extracts the agent identifier, execution instruction, user identifier, application identifier, and agent business identifier for later use. In specific implementation, triggering and execution are placed on the scheduling center and the executor respectively. On the one hand, this allows the scheduling center to focus on scheduling calculations and not be held back by time-consuming dialogue requests. On the other hand, it facilitates horizontal expansion of concurrency capabilities by adding executor nodes.
[0025] The reason for generating a session identifier for this execution instead of using an existing one in this step is that the agent's backend organizes context and history on a session-by-session basis: multiple rounds of question-and-answer under the same session identifier are considered a continuous dialogue, and the model references previous rounds during inference. However, scheduled tasks are executed unattended and periodically. If daily executions are all under the same session identifier, after a month, this session will accumulate thirty rounds of unrelated question-and-answer exchanges, polluting the model context, causing later outputs to be interfered with by earlier irrelevant content, and making it impossible for maintenance personnel to associate a particular output with a specific trigger. This embodiment generates a session identifier for each execution upon triggering, ensuring that each execution in the agent's backend is a clean and independent new session. The context between each execution does not interfere with each other, and the execution record is naturally traceable. In specific implementation, the session identifier can be generated using a universally unique identifier to ensure that it is not repeated globally.
[0026] Specifically, in one optional implementation of this application embodiment, the session identifier includes a dialogue identifier, a connection identifier, and a chat identifier, which correspond to the three fields `conversation_id`, `session_id`, and `chat_id` respectively in the interface protocol of the intelligent agent backend. The reason for using three identifiers instead of one is that the intelligent agent backend aggregates requests at different levels: the dialogue identifier is used to group multiple rounds of questions and answers belonging to the same dialogue together, serving as the primary key for historical record retrieval; the connection identifier is used to identify the currently established session connection, serving as the basis for locating the link during streaming push; and the chat identifier is granular down to a single question and answer, representing the smallest unit for locating a specific response. All three are generated and carried together, enabling the current execution to be retrieved independently at each of these three levels.
[0027] Step S103: Construct a session request based on the session identifier, the agent identifier, and the execution instruction, and initiate a streaming session request to the agent backend according to the session request. At this point, the execution side already has three types of information: "who to talk to," "what to say," and "what to call this conversation." This step assembles these into a request that the agent backend recognizes. The reason for constructing such a complete request instead of simply issuing a normal call is that the agent backend's session interface is usually not a bare interface: for security and tenant isolation needs, business parameters often need to be encoded and then encapsulated, and an outer layer needs to be added with application information, timestamps, and signatures for the server to verify the source and timeliness. Traditional scheduling frameworks' executors do not have this construction capability, which is precisely the crux of the problem in the background technology where scheduling frameworks cannot directly drive agents.
[0028] Specifically, in an optional implementation of this application embodiment, the construction of the session request includes: assembling the application identifier, the user identifier, the agent identifier, the session identifier, and the new session indication into inner business parameters (such as innerDatagram); encoding the inner business parameters with metadata to obtain an encoded message; constructing the request body of the session request using the encoded message, a timestamp, and a signature generated based on the encoded message. The outermost request body may also specifically include fields such as App-Info, zip_code, and encrypt_code to meet the security verification specifications of the agent backend. The new session indication is used to inform the agent backend that this request should start a new session rather than continue an existing session. It works in conjunction with the generation of the session identifier for this execution in step S102 to jointly ensure session isolation between executions. Metadata refers to information related to this call but not belonging to business semantics, such as session type and source channel. In specific implementation, the above encoding can use Base64 encoding, which means re-expressing the byte sequence after serializing the inner business parameters according to the rule of converting every three bytes into four printable characters. This ensures that characters such as newlines and quotation marks that may appear will not disrupt the structure of the outer message, while also preventing the business parameters from being directly exposed in a fully readable form on the transmission link. The signature is calculated based on the encoded message and the agreed key, so that the intelligent agent backend can verify that the request indeed comes from a legitimate caller and has not been tampered with during transmission. After the request body is constructed, the execution side declares in the request header that it expects to receive a response of the event stream type and sends a request, so that the server continuously pushes the generated results in a streaming manner. This request is the streaming session request described in the embodiments of this application. At this point, the scheduling platform has the complete capability to complete a compliant dialogue call with the intelligent agent backend.
[0029] Step S104: Receive the streaming response returned by the corresponding streaming session request. When the response status of the streaming response is successful, read the streaming response returned by the streaming session request line by line. Remove the data prefix from the lines starting with the data prefix and parse them into event objects. If the event type of the event object is a message event, append the text content in the event object to the content buffer. If the event type is an end event, mark the end of the streaming response reception. After the streaming session request is sent, the real challenge lies in how to completely receive the returned content. The streaming response is not returned all at once after the server has generated everything. Instead, the model pushes one line at a time as it produces a small piece of text, and the connection is closed only after the generation is complete. If the approach of reading the response body once is used, what is often read is only the first fragment, or even empty content because the response body is not ready. This is the main direct reason for the incomplete task results described in the background technology of this application. Therefore, this step reads the streaming response line by line, receiving the content segment by segment as it arrives, appending the part belonging to the main text to the content buffer according to the event type, and splicing it back into a complete text. At the same time, the end event is used as the basis for terminating the reading.
[0030] It should be noted that, in this embodiment of the application, marking the end of the streaming response reception means setting a reception end flag on the execution side for this streaming response, indicating that the server has declared the generation complete and the execution side no longer needs to read; this flag, like the content buffer, is an intermediate state maintained by the execution side for this execution. The former records when the reception ends normally, and the latter records what content was received. Together, they constitute the common basis for subsequent step S105 to determine whether content has been acquired and step S106 to determine whether the execution was successful. Specifically, as Figure 3 As shown, Figure 3 This application provides a schematic diagram of a process for reading and collecting content from a streaming response line by line, wherein step S104 includes: Step S1041: Read the streaming response line by line using a buffered character reader. In this embodiment, the buffered character reader refers to a reader that adds a memory buffer on top of the underlying byte stream and segments the data line by line. In specific implementation, it can be implemented by BufferedReader. Using line-by-line reading instead of reading all at once matches the message organization method of pushing streaming responses line by line, and also allows the content to be received immediately as fragments arrive, without having to wait for the entire response body to be ready.
[0031] In step S1042, if the read line is empty or does not begin with the data prefix, skip the line and continue reading the next line. In addition to the lines carrying data, the SSE message also contains empty lines used to maintain connections, as well as other lines such as comments and event names. These lines do not carry business data. Skipping them and returning to step S1041 to continue reading can avoid unnecessary parsing of invalid lines and throwing parsing exceptions.
[0032] Step S1043: Remove the data prefix from the rows that begin with the data prefix and parse them into event objects. For the valid data rows retained after filtering in step S1042, remove the "data:" prefix at the beginning of the row and parse the remaining part into event objects in JSON format. This event object refers to a structured object that carries a single event, which at least contains an event type field indicating the category of this event and a content field carrying the main text.
[0033] Step S1044: When the event object contains nested data message fields, the content of the data message fields is used as the data source; otherwise, the outer content of the event object is used as the data source. The data source refers to the layer of structure in this event that actually carries the event type and text content. The reason for this distinction in this embodiment is that the intelligent agent backend often does not have only one form in actual deployment: intelligent agents running on a workflow orchestration engine have their shards wrapped with another layer of data message fields (such as datagrams), with the entire business content embedded inside; while intelligent agents directly output after gateway encapsulation have their business content on the outer layer. Determining the data source by taking the nested layer if there is nesting and the outer layer if there is no nesting allows the same parsing logic to adapt to different forms of intelligent agent backends. Accordingly, when retrieving the text content from the data source, it is also compatible in one of the following ways: when the data source is text, the data source is used as the text content; when the data source contains a candidate result array (such as a choices array), the text carried by the incremental content field in the elements of the candidate result array is used as the text content; when the data source contains a content field (such as a content field), the text carried by the content field is used as the text content. If only one format is used for value retrieval, once the agent is changed or the orchestration engine is upgraded in the backend, an empty string will be retrieved while the stream itself continues to be pushed normally. In unattended scenarios, this type of problem is often not noticed until the user discovers that the result is empty.
[0034] Step S1045: When the event type of the event object is a message-type event, the text content of the event object is appended to the content buffer. The message-type events include message events and running events, which are represented in the message as "message" and "running" respectively, with the event type field value being "running". In this embodiment, running events are also classified as message-type events at this stage because workflow-based agents will also push phased outputs using this event during intermediate node execution. This content is part of the results the user expects to see and should not be discarded. After appending, return to step S1041 to continue reading the next line. Furthermore, when the event type of the event object is neither a message-type event nor a termination-type event, the text content carried by the event object is also appended to the content buffer. This is a fallback approach for event types outside the agreed scope, ensuring that more is added rather than omitted, to prevent content loss when the agent adds new event types at the backend.
[0035] Step S1046: When the event type is an end-of-stream event, mark the end of the streaming response reception. End-of-stream events include stop events, workflow completion events, and end events, represented in the message as stop, workflow_finished, and end, respectively, with the event type field value being stop, workflow_finished, and end. All three events are categorized as end-of-stream events because the event names used by different types of intelligent agents to declare the end are not uniform; recognizing only one would cause the reading loop to continue idling after the stream has finished, until a timeout occurs. Marking the end of the streaming response reception terminates the reading loop and proceeds to step S106 to determine whether the execution was successful.
[0036] Step S105: When an exception occurs during the initiation of the streaming session request and the line-by-line reading process, stop receiving the streaming response, and handle the exceptions that occur during the execution of the streaming session request according to the stage at which the exception occurs: If the exception is a connection exception during the connection establishment phase, the streaming session request is re-initiated after a delay, and the session identifier is regenerated before each re-initiation until the number of retries reaches a preset limit; if the exception is a transmission interruption exception after connection establishment, it is treated as a successful execution if the content buffer is not empty; if the response status of the streaming response is unsuccessful or the response content is empty, the execution is determined to have failed, and the streaming session request is not re-initiated. Steps S103 to S104 describe the link when everything is going smoothly. However, the scheduled task is executed unattended, and no one is there to trigger a retry for any jitter on the link. Therefore, the exception handling strategy directly determines whether this method is usable in a real environment. It should be noted that this step is not another main process executed in parallel with step S104, but rather an interruption to the initiation process of step S103 and the line-by-line reading process of step S104: this step is only triggered when an exception actually occurs in the above two processes. After triggering, the reception of the streaming response is stopped, and the handling method is selected according to the stage at which the exception occurred; if no exception occurs in the above two processes, this step is not executed, and the process directly proceeds to step S106 after the reading loop terminates in step S104. This embodiment of the application does not adopt a uniform retry strategy here, but handles the exception separately according to the stage at which it occurs. The judgment criteria are whether re-initiating might bring different results and whether the already generated content still has value. Figure 4 As shown, Figure 4 This is a schematic diagram of an anomaly classification processing method provided in an embodiment of this application. Step S105 specifically includes: Step S1051: Determine the stage at which an exception occurs during the execution of the streaming session request. The stage is divided by whether a connection has been established: if the connection has not yet been established, it is the connection establishment stage; if the connection has been established and data reception has begun, it is the post-connection establishment stage. Furthermore, if both the connection and response are normal, but the server explicitly gives an error or an empty result, it is classified as a response exception. The classification is based on stage rather than exception name because exceptions with different names within the same stage are consistent in recoverability. Dividing by stage ensures stable classification and prevents it from becoming invalid due to changes in the underlying communication library.
[0037] Step S1052: The exception is a connection exception occurring during the connection establishment phase. After a delay, the streaming session request is re-initiated, and the session identifier is regenerated before each re-initiation until the number of retries reaches a preset limit. In specific implementations, the connection exception manifests as connection rejection, target unreachability, or connection establishment timeout, such as throwing a ConnectException or HttpConnectTimeoutException. Its cause is usually instantaneous. Network jitter, the agent backend undergoing a rolling restart, and instantaneous gateway overload all share the characteristic that the model side has not yet started inference. Re-initiating once is likely to succeed without causing any redundant calculations. Therefore, exceptions in this phase are treated as re-initiable. The preset limit is exemplarily set to 3 times in specific implementations. This value balances the recovery probability of instantaneous faults with the duration of resource occupation during fault persistence. When the number of retries reaches the preset limit, it indicates that the fault is indeed ongoing. At this point, stopping re-initiation and determining that the current execution has failed is more beneficial than infinite retries in releasing execution-side resources and exposing the problem as early as possible.
[0038] Specifically, in one optional implementation of this application embodiment, the step of re-initiating the streaming session request after a delay includes: waiting for a delay duration positively correlated with the number of retries, such that the delay duration before the i-th re-initiation is greater than the delay duration before the (i-1)-th re-initiation. An incremental rather than a fixed delay duration is used because if the agent's backend is restarting or overloaded, frequent, equally spaced retries will only further strain it at its most vulnerable moment, thus prolonging the recovery time; by progressively lengthening the intervals, the first retrieval can quickly cover the extremely brief jitter, while subsequent retries provide the server with a true recovery window. The session identifier regenerated before each re-initiation is different from the session identifier used in the previously initiated streaming session request. This is to avoid the re-initiated request and the previous request being mixed up in the agent's backend: although the connection has not been established, in some implementations the server may have already pre-built a record for this session identifier. If the same session identifier is used, a single execution will correspond to multiple incomplete session records, which cannot be distinguished from each other. After using a new session identifier, each attempt is an independent record in the backend. Combined with the execution log written in step S106, it can be clearly seen how many times the execution was attempted and which session record each attempt corresponds to. After re-initiation, return to step S1051 to continue the stage-by-stage judgment.
[0039] Step S1053: The exception is a transmission interruption exception that occurs after the connection is established. If the content buffer is not empty, it is treated as a successful execution. The transmission interruption exception refers to a situation where the connection has been established and the server has started pushing data, but the stream is interrupted midway or at the end. In specific implementations, this manifests as an input / output exception (e.g., IOException) thrown when reading the input stream. Here, if the content buffer is not empty, it is treated as a successful execution without re-initiating because the model has already completed most or even all of the inference and pushed out the results. Interruptions often only occur at the end of the connection closure process. If this situation is judged as a failure and re-executed, on the one hand, a valid result that has already been produced is wasted, and on the other hand, the agent's backend has to re-infer the same instruction, which is a pure waste in scenarios where billing is based on call volume or computing power. Correspondingly, if the content buffer is empty, it means that nothing has actually been obtained, and judging this execution as a failure is consistent with the facts. This step complements the design of using the content buffer to receive fragments in step S104—because the content is stored as it arrives, existing content is available even during an interruption.
[0040] Step S1054: If the response status of the streaming response is unsuccessful or the response content is empty, the execution is determined to have failed, and the streaming session request is not re-initiated. An unsuccessful response status indicates that the agent backend has explicitly given a rejection or error response, such as signature verification failure, agent identifier non-existent, the current user not having permission to call the agent, or an HTTP response status code other than 200. An empty response content indicates that the connection and response are normal, but the server has not returned any usable message body. The common point is that the problem lies in the request itself or the configuration itself, and the request content will not change when re-initiated. Therefore, re-initiating will always yield the same result; the only effect is turning one invalid call into multiple invalid calls. Directly determining the execution to have failed and recording the reason allows the problem to be exposed to the user as soon as possible for configuration correction, rather than masking the problem with retries.
[0041] Furthermore, in an optional implementation of this application embodiment, the method further includes: configuring a request timeout duration for the streaming session request, and handling the case where a connection cannot be established with the agent backend within the request timeout duration as a connection exception occurring during the connection establishment phase; in the event of other exceptions besides the above three situations, not re-initiating the streaming session request, but directly determining that the current execution has failed and recording the exception information. The request timeout duration is exemplarily set to 10 minutes in specific implementations, mainly considering that when the agent processes complex instructions, it may require multiple rounds of tool calls and retrievals, with the overall time consumption reaching several minutes. Setting the timeout too short will misjudge normal long-time tasks as failures; the connection establishment timeout is classified as a connection exception and processed together because it and connection rejection are both due to the inability to connect, and the handling method should be consistent. For other exceptions such as message parsing errors and execution-side local resource errors, the causes are unpredictable and the benefits of re-initiating are unassessable. By uniformly adopting the handling method of not retrying, directly failing and fully recording, the exception branches can be completely closed logically, so that the execution thread will not be suspended due to a certain type of exception not being covered.
[0042] Step S106: When the streaming response is marked as received and the content buffer is not empty, the execution is determined to be successful, and the content in the content buffer is reported to the scheduling platform. This step uses parallel judgment conditions instead of only one to cover both normal and abnormal termination methods: In normal termination, the server pushes an end-of-stream event, and the stream end is marked in step S1046. At this time, regardless of the amount of content, the execution should be determined to be successful; In abnormal termination, the connection may be interrupted before the end-of-stream event arrives, and the stream end mark is never set, but the content buffer already contains the text produced by the model. If a stream end mark is mechanically required, a usable result will be judged as a failure. Conversely, if the stream end is neither marked nor the content buffer is empty, it means that the call did not produce any result, and the determination of execution failure is consistent with the fact. This judgment criterion is completely consistent with the handling of transmission interruption exceptions in step S1053. Both ensure that content is not discarded as long as it is received.
[0043] Specifically, in an optional implementation of this application embodiment, reporting the content in the content buffer to the scheduling platform includes: when the execution is successful, calling the success callback interface of the scheduling platform and carrying the content in the content buffer and the session identifier in the callback parameters; when the execution fails, calling the failure callback interface of the scheduling platform and carrying the failure reason in the callback parameters, the failure reason including the stage at which the exception occurred; and writing the session identifier used in this execution, the stage at which the exception occurred, and the number of retries into the execution log of the scheduling platform. Carrying the session identifier in the callback parameters is to establish a mutually referential link between the task execution record of the scheduling platform and the session record of the agent backend—when a user has questions about the result of a certain execution, they can directly retrieve the complete dialogue process corresponding to the agent backend based on the session identifier of that execution, without having to guess based on time; writing the stage at which the exception occurred and the number of retries into the execution log together enables the troubleshooting work to distinguish between two completely different types of faults: "failed to connect after three attempts" and "connected but the backend rejected the connection." The former should be checked for network and agent backend availability, while the latter should be checked for task configuration and permissions. Thus, a closed loop is formed, encompassing task configuration, trigger execution, request construction, streaming collection, exception handling, and result reporting, with each step being traceable.
[0044] The following describes several optional extended implementations of the method described in the embodiments of this application.
[0045] Optionally, in one implementation of this application embodiment, the method further includes: after determining that the execution is successful, pushing the content in the content buffer to the recipient corresponding to the user identifier according to the push channel configured by the scheduled task; and saving the session identifier of this execution in the task execution record so as to review the complete dialogue process corresponding to this execution based on the session identifier. The push channel can be an internal message, email, or a message interface provided by an enterprise's internal instant messaging tool. The value of a scheduled task ultimately lies in the fact that the result is visible. If the result simply lies quietly in the execution log, and users still need to actively log in every day to check it, the meaning of unattended operation is diminished. Actively delivering the successfully collected content to the user according to the configured channel, while retaining the entry point to review the complete dialogue based on the session identifier, truly forms a closed loop of automatic execution at the designated time, automatic delivery of results, and readily traceable process. This implementation reuses the content and session identifier already reported in step S106, resulting in low implementation costs and significant user impact.
[0046] Optionally, in another implementation of this application embodiment, the method further includes: at the triggering time indicated by the triggering rule, if the previous execution of the same timed task has not yet ended, processing the current trigger according to the concurrency strategy configured for the timed task, wherein the concurrency strategy includes either discarding the current trigger or queuing the current trigger; and, during the process of reading the streaming response line by line, if no new data line is read within a preset idle time, actively closing the connection and handling the transmission interruption exception as described above. This addresses the characteristic of uncertain time consumption in intelligent agent dialogue: a dialogue involving multiple rounds of retrieval and tool calls may take several minutes, while the trigger interval is fixed. Once the execution time exceeds the trigger interval, multiple executions of the same task will overlap, causing duplicate occupation of inference computing power and generating the same result multiple times. With the introduction of a concurrency strategy, users can choose to use the latest execution or queue the executions sequentially according to the nature of the task. Idle time detection is a supplement to transmission interruption judgment. In some cases, the connection is not actually broken, but the agent backend has been suspended and no longer pushes any new lines. In this case, the read loop will be blocked until the request times out, occupying the execution thread for nothing. Actively detecting idle time and handling it as a transmission interruption exception can not only release the thread in time, but also retain the received content by taking advantage of the existing judgment logic in this branch.
[0047] Optionally, in another implementation of this application embodiment, the method further includes: counting the number of times the same scheduled task is consecutively determined to have failed execution; when the number reaches a preset alarm threshold, pausing the subsequent triggering of the scheduled task and sending an alarm to the receiver corresponding to the user identifier. Response anomaly-type failures (such as an agent being taken offline or permissions being revoked) will not recover automatically until the configuration is corrected. If the task continues to be triggered day after day at the original pace, it is meaningless except for continuously generating invalid calls; pausing and issuing an alarm when consecutive failures reach the threshold can push the problem to the user as early as possible, while avoiding the long-term occupation of scheduling resources by invalid triggers.
[0048] Based on the scheduled task execution method provided in the above embodiments of this application, this application also provides a corresponding scheduled task execution device, such as... Figure 5 As shown, Figure 5 This is a schematic diagram of the structure of a timed task execution device 50 provided in an embodiment of this application. The timed task execution device 50 includes: The parameter acquisition module 501 is used to acquire the triggering rules and execution parameters of the scheduled task. The execution parameters include the agent identifier and the execution instruction. In specific implementation, this module is also used to provide a task configuration interface, generate a time expression according to the selected preset period template and execution time in the timed trigger mode, convert the interval value into seconds according to the conversion factor corresponding to the time unit in the fixed interval mode, and encapsulate the user identifier, agent identifier, execution instruction, application identifier and agent business identifier into execution parameters in JSON format and submit them to the scheduling platform. The request construction module 502 is used to trigger the execution through the scheduling platform at the trigger time indicated by the triggering rule, parse the execution parameters and generate a session identifier for the execution, construct a session request based on the session identifier, the agent identifier and the execution instruction, and initiate a streaming session request to the agent backend according to the session request. In specific implementation, the session identifier generated by this module includes a dialogue identifier, a connection identifier and a chat identifier, and the inner business parameters are Base64 encoded. After combining the metadata, it is encapsulated into an outermost request body containing application information, a timestamp and a signature, and the call is initiated in the form of a streaming HTTP request. The response collection module 503 is used to receive the streaming response returned by the corresponding streaming session request. When the response status of the streaming response is a success status, the module reads the streaming response returned by the streaming session request line by line, and parses the lines starting with a data prefix into event objects after removing the data prefix. When the event type of the event object is a message event, the text content in the event object is appended to the content buffer. When the event type is an end event, the module marks the end of the streaming response reception. In specific implementation, this module uses a buffered character reader to read the SSE stream line by line, which is compatible with flat format and nested data message format for extracting event data, and supports extracting text content from direct text, candidate result arrays, or content fields. An exception handling module 504 is used to stop receiving the streaming response when an exception occurs during the initiation of the streaming session request and the line-by-line reading process. The module handles the exceptions occurring during the execution of the streaming session request according to the stage at which the exception occurs: if the exception is a connection establishment stage, the streaming session request is re-initiated after a delay, and the session identifier is regenerated before each re-initiation until the number of retries reaches a preset limit; if the exception is a transmission interruption after connection establishment, it is treated as a successful execution if the content buffer is not empty; if the streaming response status is unsuccessful or the response content is empty, the execution is determined to have failed, and the streaming session request is not re-initiated. In specific implementation, this module waits for a delay duration positively correlated with the number of retries, regenerates the session identifier before each re-initiation, and classifies connection establishment timeouts as connection exceptions for processing. For other exceptions, the execution is directly determined to have failed, and the exception information is recorded. The result reporting module 505 is used to determine that the execution was successful when the streaming response is marked as received and the content buffer is not empty, and to report the content in the content buffer to the scheduling platform. In specific implementation, this module reports the result and the reason for failure by calling the success or failure callback interface of the scheduling platform, and records the complete execution process, including the session identifier and the number of retries, through the scheduling platform's log system.
[0049] The specific working process and technical effects of the above modules are consistent with the corresponding steps in the aforementioned method embodiments of this application, and will not be repeated here. It should be noted that the above modules are divided according to their functions. In specific implementation, the parameter acquisition module 501 can be deployed on the front-end display layer and the scheduling center side, the request construction module 502, the response collection module 503 and the exception handling module 504 can be deployed on the executor side, and the result reporting module 505 completes callback and log writing across the executor and the scheduling center; the modules can also be merged or further split, and this embodiment of the application does not limit this.
[0050] This application also provides a computer storage medium storing computer-executable instructions, which, when executed, implement any of the timed task execution methods described in the foregoing embodiments of this application.
[0051] Furthermore, this application also provides an electronic device, which includes one or more processors, a communication interface, a memory, and a communication bus. The processors, memory, and communication interface communicate with each other through the communication bus. The memory is used to store one or more programs. When the one or more programs are executed by the one or more processors, the one or more processors implement any of the timed task execution methods described in the foregoing embodiments of this application.
[0052] This application has now described specific embodiments of the subject matter. In some cases, the actions described in the claims can be performed in a different order and still achieve the desired result. Furthermore, the processes depicted in the drawings do not necessarily require a specific or sequential order to achieve the desired result. In some embodiments, multitasking and parallel processing can be advantageous.
[0053] Furthermore, this application also provides an electronic device, which includes one or more processors, a communication interface, a memory, and a communication bus. The processors, memory, and communication interface communicate with each other through the communication bus. The memory is used to store one or more programs. When the one or more programs are executed by the one or more processors, the one or more processors implement any of the timed task execution methods described in the foregoing embodiments of this application.
[0054] This application has now described specific embodiments of the subject matter. In some cases, the actions described in the claims can be performed in a different order and still achieve the desired result. Furthermore, the processes depicted in the drawings do not necessarily require a specific or sequential order to achieve the desired result. In some embodiments, multitasking and parallel processing can be advantageous.
[0055] In the 1990s, improvements to a technology could be clearly distinguished as either hardware improvements (e.g., improvements to the circuit structure of diodes, transistors, switches, etc.) or software improvements (improvements to the methodology). However, with technological advancements, many methodological improvements today can be considered direct improvements to the hardware circuit structure. Designers almost always obtain the corresponding hardware circuit structure by programming the improved methodology into the hardware circuit. Therefore, it cannot be said that a methodological improvement cannot be implemented using hardware physical modules. For example, a Programmable Logic Device (PLD) (such as a Field Programmable Gate Array (FPGA)) is such an integrated circuit whose logic function is determined by the user programming the device. Designers can program and "integrate" a digital system onto a PLD themselves, without needing chip manufacturers to design and manufacture dedicated integrated circuit chips. Furthermore, nowadays, instead of manually manufacturing integrated circuit chips, this programming is mostly implemented using "logic compiler" software. Similar to the software compiler used in program development, the original code before compilation must also be written in a specific programming language, called a Hardware Description Language (HDL). There are many HDLs, such as ABEL (Advanced Boolean Expression Language), AHDL (Altera Hardware Description Language), Confluence, CUPL (Cornell University Programming Language), HDCal, JHDL (Java Hardware Description Language), Lava, Lola, MyHDL, PALASM, and RHDL (Ruby Hardware Description Language). Currently, the most commonly used are VHDL (Very-High-Speed Integrated Circuit Hardware Description Language) and Verilog. Those skilled in the art should also understand that by simply performing some logic programming on the method flow using one of these hardware description languages and programming it into an integrated circuit, the hardware circuit implementing the logical method flow can be easily obtained.
[0056] The controller can be implemented in any suitable manner. For example, it can take the form of a microprocessor or processor and a computer-readable medium storing computer-readable program code (e.g., software or firmware) executable by the (micro)processor, logic gates, switches, application-specific integrated circuits (ASICs), programmable logic controllers, and embedded microcontrollers. Examples of controllers include, but are not limited to, the following microcontrollers: ARC 625D, Atmel AT91SAM, Microchip PIC18F26K20, and Silicon Labs C8051F320. A memory controller can also be implemented as part of the control logic of the memory. Those skilled in the art will also recognize that, in addition to implementing the controller in purely computer-readable program code form, the same functionality can be achieved by logically programming the method steps to make the controller take the form of logic gates, switches, application-specific integrated circuits, programmable logic controllers, and embedded microcontrollers. Therefore, such a controller can be considered a hardware component, and the means included therein for implementing various functions can also be considered as structures within the hardware component. Alternatively, the means for implementing various functions can be considered as both software modules implementing the method and structures within the hardware component.
[0057] The systems, devices, modules, or units described in the above embodiments can be implemented by computer chips or entities, or by products with certain functions. A typical implementation device is a computer. Specifically, a computer can be, for example, a personal computer, laptop computer, cellular phone, camera phone, smartphone, personal digital assistant, media player, navigation device, email device, game console, tablet computer, wearable device, or any combination of these devices.
[0058] For ease of description, the above devices are described separately by function as various units. Of course, in implementing this application, the functions of each unit can be implemented in one or more software and / or hardware.
[0059] It should also be noted that the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, method, article, or apparatus. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element.
[0060] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0061] This application can be described in the general context of computer-executable instructions that are executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc., that perform specific transactions or implement specific abstract data types. This application can also be practiced in distributed computing environments where transactions are performed by remote processing devices connected via a communication network. In distributed computing environments, program modules can reside in local and remote computer storage media, including storage devices.
[0062] The various embodiments in this specification are described in a progressive manner. Similar or identical parts between embodiments can be referred to interchangeably. Each embodiment focuses on describing the differences from other embodiments. In particular, the system embodiments are basically similar to the method embodiments, so the description is relatively simple; relevant parts can be referred to the descriptions in the method embodiments.
[0063] The above are merely embodiments of this application and are not intended to limit the scope of this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the scope of the claims of this application.
Claims
1. A method for executing a scheduled task, characterized in that, include: Obtain the triggering rules and execution parameters of the scheduled task, wherein the execution parameters include the agent identifier and execution instructions; The execution is triggered at the triggering time indicated by the triggering rule through the scheduling platform, the execution parameters are parsed and a session identifier for this execution is generated; A session request is constructed based on the session identifier, the agent identifier, and the execution instruction, and a streaming session request is initiated to the agent backend based on the session request; The system receives a streaming response returned in response to the streaming session request. When the response status of the streaming response is successful, it reads the streaming response line by line, removes the data prefix from the lines that begin with a data prefix, and parses them into event objects. When the event type of the event object is a message event, it appends the text content of the event object to the content buffer. When the event type is an end event, it marks the end of the streaming response reception. If an exception occurs during the initiation of the streaming session request and the line-by-line reading process, the reception of the streaming response is stopped, and the exceptions occurring during the execution of the streaming session request are handled according to the stage at which the exception occurs: If the exception is a connection exception occurring during the connection establishment phase, the streaming session request is re-initiated after a delay, and the session identifier is regenerated before each re-initiation until the number of retries reaches a preset limit; if the exception is a transmission interruption exception occurring after the connection is established, it is treated as a successful execution if the content buffer is not empty; if the response status of the streaming response is unsuccessful or the response content is empty, the execution is determined to have failed, and the streaming session request is not re-initiated. When the streaming response is marked as received and the content buffer is not empty, the execution is determined to be successful, and the content in the content buffer is reported to the scheduling platform.
2. The method for executing a timed task according to claim 1, characterized in that, The execution parameters are strings in JSON format, including user identifier, agent identifier, execution instruction, application identifier, and agent service identifier, but excluding the trigger type field and scheduling configuration field of the trigger rule.
3. The method for executing a timed task according to claim 1, characterized in that, The triggering rules include a timed triggering mode and a fixed interval mode; The triggering rules for obtaining the scheduled task include: When the triggering rule is the timed triggering mode, a time expression is generated according to the selected preset cycle template and execution time. The preset cycle template includes daily, weekly, monthly, and once-only execution. When the triggering rule is the fixed interval mode, the interval value is converted into seconds according to the conversion factor corresponding to the time unit. The time unit includes minutes, hours and days, and when the time unit is minutes, the interval value is not less than the preset minimum interval value. When editing the scheduled task, the stored time expression or number of seconds is reverse-parsed to restore the corresponding preset cycle template and execution time, or the corresponding time unit and interval value, and then displayed.
4. The method for executing a timed task according to claim 2, characterized in that, The session identifier includes a dialogue identifier, a connection identifier, and a chat identifier; the step of constructing a session request based on the session identifier, the agent identifier, and the execution instruction includes: The application identifier, the user identifier, the agent identifier, the session identifier, and the new session indication are assembled into inner-layer business parameters; The inner layer service parameters and metadata are combined and encoded to obtain an encoded message; The request body of the session request is constructed using the encoded message, the timestamp, and the signature generated based on the encoded message.
5. The method for executing a timed task according to claim 1, characterized in that, The step of re-initiating the streaming session request after a delay includes: waiting for a delay duration positively correlated with the number of retries, such that the delay duration before the i-th re-initiation is greater than the delay duration before the (i-1)-th re-initiation, where i is an integer greater than 1 and not greater than the preset upper limit. The session identifier regenerated before each re-initiation is different from the session identifier used in the previously initiated streaming session request.
6. The method for executing a timed task according to claim 1, characterized in that, Before appending the text content of the event object to the content buffer, the method further includes: when there are nested data message fields in the event object, the content of the data message fields is used as the data source; otherwise, the outer content of the event object is used as the data source. The text content is obtained from the data source in any of the following ways: when the data source is text, the data source is used as the text content; when the data source contains a candidate result array, the text carried by the incremental content field in the element of the candidate result array is used as the text content; when the data source contains a content field, the text carried by the content field is used as the text content.
7. The method for executing a timed task according to claim 1, characterized in that, The message-type events include message events and running events; the termination-type events include stop events, process completion events, and termination events; the step-by-line reading of the streaming response returned by the streaming session request further includes: If the read line is empty or does not begin with the data prefix, skip the line and continue reading the next line; When the event type of the event object does not belong to either the message type event or the end type event, the text content carried in the event object is appended to the content buffer.
8. The method for executing a timed task according to claim 1, characterized in that, The step of reporting the content in the content buffer to the scheduling platform includes: When the execution is determined to be successful, the success callback interface of the scheduling platform is invoked, and the content in the content buffer and the session identifier are carried in the callback parameters; When it is determined that the execution has failed, the failure callback interface of the scheduling platform is called, and the failure reason is carried in the callback parameters, including the stage at which the exception occurred; The session identifier used in this execution, the stage at which the exception occurred, and the number of retries are written into the execution log of the scheduling platform.
9. A device for executing a timed task, characterized in that, include: The parameter acquisition module is used to acquire the triggering rules and execution parameters of the scheduled task, wherein the execution parameters include the agent identifier and the execution instruction; The request construction module is used to trigger the execution through the scheduling platform at the triggering time indicated by the triggering rule, parse the execution parameters and generate a session identifier for the execution, construct a session request based on the session identifier, the agent identifier and the execution instruction, and initiate a streaming session request to the agent backend according to the session request; The response collection module is used to receive the streaming response returned by the corresponding streaming session request. When the response status of the streaming response is a success status, the module reads the streaming response returned by the streaming session request line by line, removes the data prefix from the lines that start with a data prefix, and parses them into event objects. When the event type of the event object is a message event, the module appends the text content of the event object to the content buffer. When the event type is an end event, the module marks the end of the streaming response reception. An exception handling module is used to stop receiving the streaming response when an exception occurs during the initiation of the streaming session request and the line-by-line reading process, and to handle the exceptions that occur during the execution of the streaming session request according to the stage at which the exception occurs: If the exception is a connection exception occurring during the connection establishment stage, the streaming session request is re-initiated after a delay, and the session identifier is regenerated before each re-initiation until the number of retries reaches a preset limit; if the exception is a transmission interruption exception occurring after the connection is established, it is treated as a successful execution if the content buffer is not empty; if the response status of the streaming response is unsuccessful or the response content is empty, the execution is determined to have failed, and the streaming session request is not re-initiated. The result reporting module is used to determine that the execution was successful when the streaming response is marked as received or the content buffer is not empty, and to report the content in the content buffer to the scheduling platform.
10. A computer storage medium, characterized in that, The computer storage medium stores computer-executable instructions, which, when executed, implement the method for executing a timed task as described in any one of claims 1 to 8.
