A method and system for capacity-constrained large model inference request backfill routing
By parsing the route input step by step and generating the target-specific request body, the problem of process interruption when the visual large model is processing empty results is solved, the adaptability and continuity of the large model inference request are realized, and the stability and traceability of the testing process are ensured.
Patent Information
- Application Number
- CN202611709817.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-11-02
- Publication Date
- 2026-11-27
AI Technical Summary
In existing technologies, large visual models cannot effectively identify and process empty results after receiving screenshots of the interface, leading to interruptions in the testing process or waste of resources. They also cannot take into account differences in model capabilities and call anomalies, affecting the continuity and traceability of testing.
By parsing the route input step by step to form a target list, generating a target-specific request body, adapting the call according to the model's capability configuration, and controlling retries for empty results or target replacement under a shared timeout budget, the protocol adaptation and call log recording are completed in conjunction with the provider type to ensure the continuity and traceability of the call process.
It improves the adaptability and continuity of large model inference requests, avoids resource waste, and enables effective handling of empty results and call exceptions, ensuring the stability and traceability of the testing process.
Smart Images

Figure CN123178156A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of large model inference request supplementary routing technology, and in particular to a large model inference request supplementary routing method and system based on capability constraints. Background Technology
[0002] In AI automated testing platforms, large visual models are used to receive screenshots of the interface and complete interface element recognition, operation planning, and result judgment. The results of these calls directly affect whether subsequent test steps can continue. To reduce process interruptions caused by the unavailability of a single model, existing calling methods can configure multiple targets, which will take over the next target in a predetermined order after the current target fails, combined with timeout control to limit the calling process. For the model service's return results, the decision to end the current call is usually based on whether the request was completed normally and whether the returned content is available.
[0003] However, the model service has an exception state different from a direct call failure: the request has been completed normally and returned a success status, but no valid text content can be extracted from the response. If it is processed as a successful request, an empty result will continue to be passed to the interface element recognition, operation planning, or result judgment process; if it is processed as a call failure and the next target is substituted, the current target, which could still respond, will be prematurely abandoned. Furthermore, if it continues to retries at the current target in order to obtain valid content, it may continuously consume the timeout budget shared by multiple targets, compressing the callable time of subsequent targets. Summary of the Invention
[0004] To address the shortcomings of existing technologies, the present invention aims to provide a method and system for recursive routing of large model inference requests based on capability constraints. This method parses the routing input hierarchically according to the configuration level to form a target list for recursive calls. For each target, a target-specific request body is generated based on the model capability configuration to adapt to the current target's capability. Under shared timeout budget constraints, empty result retries or target recursion are performed. Protocol adaptation is completed according to the provider type, and call log records are generated based on the execution context field. This achieves the effect of balancing model capability differences and call anomalies, improving the adaptability, continuity, and traceability of large model inference requests.
[0005] To achieve the above objectives, the present invention adopts the following technical solution:
[0006] In a first aspect, the present invention provides a large-scale model inference request supplementary routing method based on capability constraints, comprising:
[0007] The routing input is parsed step by step according to the configuration hierarchy. After the first hit of a callable target, a target list for supplementary calls to large model inference requests is formed based on the priority field.
[0008] Based on the target list, read the model capability configuration one by one, and generate a target-specific request body that adapts to the current target capability in the target list, using the original large model inference request as the processing basis;
[0009] The current target call is executed based on the target-specific request body. Under the shared timeout budget constraint, the current target and its corresponding target-specific request body are handed over to the protocol adapter for processing. The empty result retry or target replacement is controlled according to the response status in the unified response structure returned by the protocol adapter until valid text content is obtained or the corresponding exception is output.
[0010] Based on the current target, the protocol is adapted according to the corresponding provider type. After converting the target-specific request body into a callable request, the current target call is issued. The call response is organized into a unified response structure and returned for control of empty result retry or target replacement.
[0011] Based on the current call data generated by protocol adaptation, call log records that can be traced according to test execution steps are generated according to the execution context field.
[0012] Preferably, the step of parsing the route input level by level according to the configuration hierarchy includes:
[0013] The configuration search scope is limited by the organization identifier in the routing input. Explicit route identifiers are parsed first, and explicit model identifiers are parsed if no match is found.
[0014] When the explicit model identifier is not found and there is no purpose-level configuration corresponding to the purpose identifier in the route input, the project default route is parsed first, and then the project default model is parsed when the project default route is not found.
[0015] When none of the preceding configuration levels are hit, the default dialogue model at the organization level that is active is located.
[0016] When any configuration level is hit, the target list is formed by sorting the priority field in the corresponding target record in ascending order, and subsequent configuration level parsing is stopped.
[0017] Preferably, the explicit routing identifier includes:
[0018] The explicit route identifier in the route input is read first. If the explicit route identifier is not provided, the purpose identifier is used as the query key to obtain a non-empty mapping value from the purpose route identifier in the project-level configuration information, and the non-empty mapping value is determined as the explicit route identifier.
[0019] The retrieval scope is limited by the organization identifier, and the routing records are queried based on the explicit routing identifier. When a match is found, the sequence of target records used to form the target list is read.
[0020] Preferably, the step of generating a target-specific request body based on the original large model inference request to adapt to the current target capability in the target list includes:
[0021] Copy the request body of the original large model inference request to each target to obtain a copy of the request body corresponding to the current target;
[0022] The model capability configuration is read based on the model identifier of the model bound to the current target, the request body copy is processed according to the model capability configuration, and the target-specific request body corresponding to the current target is generated;
[0023] The target-specific request body is saved according to the target identifier of the current target, and the target-specific request body corresponding to the target identifier of the next target is read when the target is replaced.
[0024] Preferably, the step of configuring and processing the request body copy according to the model capability includes:
[0025] When the original large model inference request contains image data, read the visual support flag in the model capability configuration;
[0026] When the visual support flag is true, the content of the last user message in the request body copy is converted into a multimodal content array, and the image data is appended to the multimodal content array;
[0027] When the visual support flag is not set, the visual degradation allow flag in the route call configuration is read. When the visual degradation allow flag is set, the text content in the request body copy is retained and the image data is omitted. When the visual degradation allow flag is not set, the target replacement is executed.
[0028] Preferably, the step of configuring and processing the request body copy according to the model capability includes:
[0029] Read the model capability array from the model capability configuration, convert each capability item in the model capability array to lowercase, replace hyphens with underscores and then replace spaces with underscores to form a normalized capability item array;
[0030] When the original large model inference request requires a structured output format and the normalized capability item array does not contain the structured output capability identifier in the model capability configuration, the structured output degradation permission flag in the routing call configuration is read.
[0031] When the structured output degradation permission flag is true, the response format in the request body copy is converted into the general constraint format given by the protocol configuration of the provider associated with the current target.
[0032] Preferably, the shared timeout budget constraint includes:
[0033] Record the start timestamp before the first call to the target list, and read the total timeout budget in the route call configuration as the shared timeout budget;
[0034] Before each call, the shared timeout budget is subtracted from the elapsed time from the start timestamp to the current time to obtain the remaining timeout time;
[0035] If the remaining timeout is greater than zero, the current target call is executed within the remaining timeout period; otherwise, the call is stopped and a service unavailable exception is output.
[0036] The retry of the empty result or the target replacement both use the starting timestamp to recalculate the remaining timeout.
[0037] Preferably, the retry of the empty result includes:
[0038] When the Hypertext Transfer Protocol status code in the unified response structure is between 200 and 299, the text content is extracted from the message content field of the unified response structure. If non-empty text content can be obtained, the non-empty text content is determined as the valid text content and returned; otherwise, an empty result is generated.
[0039] Before the current target is first invoked, the empty result retry count is set to zero, and the empty result retry count is incremented by one each time the empty result is formed.
[0040] When the empty result retry count is not greater than the upper limit of the empty result retry count in the routing call configuration, the target-specific request body of the current target is used to call again.
[0041] When the retry count for an empty result exceeds the upper limit for the number of retry attempts for an empty result, the error type corresponding to the empty result is determined according to the preset error classification rules; if the error type is a replaceable error type, the target replacement is performed; if the error type is a non-replaceable error type, the routing is terminated and the service unavailable exception is output.
[0042] Preferably, the target replacement includes:
[0043] If the Hypertext Transfer Protocol status code is not between 200 and 299, or if a connection error or single call timeout occurs during the current target call, the empty result retry for the current target will end, and the empty result retry count will not be increased.
[0044] Select the next target according to the order of the target list, read the target-specific request body corresponding to the next target, and set the empty result retry count of the next target to zero;
[0045] Recalculate the remaining timeout; if the remaining timeout is greater than zero, execute the next target call.
[0046] If the target list is exhausted and no valid text content is obtained, an "unavailable service" exception will be output.
[0047] Preferably, the step of converting the target-specific request body into a callable request includes:
[0048] When the provider type corresponds to the native protocol of the local inference engine, the multimodal content array that serves as message content in the target-specific request body is converted into a native message;
[0049] The text portions are merged according to the array item order of the multimodal content array, separated by newline characters, and then written into the text field of the native message;
[0050] Read the image data from the multimodal content array, remove the data uniform resource identifier prefix from the image data, and write the processed image data into the image array of the native message in the order of the array items of the multimodal content array;
[0051] The callable request is generated based on the native message.
[0052] Preferably, the call log recording includes:
[0053] Each time a call is made, the call log record is generated based on the current call data, and the call chain identifier corresponding to the original large model inference request is written into each call log record.
[0054] Write the obtainable execution context fields into the call log record;
[0055] The test run is limited by the execution run identifier in the execution context field, the test cases in the test run are limited by the test case identifier in the execution context field, and the call log record of the same test execution step in the test case is obtained by the step identifier in the execution context field.
[0056] Associate the call log records with the call chain identifier, and output a list of call log records for the same call chain.
[0057] Secondly, the present invention provides a large-scale model inference request supplementary routing system based on capability constraints, comprising:
[0058] The routing target parsing module is used to parse the routing input level by level according to the configuration hierarchy. After the first hit of a callable target, it forms a target list for supplementary calls for large model inference requests based on the priority field.
[0059] The capability constraint processing module is used to read the model capability configuration one by one based on the target list, and generate a target-specific request body that adapts to the current target capability in the target list based on the original large model inference request.
[0060] The supplementary call control module is used to execute the current target call based on the target-specific request body, and under the shared timeout budget constraint, hand over the current target and the corresponding target-specific request body to the protocol adapter for processing, and control the retry of empty results or target supplementation according to the response status in the unified response structure returned by the protocol adapter, until valid text content is obtained or the corresponding exception is output.
[0061] The protocol adaptation module is used to complete the protocol adaptation according to the corresponding provider type based on the current target, convert the target-specific request body into a callable request and then issue the current target call, organize the call response into the unified response structure, and return the unified response structure for control of retrying the empty result or the target replacement;
[0062] The call logging module is used to generate call log records that can be traced according to the test execution steps based on the current call data formed by the protocol adaptation and the execution context field.
[0063] Compared with the prior art, the beneficial effects of the present invention are as follows:
[0064] This invention parses routing input hierarchically according to configuration levels and forms a target list based on priority fields after the first hit on a callable target. This ensures that explicit configurations, project default configurations, and organization-level default configurations participate in routing according to a defined hierarchy, avoiding uncertainty in the call target caused by configurations from different sources taking effect simultaneously. It reads the model capability configuration for each target separately and always generates a target-specific request body based on the original large model inference request. This ensures that degradation processing of visual input and structured output capabilities only applies to the current target, preventing the capability degradation result of the previous target from being passed to the next target. Under shared timeout budget constraints, it distinguishes between empty results and call failures, performs retry for empty results of the current target, and determines whether to supplement based on preset error classification rules when retry is exhausted. This ensures that the current target, which is still responsive, retains retry opportunities, avoiding unnecessary subsequent target calls and preventing continuous occupation of the callable time of subsequent targets. It completes protocol adaptation according to provider type and unifies the response structure, so that supplementation control does not need to change with protocol differences. Furthermore, it associates each call log record with the execution context field, achieving continuous traceability of empty result retries, call failures, and target supplementation processes. Attached Figure Description
[0065] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are merely some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without any creative effort.
[0066] Figure 1 This is a flowchart illustrating the overall process of a large-scale model reasoning request supplementary routing method based on capability constraints in this invention.
[0067] Figure 2 This is an overall flowchart of multi-target routing orchestration in an embodiment of the present invention;
[0068] Figure 3 This is a flowchart illustrating the multi-level routing target resolution process in an embodiment of the present invention;
[0069] Figure 4 This is a flowchart illustrating the capability adaptive degradation process in an embodiment of the present invention;
[0070] Figure 5 This is a comparison chart of empty result retry and failure compensation in an embodiment of the present invention;
[0071] Figure 6 This is a diagram of a unified multi-protocol adaptation architecture in an embodiment of the present invention;
[0072] Figure 7 This is a functional block diagram of a large model inference request supplementary routing system based on capability constraints in an embodiment of the present invention. Detailed Implementation
[0073] Example 1:
[0074] like Figure 1 The diagram shown is an overall flowchart of a large-model inference request supplementary routing method based on capability constraints according to the present invention. Figure 2The diagram shows the overall flowchart of multi-target routing orchestration. In this embodiment, large model inference requests are not directly sent to a fixed model. Instead, a target list with a defined calling order is first formed based on the routing configuration. Then, the differences in visual input capabilities and structured output capabilities for each target in the list are processed separately. During the actual calling phase, if the current target obtains a successful status but does not generate valid text content, the target is retained for empty result retry. After the empty result retry is exhausted, a preset error classification rule is used to determine whether to supplement the next target or terminate the route and output a service unavailable exception. If an unsuccessful status or calling error occurs, the process proceeds to the next target. Each call is subject to the same total timeout budget constraint and forms a unified response structure after protocol adaptation, while recording the corresponding call log. The call result is only returned when valid text content that can be used for interface element recognition, operation planning, or result judgment is obtained. If none of the targets can provide valid content, the total timeout budget is exhausted, or the empty result retry is exhausted and the error is determined to be of an unsustainable type, a service unavailable exception is output.
[0075] S1: Parse the route input level by level according to the configuration hierarchy, and after the first hit of a callable target, form a target list for supplementary calls for large model inference requests based on the priority field.
[0076] In this embodiment, the large model inference request is a request initiated by the caller and processed by the target model, including a request type and a request body. The request body may include message content, image data, response format, and model generation option parameters. The routing resolution input includes an organization identifier, a purpose identifier, and optional explicit route identifiers and explicit model identifiers; project-level configuration information is read by the AI automated testing platform based on the current project identifier. The routing resolution input may simultaneously contain configurations explicitly specified by the caller, configurations saved by purpose within the project scope, and default configurations saved within the organization scope. If the resolution order is not limited, configurations from different sources may participate in subsequent calls simultaneously, causing the caller's explicit selection to be overridden by the default configuration. Step S1 parses the routing resolution input in hierarchical order from explicitly specified to default configuration, and uniformly converts different configuration sources into a target list, providing definite input for step S2 to construct the request body target by target.
[0077] The target refers to the model service object to be invoked; the target record is used to record the model identifier, provider information and priority field corresponding to the target. The sequence of target records sorted according to the priority field forms a target list, and the target identifier is used to identify the corresponding target.
[0078] Further, step S1 includes:
[0079] S11: After limiting the configuration search scope by organization identifier, resolve the explicit route identifier according to the purpose identifier, and output the target record in the corresponding route when the explicit route identifier is matched.
[0080] The explicit route identifier directly specified by the caller expresses the explicit route selection for this large model inference request, while the purpose route identifier in the project-level configuration information maps to express the explicit selection of a specific purpose within the project scope. If the explicit route identifier still needs to be compared with the project default route, the project default route may change the target scope specified by the caller or purpose configuration. Step S11 prioritizes resolving the explicit route identifier, and stops subsequent level resolution in steps S12 and S13 after a match.
[0081] Specifically, the organization identifier is obtained from the current organization context by the AI automated testing platform when initiating a large model inference request, while the purpose identifier is provided by the test processing procedure that initiates the large model inference request. The purpose identifier is used to distinguish the model usage purpose corresponding to interface element identification, operation planning, or result judgment. Optional explicit route identifiers are directly passed in by the caller along with the route parsing input. Project-level configuration information is read by the AI automated testing platform based on the current project identifier. The project-level configuration information includes purpose route identifier mappings and purpose model identifier mappings saved according to purpose, and also allows saving the project default route or project default model.
[0082] The resolution order of explicit route identifiers is as follows: First, read the explicit route identifiers from the route resolution input; if the explicit route identifiers in the route resolution input are empty, then use the purpose identifier as the lookup key for the purpose route identifier mapping and read the mapping value from the project-level configuration information. If the explicit route identifiers in the route resolution input or the mapping value of the purpose route identifier mapping are not empty, use the non-empty route identifier as the explicit route identifier to be resolved.
[0083] The routing record is queried using the organization identifier and the explicit route identifier to be resolved. If a match is found, the target record sequence is read. Each target record retains a priority field, model identifier, and provider information. A routing record is a configuration record that corresponds to a route identifier and stores the target record sequence. Step S11 outputs the target record sequence and marks it as a match. Steps S12 and S13 do not parse the low-level configuration.
[0084] If the query fails, or if the explicit route identifier is empty and the purpose route identifier mapping does not exist, the explicit route hit status is recorded as a miss and the process proceeds to step S12. Step S12 continues to use the organization identifier, purpose identifier, and project-level configuration information from the route resolution input.
[0085] S12: If the explicit route identifier is not hit, resolve the explicit model identifier or the project-level default configuration according to the predetermined hierarchy, and output the direct target or target record.
[0086] When step S11 fails, the route resolution input has not yet formed a target record for use in step S2. An explicit model identifier points to a model bound to a target. The project default route and project default model are used to fill project-wide configuration gaps when no purpose-level configuration exists. If a project-level default configuration is allowed to hit even when a purpose-level configuration already exists, the configuration intent of the purpose route identifier mapping or purpose model identifier mapping will be replaced by the project-level default configuration. Therefore, the project-level default configuration only participates in resolution when no purpose-level configuration exists.
[0087] Specifically, the parsing order of explicit model identifiers is as follows: first, read the explicit model identifiers from the route parsing input; if the explicit model identifiers in the route parsing input are empty, then use the purpose identifier as the query key for the purpose model identifier mapping and read the mapping value from the project-level configuration information. If the explicit model identifiers in the route parsing input or the mapping value of the purpose model identifier mapping are not empty, use the non-empty model identifier as the explicit model identifier to be parsed.
[0088] The model record is queried using the organization identifier and the explicit model identifier to be parsed. Upon a query hit, a direct target is formed based on the provider information stored in the model record. A model record is a model configuration record corresponding to a model identifier, and at least stores provider information. Direct targets retain the model identifier, provider information, and a priority field used for target sorting. Direct targets constitute a sequence of target records containing only the current direct target. Step S12 outputs the target record sequence and records the explicit model hit status as a hit. Step S13, after receiving the explicit model hit status, no longer parses the organization-level default model.
[0089] The purpose-level configuration is a non-empty configuration obtained from the purpose route identifier mapping or purpose model identifier mapping using the current purpose identifier as the query key. If neither the explicit route identifier nor the explicit model identifier is found, check if a purpose-level configuration exists for the current purpose identifier. If no purpose-level configuration exists for the current purpose identifier, first read the project default route from the project-level configuration information. If the project default route is not empty and the query is successful, read the target records from the project default route and output the target record sequence.
[0090] If the project's default route is empty or the query fails, continue reading the project's default model. If the project's default model is not empty and the query succeeds, form a direct target based on the corresponding model record. If the current purpose identifier has a purpose-level configuration, or if both the project's default route and the project's default model fail, proceed to step S13.
[0091] S13: Locate the active organization-level default dialogue model when none of the preceding configuration levels are hit, and generate a target list based on the priority field.
[0092] The organization-level default model is used to maintain route resolution when no callable target is provided in either the explicit or project-level configuration. Large model inference requests use dialog requests; therefore, the organization-level default model should be a dialog type and active.
[0093] Specifically, if neither step S11 nor step S12 results in a match, the organization-level model configuration is queried using the organization identifier, dialogue type, active state, and default state. If a match is found, a direct target is formed based on the model identifier and provider information of the active organization-level default dialogue model.
[0094] When a route is hit in step S11 or S12, the sequence of target records in the hit route is sorted in ascending order, with the priority field of each target record as the sorting key. Target records with smaller priority field values are placed before those with larger priority field values. When a model is hit in step S12 or S13, the direct targets constitute a sequence of target records containing only the current direct targets, and the sorting order does not need to be changed. The sorted sequence of target records is then determined as a target list and output to step S2.
[0095] If none of steps S11 to S13 are successful, the route resolution process cannot form a target list, outputs a route not configured exception, and terminates the current large model inference request. The route not configured exception indicates that none of the resolution levels corresponding to the organization identifier, purpose identifier, and project-level configuration information provide a callable target; no arbitrary model will be used to replace the missing configuration.
[0096] Parsing stops immediately upon a hit at each level, ensuring that explicit configurations, project-level default configurations, and organization-level default configurations all produce only one parsed result. If lower-level default configurations and higher-level explicit configurations enter the target list simultaneously, the replacement order will not reflect the caller's selection. A unified target list also ensures that different configuration sources enter the same capability constraint processing and replacement call path, so the target order will not change due to the configuration source.
[0097] like Figure 3 As shown in the flowchart, the multi-level route target resolution process prioritizes explicitly specified configurations from the caller over default configurations. Upon entering resolution, it first checks if the explicit route identifier can match a route record; if not, it checks if the explicit model identifier can locate a model record. Only when no purpose-level configuration exists for the current purpose will the project's default route and default model be checked to avoid default configurations overwriting existing purpose configurations. If no callable target is formed at any of the aforementioned levels, the active organization-level default dialogue model will be located. Resolution stops upon a match at any level, and the matched target records are organized into a target list according to priority fields; if no match is found at any level, a "route not configured" exception is output. This ensures a clear priority relationship between configurations from different sources and provides a unique and definite input for subsequent target-by-target capability processing.
[0098] S2: Read the model capability configuration one by one based on the target list, and generate a target-specific request body adapted to the current target capability based on the original large model inference request.
[0099] The original large model inference request refers to a large model inference request that has not yet undergone capability constraint processing for any target; the target-specific request body refers to the request body formed based on the original large model inference request and processed according to the current target's capability configuration. The routing call configuration also includes visual degradation permission flags and structured output degradation permission flags, which are used to indicate whether it is allowed to continue the call after reducing the request capability requirements when the current target lacks the corresponding capability; if the corresponding flag is not configured, it is set to no.
[0100] The target list output in step S1 only determines the target invocation order; different targets in the target list may still have different visual input capabilities or structured output capabilities. If the same request body is sent directly to each target in the target list, targets that do not support image data may encounter invocation errors due to multimodal content, and targets that do not support structured output formats may reject the response format. Step S2 processes the capability differences for each target separately, starting from the original large model inference request, so that step S3 obtains a target-specific request body that matches the current target capability configuration.
[0101] Further, step S2 includes:
[0102] S21: Process the image data in the large model inference request based on the visual support flag of the model bound to the target, and generate a target-specific request body with attached image content or visual degradation warning.
[0103] The image data corresponding to the screenshot is the input required for the visual large model to complete the recognition of interface elements and the judgment of results. However, the models bound to the targets in the target list do not necessarily have visual input capabilities. If the image data is sent to a target with a no visual support flag, the target may return an error when parsing the multimodal message. If the image data is deleted from the request body of all subsequent targets because a target does not support visual input, subsequent targets with visual input capabilities will also be unable to obtain the screenshot. Step S21 reads the visual support flag according to the target and always uses the original large model inference request as the basis for processing.
[0104] Specifically, the image data is obtained by the AI-automated testing platform before performing interface element recognition, operation planning, or result judgment. The image data is passed in along with the large model inference request. The image data is stored in an image data array, with each array item corresponding to an interface screenshot. The visual support flag of the model bound to the target comes from the model configuration corresponding to the model identifier in the target list output in step S1, and the value of the visual support flag is either yes or no.
[0105] For the current target in the target list, first copy the request body of the original large model inference request as the basis for processing the request body of the current target, then read the visual support flag of the model bound to the current target. If the visual support flag is present and the image data array is not empty, locate the last user message in the request body, represent the content of the last user message as a multimodal content array, and append each image data in the image data array to the multimodal content array in sequence. The text part of the multimodal content array retains the original user message text, and the image part stores the corresponding image data. After processing, output the target-specific request body corresponding to the current target.
[0106] If the visual support flag is negative and the image data array is not empty, read the visual degradation allow flag. If the visual degradation allow flag is positive, do not append image data to the target-specific request body corresponding to the current target, the text content in the original user message remains unchanged, and a visual degradation warning for the current target is generated. If the visual degradation allow flag is negative, mark the current target as having a visual capability mismatch, and do not generate a target-specific request body for the current target to invoke.
[0107] The visual degradation warning includes the model identifier, model name, and number of images in the image data array of the model to which the current target is bound. The model identifier and model name are derived from the model configuration, and the number of images is obtained by reading the number of array items in the image data array. When the image data array is empty, no image attachment processing is performed, and no visual degradation warning is generated.
[0108] A correspondence is established between the visual degradation warning and the target identifier of the current target; in step S3, when the current target obtains the call result, the visual degradation warning is returned to the caller along with the call result.
[0109] S22: Process the model capability array of the target model according to the normalization rules, and output a normalized capability item array used to determine the structured output capability.
[0110] The capability items in the model capability array may use strings with different capitalization, or they may use hyphens, spaces, or underscores to separate the same capability name. If the structured output capability is judged directly according to the original string, capability items with the same meaning but different writing styles will produce different judgment results, causing step S23 to incorrectly retain or reduce the response format. Step S22 applies the same string processing rule to each capability item, converting the model capability array into a normalized capability item array that can directly check the structured output capability identifier.
[0111] Specifically, the model capability array is derived from the model configuration of the model bound to the current target. The data structure of the model capability array is a string array, with each array item storing one capability item. The model capability array is obtained along with the model identifier of the current target and is not inferred from the original large model inference request.
[0112] Iterate through each capability item in the model capability array, converting all English letters in the currently iterated capability item to lowercase, replacing hyphens with underscores, and then replacing spaces with underscores. The capability items after these string conversions are identified as normalized capability items. After processing all capability items in the model capability array, form a normalized capability item array according to the original array item order.
[0113] The structured output capability identifier is derived from the model capability configuration and is used to indicate the capability items that the model supports for structured output. After processing the structured output capability identifier according to the normalization rules in step S22, it is compared item by item with the normalized capability item array; if there is a matching item, the structured output capability judgment result of the current target is recorded as supported, otherwise it is recorded as not supported.
[0114] If the original large model inference request does not require a structured output format, step S23 does not change the response format; if the original large model inference request requires a structured output format, step S23 receives the structured output capability judgment result and the current target request body processing result formed in step S21.
[0115] S23: Determine the structured output capability based on the normalized capability item array, and generate a target-specific request body using a general constraint format if it is not supported.
[0116] The structured output format imposes requirements on the capabilities of the model bound to the target, but insufficient structured output capabilities do not equate to the current target being completely unable to return text content. If the current target call is terminated directly when the structured output capability judgment result indicates that it is not supported, the current target, which can still return general object content, will be abandoned prematurely; if the response format that the current target cannot recognize is maintained, step S3 will mistakenly treat the error caused by capability mismatch as a call failure. Step S23 only processes the response format field, allowing the current target to continue responding within its capabilities.
[0117] Specifically, when the original large model inference request requires a structured output format and the current target's structured output capability judgment result is supported, the response format in the original large model inference request is retained, and the current target request body processing result formed in step S21 is not changed.
[0118] If the original large model inference request requires a structured output format and the current target's structured output capability is determined to be unsupported, the structured output degradation permission flag is read. If the structured output degradation permission flag is yes, the response format is converted to a general constraint format; if the structured output degradation permission flag is no, the current target is marked as having a mismatched structured output capability, and no target-specific request body is generated for the current target's invocation.
[0119] The general constraint format is a generic object output format supported by the protocol used by the current target. It is used to require the model bound to the target to return generic object content, without further requiring the model bound to the target to conform to the original structured output format. The general constraint format is given by the protocol configuration of the provider associated with the current target. When performing response format conversion, the current target request body processing result fields, except for the response format fields, remain unchanged.
[0120] When the original large model inference request does not require a structured output format, no new response format requirements are added, and the processing result of the current target request body formed in step S21 is directly determined as the current target-specific request body.
[0121] After completing the processing of the current target, write the target identifier, target-specific request body, and visual degradation warning to the same corresponding record. Repeat steps S21 to S23 for each target in the target list. In step S3, read the target-specific request body according to the target identifier, without using the request body corresponding to the previous target as the basis for processing the request body corresponding to the next target.
[0122] Each target is assigned a unique request body, ensuring that capability processing applies only to the current target. Using a shared request body would prevent subsequent targets from recovering missing image data if a previous target did not support visual input, or if a previous target did not support structured output formats, the original response format could not be restored. Each target is processed starting from the original large model inference request; capability degradation results are not propagated along the target list.
[0123] like Figure 4The diagram shows the flowchart for adaptive capability degradation. Adaptive capability degradation starts with the original large model inference request copy corresponding to the current target. When the request contains image data, the process first determines whether to attach the image based on the visual support flag of the current target. If the target does not support visual input but allows visual degradation, only the text content is retained and a visual degradation warning is generated; if degradation is not allowed, the target is marked as having a visual capability mismatch. Then, it is determined whether the original request requires structured output, and the normalized model capability configuration is used to determine whether the current target supports the corresponding capability. If it does not support structured output but allows structured output degradation, the response format is converted to a common constraint format supported by the provider's protocol; otherwise, it is marked as having a structured output capability mismatch. Each target is processed independently from the original request; the degradation result of the previous target is not passed to the next target.
[0124] S3: Execute the current target call based on the target-specific request body. Under the shared timeout budget constraint, hand over the current target and the corresponding target-specific request body to the protocol adapter for processing. Control the retry of empty results or target replacement according to the response status in the unified response structure returned by the protocol adapter, until valid text content is obtained or the corresponding exception is output.
[0125] The call chain refers to the entire process of target call attempts from the moment step S3 enters the outer recursive loop until a valid text content is obtained or a service unavailability exception is output. A service unavailability exception is an exception output when all targets in the target list fail to obtain valid text content, the total timeout budget is exhausted, or the empty result retries are exhausted and the error is determined to be a non-recursive error type according to preset error classification rules.
[0126] When the model service returns a success status code but results in an empty result, the network request has already been completed, and the current target may still return valid text content in the next call. When the model service returns a failure status code or an error occurs during the call process, remaining at the current target will prevent the use of the recursive capabilities provided by the target list. If both types of results use the same path, the current target may be abandoned prematurely, or call failures may occur repeatedly on the current target. Step S3 distinguishes between the two types of results through an outer recursive loop and an inner empty result retry loop, and when the empty result retries are exhausted, it distinguishes between recursible and non-recursible error types according to a preset error classification rule, ensuring that all calls attempt to use the same total timeout budget.
[0127] Further, step S3 includes:
[0128] S31: Establish a shared time base at the beginning of the call chain, and control the remaining timeout time allowed for each call based on the shared time base.
[0129] Both target replacement calls and empty result retries consume actual execution time. If each target or each empty result retry acquires a full timeout, the total execution time of the call chain will increase with the number of call attempts, and preceding targets may exhaust the available execution time for subsequent targets. Step S31 provides a shared time base for all call attempts using the same start timestamp recorded at the beginning of the call chain, and each call only uses the time of the total timeout budget that has not yet been consumed by preceding calls.
[0130] Further, step S31 includes:
[0131] S311: When the call chain starts, a call chain identifier is generated and the start timestamp is recorded. After reading the total timeout budget in the route call configuration, a shared time base is formed.
[0132] A shared time base needs to be determined before any target call occurs; otherwise, different targets will calculate available time with different start times, making it impossible to limit the entire call chain. The start timestamp records the moment before the call chain enters the outer replacement loop, and the total timeout budget limits the total time allowed for step S3 starting from the start timestamp. Step S311 records the start timestamp only once; the start timestamp is not re-recorded for target switching and empty result retries. The call chain identifier is generated when the current large model inference request enters step S3. All calls within the same call chain attempt to use the same call chain identifier, while different call chains use different call chain identifiers.
[0133] Specifically, the start timestamp is read by the timing function of the AI automated testing platform when the call chain is started in step S3. The start timestamp uses a time value that allows for difference calculation with the current time. The route call configuration is a supplementary call control configuration obtained with the call settings of the large model inference request. The total timeout budget is preferentially read from the value given in the route call configuration; if the route call configuration does not explicitly give the total timeout budget, it is determined based on the preset value corresponding to the call entry and the deployment configuration. In one implementation, the total timeout budget for planned call entry is 300 seconds; in another implementation, the fallback total timeout budget for call entry without planned configuration is 30 minutes. The above values are examples and can be adjusted according to the call entry and deployment configuration.
[0134] S312: Before each call begins, calculate the remaining timeout based on the total timeout budget and the start timestamp, and output the allowed timeout for a single call.
[0135] The timing record generated in step S311 only provides the start time and total time range of the call chain, and does not yet reflect the time already consumed by previous calls. Step S312 rereads the current time before each call begins and deducts the elapsed time from the start timestamp to the current time from the total timeout budget. The same calculation process is used simultaneously for the first call to the target, retrying the same target with an empty result, and calling the replacement target; therefore, the remaining timeout time obtained for each call comes from the same total timeout budget.
[0136] Specifically, before each call begins, the current time is read, and the remaining timeout is calculated using the following formula:
[0137]
[0138] In the formula, T represents the total timeout budget determined in step S311 based on the routing call configuration, call entry point, and deployment configuration. In one implementation, T can be 300 seconds. The timestamp represents the start time recorded in step S311; t represents the current time read before each call; and R represents the remaining timeout. All four quantities use the same time unit. The expression subtracts the elapsed time of the call chain from the total timeout budget; therefore, R decreases as the call duration increases and does not increase again due to target switching.
[0139] When R is greater than 0, read the timeout of the model bound to the current target. If the model's own timeout exists and is greater than 0, compare R and the model's own timeout, and select the smaller value as the single-call timeout. If the model's own timeout does not exist, is empty, or is less than or equal to 0, directly use R as the single-call timeout. If R is less than or equal to 0, determine that the total timeout budget has been exhausted, add the total timeout budget exhausted error message to the error message list, stop the current target call and subsequent target attempts, and output a service unavailable exception.
[0140] S313: Sets the interrupt controller's timer based on the single call timeout, and controls the end point of the current call in conjunction with the external interrupt signal.
[0141] The single-call timeout obtained in step S312 needs to be implemented in the current target call process; otherwise, the remaining timeout will only be recorded numerically and cannot terminate the network request while the current call continues to occupy time. External interrupt signals may also change to an interrupt state after the current call begins. Step S313 creates an interrupt controller for each call, implements the single-call timeout through a timer, and listens for external interrupt signals to respond to interrupt requests issued by the superior execution process.
[0142] Specifically, an interrupt controller is created before the current target call is issued, and a timer is set according to the single-call timeout output in step S312. The timer starts counting from the current call, and when the single-call timeout is reached, the interrupt controller is triggered, interrupting the current target call. The external interrupt signal is provided by the upper-level execution process that initiated the large model inference request. When the external interrupt signal indicates an interrupt, the interrupt controller is triggered immediately, and the current target call is not issued again.
[0143] When an external interrupt signal has not yet indicated an interrupt, a one-time interrupt event listener is registered for the external interrupt signal. During the current target call, if the external interrupt signal changes to an interrupt state, the one-time interrupt event listener triggers the interrupt controller corresponding to the current call. The timer trigger and the external interrupt signal trigger use the same interrupt controller to end the current call, so that step S32 or step S33 can enter the corresponding processing path according to the result of the current call.
[0144] After the current target call completes, an error occurs, or it is interrupted, the timers and one-time interrupt event listeners corresponding to the current call are cleared. The next call creates a new interrupt controller and does not reuse the interrupt controller that has already ended, to prevent the timing events of the previous call from affecting subsequent calls.
[0145] S32: If the current target returns a success status code but produces an empty result, maintain the current target and perform empty result retries according to the maximum number of empty result retries until valid text content is obtained.
[0146] A success status code only indicates that the model service has completed network request processing; it does not prove that the response body contains valid text content that can be used for interface element identification, operation planning, or result judgment. If the success status code is used directly as the basis for ending the call chain, an empty result will proceed to subsequent test steps; if an empty result is directly classified as a call failure, the position in the target list will be immediately advanced, and the current target that can still respond will lose the opportunity to retry. Step S32 continues to check for valid text content in the success status code branch and controls the retry of empty results on the same target through independent counting.
[0147] Specifically, when the outer loop iterates through the target list to access the current target, it reads the corresponding record output in step S2 based on the target identifier of the current target. If the corresponding record contains a capability mismatch flag, the corresponding capability mismatch error message is added to the error message list, the current target processing ends, and the process moves to the next target in the target list without issuing a call to the current target. If the corresponding record does not contain a capability mismatch flag, the current target-specific request body is read. After confirming in step S31 that the remaining timeout is greater than 0, the current target, the current target-specific request body, and the single call timeout are passed to step S4.
[0148] The Hypertext Transfer Protocol (HTTP) status code is read from the unified response structure. A success status code is an HTTP status code with a value between 200 and 299. When the HTTP status code is a success status code, the text content is extracted from the message content field of the unified response structure. If non-empty text content is available, it is determined as valid text content. The provider information, model information, actual request body, response body, HTTP status code, call latency, and success status generated by the current call attempt are passed to step S5. The inner empty result retry loop and the outer supplementary loop end, forming a call result containing valid text content.
[0149] If the visual degradation warning corresponding to the current target is not empty, the visual degradation warning generated in step S21 is written to the warning field of the call result; if the visual degradation warning corresponding to the current target is empty, no visual degradation warning is added to the call result. The call result is returned to the caller who initiated the large model inference request, and the caller uses the valid text content for interface element recognition, operation planning, or result judgment.
[0150] When a Hypertext Transfer Protocol (HTTP) status code is a success code but non-empty text content cannot be obtained from the message content field, an empty result is generated. An empty result retry count is set for the current target. The empty result retry count is 0 before the first call to the current target, and incremented by 1 each time an empty result is generated. The upper limit of the number of empty result retries can be determined according to the call entry point and routing call configuration, and can be adjusted according to the deployment configuration. When the upper limit of the number of empty result retries is not explicitly given, the preset value of the corresponding call entry point is used; in one implementation, this preset value is 0 or 1 times. When a positive value is explicitly passed, the maximum number of retries allowed by the configuration is capped; in one implementation, the maximum number of retries is 3.
[0151] If the retry count for an empty result is less than or equal to the upper limit for the number of retry attempts for an empty result, and the remaining timeout calculated in step S31 is greater than 0, the current position of the outer supplementary loop in the target list is not changed, and the target-specific request body corresponding to the same current target is read again to execute steps S31 and S4. Empty result retries do not re-execute step S1, nor do they regenerate the target list; empty result retries do not re-execute step S2, and the current target continues to use the target-specific request body corresponding to the current target.
[0152] Each time an empty result is generated, the success status code, response body, empty result error message, and call delay are passed to step S5. If the empty result retry count exceeds the upper limit of the empty result retry count and no valid text content is obtained, the empty result error message is added to the error message list, and the error type corresponding to the empty result is determined according to the preset error classification rules. If it is determined to be a replaceable error type, step S33 is entered to perform target replacement; if it is determined to be a non-replaceable error type, the outer replacement loop is terminated, a service unavailable exception is output, and no further targets are called. The non-replaceable error types include, for example, cases classified as contract errors according to preset rules.
[0153] S33: When the current target call fails, perform target replacement. When the number of retries for an empty result exceeds the limit, it is judged according to the preset error classification rules. If replacement is possible, the target list is advanced. If replacement is not possible, the route is terminated and a service unavailable exception is output.
[0154] If the current target does not return a success status code or an error occurs during the call process, the current call has not entered a successful response state where valid text content can be extracted. Continuing to retries with an empty result on the current target will confuse the processing boundary between an empty result and a call failure, and will also delay the call to the next target in the target list. Step S33 directly terminates the inner loop of the current target when the call fails and advances the outer supplementary loop; for empty results under the success status code identified in step S32, the current target is retained within the maximum number of retries. After the retries are exhausted, they are processed according to the preset error classification rules: for supplementable error types, the target list is advanced; for non-supplementable error types, the route is terminated and a service unavailable exception is output.
[0155] Specifically, if the Hypertext Transfer Protocol status code in the unified response structure is not in the range of 200 to 299, the current call is judged as a failure, and error information is read from the unified response structure and written to the error information list. If the current target call encounters a connection error or is interrupted by the interrupt controller corresponding to the single call timeout before obtaining a response, the error information generated during the call is written to the error information list and processed according to the target replacement rules. If the current target call is interrupted by an external interrupt signal, the external interrupt error information is written to the error information list, the inner empty result retry loop and the outer replacement loop are immediately terminated, a call interruption exception is output, and no further attempts are made to the target.
[0156] Each failed call passes the provider identifier, provider name, model identifier, model name, request body, response body, HIP status code, call delay, and error information to step S5. If no response body or HIP status code is obtained, the corresponding field remains empty. Call failures do not increment the empty result retry count; the inner loop of the current target terminates immediately.
[0157] When the current target call fails and target replacement is required, or when empty result retries are exhausted and the error is determined to be a replaceable error type according to the preset error classification rules, the inner empty result retry loop of the current target ends, and the outer replacement loop then advances the current position to the next target in the target list. The next target call reads the next target-specific request body from the record corresponding to the target-specific request body output in step S2, and re-executes the remaining timeout check in step S31. The next target does not use the empty result retry count of the previous target; the empty result retry count before the first call of the next target is reset to 0; the total timeout budget and start timestamp still use the values recorded in step S311 for this call chain. When empty result retries are exhausted and the error is determined to be a non-replaceable error type, the target list is not advanced, the routing is terminated directly, and a service unavailability exception is output.
[0158] If none of the targets in the target list have received valid text content, the remaining timeout is less than or equal to 0, or the error is determined to be non-replaceable after all retries for empty results have been exhausted, a service unavailability exception will be output. The error message list is a list of strings, with each item storing the error message corresponding to one target. When forming an exception message, the list items are connected using semicolons according to the order of the target list. The caller uses this list to distinguish between empty result retry count exceeding the maximum number of empty result retry attempts, non-success status codes, call process errors, total timeout budget exhaustion, and non-replaceable error types. The error message list is used for service unavailability exceptions and call logging; whether to replace empty result retries after exhaustion is determined by preset error classification rules, not by the order in the error message list.
[0159] Retrying with empty results, call failure compensation, and the total timeout budget are mutually constrained. Only performing call failure compensation prematurely abandons the current target that is still responsive; only performing retries for the same target prevents the subsequent target from getting a call opportunity; and configuring full timeouts for each target would cause the call chain to exceed the total timeout budget. Step S32 retains the current target when the number of attempts allows; step S33, based on the error type, advances the target list when compensation is possible and terminates the route when compensation is not possible; and step S31 continuously deducts the elapsed time, ensuring that retry opportunities, compensation opportunities, and total execution time are all constrained by deterministic rules.
[0160] S4: Based on the current target, complete the protocol adaptation according to the corresponding provider type, convert the target-specific request body into a callable request, issue the current target call, organize the call response into a unified response structure, and return the unified response structure for control of empty result retry or target replacement.
[0161] Step S3 controls target order, empty result retries, and timeout budgets in a unified manner. However, the compatible protocol differs from the native protocol of the local inference engine in terms of endpoint paths, request headers, message content, model generation option parameters, and response fields. If these protocol differences are written into the loop branch of step S3, the supplementary control logic needs to be changed simultaneously when switching targets. Step S4 only receives the current target and its specific request body, performs protocol adaptation processing based on the provider type, and converts the response into a unified response structure that step S3 can read.
[0162] The provider type is used to determine whether the current target uses a compatible protocol or the native protocol of the local inference engine. The unified response structure is a response data structure that is uniformly read by step S3, including message content, token usage statistics, completion reason, and Hypertext Transfer Protocol status code, and may include error information.
[0163] like Figure 5 The diagram shows a comparison between empty result retries and failure compensation. After the current target completes the call, the system first distinguishes between a normal response and a call failure based on the Hypertext Transfer Protocol (HTTP) status code. When the status code is between 200 and 299, the system continues to check if non-empty text can be obtained from the message content. If it can be obtained, a valid call result is formed; otherwise, it is considered an empty result, and the system continues to call the same target within the maximum number of empty result retries and the remaining timeout. If the empty result retries exceed the maximum number of retries and still no valid text is obtained, an empty result error message is recorded and judged according to the preset error classification rules. If it belongs to a compensable error type, the next target is compensated; if it belongs to a non-compensable error type, the route is terminated and a service unavailable exception is output. If the status code is not in the success range, or if a connection error or single call timeout occurs during the call, the system does not enter the empty result retries path, but directly records the error and compensates the next target. This branch setting allows for different handling methods for successful requests with empty content and calls that fail, and distinguishes between the two error classification handling paths after empty result retries are exhausted.
[0164] Further, step S4 includes:
[0165] S41: Construct a request endpoint according to the address rules of the compatible protocol, issue a current target call using the request body with the additional model identifier, and then return the compatible protocol response body.
[0166] A compatibility protocol refers to a protocol in which the request body adopts a message structure that can be recognized in step S3 and completes the call based on the base address, endpoint path, authentication request header, and model identifier field.
[0167] The request body of the compatibility protocol already uses the message structure that can be recognized in step S3. The main differences are concentrated in the base address, endpoint path, authentication request header, and model identifier fields. If the unprocessed base address is directly concatenated, the trailing slash of the base address may form a duplicate separator with the starting slash of the endpoint path; if the request body lacks a model identifier, the compatibility protocol service cannot determine the model used in this request. Step S41 constructs the compatibility protocol request after obtaining the call data from the provider configuration and model configuration.
[0168] Specifically, the base address of the provider associated with the current target is read, and the trailing forward slash is removed. A dialogue completion endpoint path is appended to the processed base address to form the dialogue request endpoint. The request endpoint is determined based on the request type inferred from the large model, not inferred from the name of the model to which the target is bound.
[0169] Construct a compatibility protocol request header, setting the content type request header value to application / json. If the provider configuration associated with the current target includes an authentication key, write the authentication key into the authentication field required by the compatibility protocol; if the provider configuration does not include an authentication key, do not write the authentication key. The authentication key is only used in the request header invoked by the current target and is not written into the error information recorded in step S5.
[0170] Using the target-specific request body output in step S2 as the basis for processing the compatibility protocol request body, the model identifier of the model bound to the current target is appended to the model identifier field. Except for the model identifier field, the user message, multimodal content array, response format, and model generation option parameters from the target-specific request body are retained. The compatibility protocol request header and compatibility protocol request body are then sent to the dialog request endpoint or the embedded request endpoint.
[0171] Extract the message content, token usage statistics, and completion reason from the compatible protocol response body, and write them into the corresponding fields of the unified response structure. Also, write the Hypertext Transfer Protocol status code obtained from the network call into the unified response structure for step S3 to read.
[0172] S42: Based on the native protocol of the local inference engine, convert the multimodal message content to generate a native request body that separates the text content and Base64 encoded image data.
[0173] The native protocol of the local inference engine does not directly receive the multimodal content array from the compatible protocol; instead, it receives text content and image data separately. If the multimodal content array formed in step S21 is sent as is, the native protocol of the local inference engine cannot obtain the corresponding input from the array items; when the image data retains the Data Uniform Resource Identifier prefix, it also does not meet the field requirement of only receiving Base64 encoded data. Step S42 separates the two types of content without changing the semantics of the text and the main body of the image encoding.
[0174] Specifically, the provider's base address is read. If the base address already contains the complete native dialogue endpoint path, it is used directly; if the base address only contains the native protocol path prefix, the native dialogue endpoint path is appended; if the base address does not contain the native protocol path prefix, the complete native dialogue endpoint path is appended, and the processing result is determined to be the native dialogue request endpoint.
[0175] Iterate through each message in the current target's request body. If the message content is a text string, write the text string directly into the text field of the native message. If the message content is a multimodal content array, read the text and image parts in the order of the array items. Merge all text parts in their original order, separating adjacent text parts with newline characters, and write the merged result into the text field of the native message.
[0176] For each image segment in the multimodal content array, read the image data. If the image data contains a Data Uniform Resource Identifier (DRI) prefix, remove the DRI prefix and retain only the Base64 encoded data. Write each Base64 encoded data segment into the native message's image array according to its original order in the multimodal content array. If the image data is already Base64 encoded, write it directly into the native message's image array without modifying the Base64 encoded data.
[0177] S43: Generate option parameters by converting the model according to parameter name mapping rules, and organize the returned fields in the original protocol response body according to the unified response structure.
[0178] Step S42 only completes the message content conversion; the model generation option parameter names and response field names used by the native protocol of the local inference engine may still differ from those of the compatible protocol. If the parameter names are not converted, generation control information such as the maximum output length cannot be recognized by the native protocol of the local inference engine; if the response fields are not organized, step S3 cannot extract the message content from the fixed location. Step S43 converts the request parameters according to the established mapping relationship and organizes the response fields after the call is completed.
[0179] Specifically, the parameter name mapping relationship comes from the protocol configuration of the native protocol of the local inference engine. In the model generation option parameters of the current target-specific request body, the maximum number of tokens or the maximum number of completion tokens is converted into the prediction number parameter in the native protocol; the temperature parameter, candidate cumulative probability parameter, candidate sampling number parameter, random seed parameter, and stopping sequence parameter are written into the native request body according to the corresponding names used in the native protocol. The parameter values are the same as those in the current target-specific request body. Step S43 only converts the parameter names and does not recalculate the parameter values.
[0180] Write the model identifier of the model bound to the current target into the native request body, and then send the native request body to the native dialogue request endpoint formed in step S42. After receiving the native protocol response body, read the message content from the native protocol response body and write the message content into the message content field of the unified response structure; read the token count in the native protocol response body and write the token count into the token usage statistics field of the unified response structure; read the completion reason in the native protocol response body and write the completion reason into the completion reason field of the unified response structure.
[0181] Write the Hypertext Transfer Protocol status code obtained from the network call into the unified response structure. If the native protocol response body contains error information, write the error information into the unified response structure. After completing the field processing, return to step S3. Step S3 no longer distinguishes the protocol source of the unified response structure.
[0182] Protocol adaptation processes confine differences in endpoint paths, request headers, message content, model generation option parameters, and response fields to step S4. If different protocols use independent replacement processes, protocol switching may alter the empty result judgment and target replacement behavior. Steps S41 to S43 output a unified response structure, ensuring that the target order, capability processing, and result branching remain unchanged regardless of the provider type.
[0183] like Figure 6 The diagram illustrates a unified multi-protocol adaptation architecture. This architecture sits between target invocation control and specific model services. Upstream steps only need to provide the current target and its target-specific request body, without directly handling differences between provider protocols. When the current target uses a compatible protocol, a dialogue request endpoint is constructed based on the base address, corresponding request headers are set, and model identifiers are added. After the call is completed, directly usable message content, token usage statistics, and completion reasons are retained. When the current target uses the native protocol of the local inference engine, the address is processed according to the native endpoint rules. The text content and image data in the multimodal message are separated, the Uniform Resource Identifier prefix for the image data is removed, and the Base64 encoded body is retained. Model generation option parameters are then converted based on parameter name mapping relationships. Both protocol paths are ultimately processed into a unified response structure, ensuring that empty result checks, target replacement, and logging do not change with provider types.
[0184] S5: Based on the current call data formed by protocol adaptation, generate call log records that can be traced according to the test execution steps based on the execution context field.
[0185] The final call result only retains the target response that obtained valid text content or the service unavailability exception, and cannot fully represent the empty result retries, call failures, and target replacements that have occurred in the call chain. If only the final successful call is recorded, it is impossible to confirm whether the previous target returned an empty result; if only the failed call is recorded, it is impossible to classify failed attempts and subsequent successful target calls into the same test execution step. Step S5 generates a call log record for each call attempt and uses the execution context field to establish the record association in the same call chain.
[0186] Further, step S5 includes:
[0187] S51: Extract basic record fields from the request and response data generated by the current call attempt, and generate call log records that cover success, failure, and empty result states.
[0188] A call attempt may yield valid text content, result in an empty result, return a non-success status code, or encounter an error before receiving a response. The available data fields differ depending on the status. If all fields are required to be non-empty before recording, failure records needed for fault location might be missed. Step S51 uses each actual target call as a recording unit, writing each of the already obtained basic record fields and using a success or failure status to indicate the processing result of the current call attempt.
[0189] Specifically, the organization identifier and purpose identifier are read from the route parsing input, and the request type is read from the large model inference request. The request type is recorded as a dialogue request. Based on the current target, the provider identifier, provider name, model identifier, and model name are read. The provider field comes from the provider configuration of the provider associated with the current target, and the model field comes from the model configuration of the model bound to the current target.
[0190] Record the request body attempted by the current call. For compatible protocol calls, record the compatible protocol request body after attaching the model identifier in step S41; for native protocol calls from the local inference engine, record the native request body formed in steps S42 and S43. When a response is obtained, record the response body and the Hypertext Transfer Protocol status code; when no response is obtained, leave the response body field and the Hypertext Transfer Protocol status code field empty, and record any error information generated during the call.
[0191] The call delay is obtained by measuring the elapsed time between the start and end times of the current call attempt, and is recorded in milliseconds. The start time of the current call attempt is read before the network call is issued in step S4, and the end time of the current call attempt is read when a response is received, an error occurs, or the interrupt controller terminates the call. The call delay only represents the time occupied by the current call attempt and does not replace the remaining timeout calculated in step S31.
[0192] Success is recorded when valid text content is obtained; failure is recorded when an empty result is generated, a non-success status code is returned, or a call error occurs. An empty result error is recorded, a response error is recorded when a non-success status code is returned, and an error generated during the call process is recorded when a call error occurs.
[0193] S52: Extract related fields from the route parsing input and test execution context, and write the related fields to the call log record corresponding to the current call attempt.
[0194] Basic record fields can describe the provider, model, and protocol used in a call, but cannot individually identify which test execution, test case, or test execution step a call belongs to. The AI-powered automated testing platform already possesses the project, operating user, and test execution context when initiating a large model inference request. Step S52 only reads the execution context fields available when initiating the large model inference request and does not generate substitute values for missing fields.
[0195] Specifically, the project identifier and the user identifier are derived from the project context and user context when the large model inference request is initiated. The execution run identifier, execution job identifier, test case identifier, step identifier, and step sequence are derived from the current test execution process of the AI automated testing platform. The caller type indicates the type of processing process that initiated the large model inference request and is provided by the processing process that initiated the large model inference request; metadata is provided by the execution information carried by the large model inference request.
[0196] Each item is checked: call chain identifier, project identifier, operation user identifier, execution run identifier, execution job identifier, use case identifier, step identifier, step sequence, caller type, and metadata. If the corresponding field can be obtained, it is written to the call log record; otherwise, it is left empty, without affecting the basic fields recorded in step S51.
[0197] The route identifier and route name originate from step S1. When a route is hit in step S11 or step S12, the route identifier and route name are written; when a direct target is formed in step S12 or step S13, the two route fields remain empty, and the model identifier and model name are still recorded by step S51.
[0198] Each call within the same call chain attempts to use the same set of execution run identifiers, use case identifiers, and step identifiers. Each retry with an empty result still saves the Hypertext Transfer Protocol status code, call latency, response body, and error message. After writing the associated fields, the call log record is saved.
[0199] S53: Based on the call chain identifier, associate the call log records in the same call chain and output a list of call log records that can be queried according to the test execution steps.
[0200] Steps S51 and S52 have generated sequentially saved call log records, but troubleshooting requires viewing the complete call process of the same test execution step from one target to the next. Querying solely by model identifier will mix calls to the same model from different test steps, while querying solely by success or failure status will separate failed attempts from the final successful result. Step S53 uses the execution run identifier, test case identifier, and step identifier as association conditions to obtain a list of call log records corresponding to the same test execution step.
[0201] Specifically, the system receives a call log query request, reads the execution run identifier, test case identifier, and step identifier from the call log query request, uses the execution run identifier to define a test run, uses the test case identifier to define the test cases in a test run, and uses the step identifier to define the execution steps in the test cases, and obtains the call log records in the corresponding test execution steps; then, it distinguishes different call chains in the same test execution step based on the call chain identifier, and the call log records corresponding to the same call chain identifier constitute the call log record list corresponding to the current large model inference request.
[0202] Each record in the call log list remains independent. Each time the current target produces an empty result, a separate empty result call log record is saved; if the current target call fails, a call failure record is saved; after the outer recursive loop advances, a new record is saved for the next target call attempt.
[0203] By associating the log records of each actual call with the call chain identifier, it is possible to query the empty result retry, call failure and target replacement process in the same large model inference request, and trace the results of each call through the request body, response body, HIP status code and call delay.
[0204] Example 2:
[0205] like Figure 7 As shown, this embodiment, based on Embodiment 1, provides a capability-constrained large model inference request supplementary routing system to implement the aforementioned capability-constrained large model inference request supplementary routing method. The system includes a routing target parsing module, a capability constraint processing module, a supplementary call control module, a protocol adaptation module, and a call log recording module.
[0206] The routing target parsing module is used to parse the routing input level by level according to the configuration hierarchy. After the first hit of a callable target, it forms a target list for supplementary calls for large model inference requests based on the priority field.
[0207] The capability constraint processing module is used to read the model capability configuration one by one based on the target list, and generate a target-specific request body that adapts to the current target capability based on the original large model inference request.
[0208] The supplementary call control module is used to execute the current target call based on the target-specific request body. Under the shared timeout budget constraint, it controls the retry of empty results or target supplementation according to the response status until valid text content is obtained or the corresponding exception is output.
[0209] The protocol adaptation module is used to adapt the protocol to the corresponding provider type based on the current target, and to convert the target-specific request body into a callable request and then organize it into a unified response structure.
[0210] The call logging module is used to generate call log records that can be traced according to the test execution steps based on the current call data formed by protocol adaptation and the execution context field.
[0211] The above description is merely a preferred embodiment of the present invention and is not intended to limit the invention. Various modifications and variations can be made to the present invention by those skilled in the art. Any modifications, equivalent substitutions, improvements, combinations, or omissions made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.
Claims
1. A large-scale model reasoning request supplementary routing method based on capability constraints, characterized in that, include: The routing input is parsed step by step according to the configuration hierarchy. After the first hit of a callable target, a target list for supplementary calls to large model inference requests is formed based on the priority field. Based on the target list, read the model capability configuration one by one, and generate a target-specific request body that adapts to the current target capability in the target list, using the original large model inference request as the processing basis; The current target call is executed based on the target-specific request body. Under the shared timeout budget constraint, the current target and its corresponding target-specific request body are handed over to the protocol adapter for processing. The empty result retry or target replacement is controlled according to the response status in the unified response structure returned by the protocol adapter until valid text content is obtained or the corresponding exception is output. Based on the current target, the protocol is adapted according to the corresponding provider type. After converting the target-specific request body into a callable request, the current target call is issued. The call response is organized into a unified response structure and returned for control of empty result retry or target replacement. Based on the current call data generated by protocol adaptation, call log records that can be traced according to test execution steps are generated according to the execution context field.
2. The large-scale model inference request supplementary routing method based on capability constraints according to claim 1, characterized in that, The step-by-step parsing of route input according to the configuration hierarchy includes: The configuration search scope is limited by the organization identifier in the routing input. The explicit route identifier is parsed first, and the explicit model identifier is parsed if no match is found. When the explicit model identifier is not found and there is no purpose-level configuration corresponding to the purpose identifier in the route input, the project default route is parsed first, and then the project default model is parsed when the project default route is not found. When none of the preceding configuration levels are hit, the default dialogue model at the organization level that is active is located. When any configuration level is hit, the target list is formed by sorting the priority field in the corresponding target record in ascending order, and subsequent configuration level parsing is stopped.
3. The large-scale model inference request supplementary routing method based on capability constraints according to claim 2, characterized in that, The explicit routing identifier includes: The explicit route identifier in the route input is read first. If the explicit route identifier is not provided, the purpose identifier is used as the query key to obtain a non-empty mapping value from the purpose route identifier in the project-level configuration information, and the non-empty mapping value is determined as the explicit route identifier. The retrieval scope is limited by the organization identifier, and the routing records are queried based on the explicit routing identifier. When a match is found, the sequence of target records used to form the target list is read.
4. The large-scale model inference request supplementary routing method based on capability constraints according to claim 1, characterized in that, The process of generating a target-specific request body based on the original large model inference request to adapt to the current target capability in the target list includes: Copy the request body of the original large model inference request to each target to obtain a copy of the request body corresponding to the current target; The model capability configuration is read based on the model identifier of the model bound to the current target, the request body copy is processed according to the model capability configuration, and the target-specific request body corresponding to the current target is generated; The target-specific request body is saved according to the target identifier of the current target, and the target-specific request body corresponding to the target identifier of the next target is read when the target is replaced.
5. The large model inference request supplementary routing method based on capability constraints according to claim 4, characterized in that, The step of configuring and processing the request body copy according to the model capability configuration includes: When the original large model inference request contains image data, read the visual support flag in the model capability configuration; When the visual support flag is true, the content of the last user message in the request body copy is converted into a multimodal content array, and the image data is appended to the multimodal content array; When the visual support flag is not set, the visual degradation allow flag in the route call configuration is read. When the visual degradation allow flag is set, the text content in the request body copy is retained and the image data is omitted. When the visual degradation allow flag is not set, the target replacement is executed.
6. The large model inference request supplementary routing method based on capability constraints according to claim 4, characterized in that, The step of configuring and processing the request body copy according to the model capability configuration includes: Read the model capability array from the model capability configuration, convert each capability item in the model capability array to lowercase, replace hyphens with underscores and then replace spaces with underscores to form a normalized capability item array; When the original large model inference request requires a structured output format and the normalized capability item array does not contain the structured output capability identifier in the model capability configuration, the structured output degradation permission flag in the routing call configuration is read. When the structured output degradation permission flag is true, the response format in the request body copy is converted into the general constraint format given by the protocol configuration of the provider associated with the current target.
7. The large model inference request supplementary routing method based on capability constraints according to claim 1, characterized in that, The shared timeout budget constraint includes: Record the start timestamp before the first call to the target list, and read the total timeout budget in the route call configuration as the shared timeout budget; Before each call, the shared timeout budget is subtracted from the elapsed time from the start timestamp to the current time to obtain the remaining timeout time; If the remaining timeout is greater than zero, the current target call is executed within the remaining timeout period; otherwise, the call is stopped and a service unavailable exception is output. The retry of the empty result or the target replacement both use the starting timestamp to recalculate the remaining timeout.
8. The large model inference request supplementary routing method based on capability constraints according to claim 7, characterized in that, The retry of empty results includes: When the Hypertext Transfer Protocol status code in the unified response structure is between 200 and 299, the text content is extracted from the message content field of the unified response structure. If non-empty text content can be obtained, the non-empty text content is determined as the valid text content and returned; otherwise, an empty result is generated. Before the current target is first invoked, the empty result retry count is set to zero, and the empty result retry count is incremented by one each time the empty result is formed. When the empty result retry count is not greater than the upper limit of the empty result retry count in the routing call configuration, the target-specific request body of the current target is used to call again. When the retry count for an empty result exceeds the upper limit for the number of retry attempts for an empty result, the error type corresponding to the empty result is determined according to the preset error classification rules; if the error type is a replaceable error type, the target replacement is performed; if the error type is a non-replaceable error type, the routing is terminated and the service unavailable exception is output.
9. A large model inference request supplementary routing method based on capability constraints according to claim 8, characterized in that, The target replacement includes: If the Hypertext Transfer Protocol status code is not between 200 and 299, or if a connection error or single call timeout occurs during the current target call, the empty result retry for the current target will end, and the empty result retry count will not be increased. Select the next target according to the order of the target list, read the target-specific request body corresponding to the next target, and set the empty result retry count of the next target to zero; Recalculate the remaining timeout. If the remaining timeout is greater than zero, execute a call to the next target based on the target-specific request body corresponding to the next target. If the target list is exhausted and no valid text content is obtained, an "unavailable service" exception will be output.
10. A large model inference request supplementary routing method based on capability constraints according to claim 1, characterized in that, The step of converting the target-specific request body into a callable request includes: When the provider type corresponds to the native protocol of the local inference engine, the multimodal content array that serves as message content in the target-specific request body is converted into a native message; The text portions are merged according to the array item order of the multimodal content array, separated by newline characters, and then written into the text field of the native message; Read the image data from the multimodal content array, remove the data uniform resource identifier prefix from the image data, and write the processed image data into the image array of the native message in the order of the array items of the multimodal content array; The callable request is generated based on the native message.
11. The large model inference request supplementary routing method based on capability constraints according to claim 1, characterized in that, The call log records include: Each time a call is made, the call log record is generated based on the current call data, and the call chain identifier corresponding to the original large model inference request is written into each call log record. Write the obtainable execution context fields into the call log record; The test run is limited by the execution run identifier in the execution context field, the test cases in the test run are limited by the test case identifier in the execution context field, and the call log record of the same test execution step in the test case is obtained by the step identifier in the execution context field. Associate the call log records with the call chain identifier, and output a list of call log records for the same call chain.
12. A large-scale model inference request supplementary routing system based on capability constraints, characterized in that, include: The routing target parsing module is used to parse the routing input level by level according to the configuration hierarchy. After the first hit of a callable target, it forms a target list for supplementary calls for large model inference requests based on the priority field. The capability constraint processing module is used to read the model capability configuration one by one based on the target list, and generate a target-specific request body that adapts to the current target capability in the target list based on the original large model inference request. The supplementary call control module is used to execute the current target call based on the target-specific request body, and under the shared timeout budget constraint, hand over the current target and the corresponding target-specific request body to the protocol adapter for processing, and control the retry of empty results or target supplementation according to the response status in the unified response structure returned by the protocol adapter, until valid text content is obtained or the corresponding exception is output. The protocol adaptation module is used to complete the protocol adaptation according to the corresponding provider type based on the current target, convert the target-specific request body into a callable request and then issue the current target call, organize the call response into the unified response structure, and return the unified response structure for control of retrying the empty result or the target replacement; The call logging module is used to generate call log records that can be traced according to the test execution steps based on the current call data formed by the protocol adaptation and the execution context field.
