A multi-round dialogue information processing method, device, storage medium and program product

By implementing a three-part pruning and placeholder backfilling mechanism for the metadata area, result area, and history area, combined with a fingerprint deduplication strategy, the stability problem caused by the excessive size of the context in multi-turn dialogues is solved, and the stable execution of the model context protocol is achieved.

CN122153023APending Publication Date: 2026-06-05INSPUR SUZHOU INTELLIGENT TECH CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
INSPUR SUZHOU INTELLIGENT TECH CO LTD
Filing Date
2026-04-30
Publication Date
2026-06-05

Smart Images

  • Figure CN122153023A_ABST
    Figure CN122153023A_ABST
Patent Text Reader

Abstract

The application discloses a multi-round dialogue information processing method and device, a storage medium and a program product, relates to the technical field of artificial intelligence, and comprises a three-partition cutting and placeholder backfill mechanism for a meta-information area, a result area and a history area. The context provided for a large language model in each round is strictly controlled within the upper limit of the window without missing important content, and the generation interruption or call failure caused by the excessive context is greatly reduced. With the help of a fingerprint deduplication strategy, the same content is avoided from being repeatedly carried across rounds, and the growth rate of the input context in each round is greatly reduced. The calculation resources and time overhead consumed by model reasoning are reduced, the technical problems of missing necessary parameters and formats, repeatedly embedding meta-information and directly inserting long results are solved, and the technical effects of effectively controlling the input context volume in multi-round dialogue processing and improving the stability of model context protocol execution are achieved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of artificial intelligence technology, and in particular to a multi-turn dialogue information processing method, device, storage medium, and program product. Background Technology

[0002] Large Language Models (LLMs) face a dramatic increase in the amount of contextual information they need to process during multi-turn dialogues. Especially within the Model Context Protocol (MCP) framework, each time an LLM interacts with an external tool or service, it concatenates three key types of information into the input context: tool metadata, tool call results, and dialogue history. If this exceeds the LLM's context window size limit, it can lead to anything from forced model generation truncation to MCP call instruction parsing failures, impacting service continuity.

[0003] Current methods for processing multi-turn dialogue information primarily rely on semantic relevance retrieval and rewriting, or on dialogue message chain compression. However, these methods are prone to issues such as missing necessary parameters and formats, redundant embedding of metadata, and direct insertion of long results. They also fail to address the problems of a surge in input context size and low stability of model context protocol execution in multi-turn dialogue processing. Summary of the Invention

[0004] This application provides a method, device, storage medium, and program product for processing multi-turn dialogue information, in order to at least solve the problems in related technologies that easily lead to the loss of necessary parameters and formats, repeated embedding of metadata, and direct insertion of long results.

[0005] This application provides a method for processing information in a multi-turn dialogue, including: Obtain the initial input context corresponding to the current round of dialogue, and count the number of lexical units in the meta-information area, the number of lexical units in the result area, the number of lexical units in the history area, and the total context length in the initial input context; When any one or more of the number of lexical units in the meta-information area, the number of lexical units in the result area, the number of lexical units in the history area, and the total context length exceed the corresponding threshold, the content of the meta-information area, the result area, and the history area is truncated to obtain truncated meta-information area content blocks, truncated result area content blocks, and truncated history area content blocks. When the size of any one or more of the cropped metadata area content block, the cropped result area content block, and the cropped history area content block exceeds a preset content block threshold, placeholders are used to store the content blocks that exceed the preset content block threshold to obtain the intermediate current round input context. Obtain the current round content fingerprint corresponding to the initial current round input context and the previous round content fingerprint corresponding to the previous round input context; Based on the current round content fingerprint and the previous round content fingerprint, the intermediate current round input context is filtered for duplicate segments to obtain the target current round input context.

[0006] This application also provides an electronic device, including: a memory for storing a computer program; and a processor for executing the computer program to implement the steps of any of the above-described multi-turn dialogue information processing methods.

[0007] This application, by employing a three-part pruning and placeholder backfilling mechanism for the meta-information area, result area, and history area, can strictly control the context provided to the large language model in each round within the upper limit of the window without omitting important content, significantly reducing generation interruptions or call failures caused by excessively long context. The fingerprint deduplication strategy avoids carrying the same content repeatedly across rounds, greatly reducing the growth rate of the input context in each round. By reducing invalid repetitive information and delaying the provision of unnecessary details, the number of lexical units and processing latency in each round of interaction are reduced, lowering the computational resources and time overhead consumed by model inference. Therefore, it can solve the technical problems that easily lead to missing necessary parameters and formats, repeated embedding of meta-information, and direct insertion of long results, achieving the technical effect of effectively controlling the input context size in multi-round dialogue processing and improving the stability of model context protocol execution. Attached Figure Description

[0008] To more clearly illustrate the embodiments of this application, the accompanying drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0009] Figure 1 A flowchart illustrating the implementation of a multi-turn dialogue information processing method provided in this application embodiment; Figure 2 A flowchart illustrating the implementation of another multi-turn dialogue information processing method provided in this application embodiment; Figure 3 This is a flowchart illustrating the implementation of a multi-turn dialogue information processing device provided in this application. Detailed Implementation

[0010] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the protection scope of this application.

[0011] It should be noted that, in the description of this application, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. The terms "first," "second," etc., in this application are used to distinguish similar objects and are not used to describe a specific order or sequence.

[0012] To enable those skilled in the art to better understand the present application, the present application will be further described in detail below with reference to the accompanying drawings and specific embodiments.

[0013] The embodiments of this application provide a multi-turn dialogue information processing method, and the method is described in detail in conjunction with the execution flow of the multi-turn dialogue information processing method.

[0014] See Figure 1 , Figure 1 A flowchart illustrating the implementation of a multi-turn dialogue information processing method provided in this application embodiment is shown. The method may include the following steps: S101: Obtain the initial input context corresponding to the current round of dialogue, and count the number of meta-information region lexical units, result region lexical units, history region lexical units, and total context length in the initial input context.

[0015] During the multi-turn dialogue information processing, the initial input context corresponding to the current turn of the dialogue is obtained, and the number of lexical units in the meta information (Meta) area, the number of lexical units in the result (Result) area, the number of lexical units in the history (History) area, and the total context length are counted in the initial input context.

[0016] S102: When any one or more of the number of lexical units in the meta-information area, the number of lexical units in the result area, the number of lexical units in the history area, and the total context length exceed the corresponding threshold, the content of the meta-information area, the result area, and the history area is truncated to obtain the truncated content blocks of the meta-information area, the truncated content blocks of the result area, and the truncated content blocks of the history area.

[0017] The system pre-sets thresholds for the number of tokens in the metadata area, the result area, the history area, and the total context length. A context monitoring module is also configured to monitor the length of these three types of content (metadata area, result area, and history area) and the entire input context in real time. This module counts tokens for each part of the content, approximating the count using Byte Pair Encoding (BPE) rules and then precisely verifying it using the model's built-in tokenizer, constantly monitoring whether the context length is approaching the threshold.

[0018] After statistically obtaining the number of lexical units in the initial input context, including the number of lexical units in the meta-information area, the number of lexical units in the result area, the number of lexical units in the history area, and the total context length, it is determined whether each of these thresholds is exceeded. If any one or more of these thresholds are exceeded, the meta-information area, the result area, and the history area are truncated, resulting in truncated content blocks for the meta-information area, the result area, and the history area. This real-time monitoring and triggering mechanism prevents passive truncation only when the context becomes too long, thus avoiding the loss of entire blocks of information and allowing for proactive processing of the excessive portions.

[0019] S103: When the size of any one or more of the content blocks in the cropped metadata area, the cropped result area, and the cropped history area exceeds the preset content block threshold, placeholders are used to store the content blocks that exceed the preset content block threshold to obtain the intermediate input context for this round.

[0020] A pre-set content block threshold is used. After obtaining the content blocks of the cropped meta-information area, the cropped result area, and the cropped history area, it is determined whether the content blocks of the cropped meta-information area, the cropped result area, and the cropped history area exceed the preset content block threshold. When the size of any one or more of the content blocks of the cropped meta-information area, the cropped result area, and the cropped history area exceeds the preset content block threshold, a placeholder (PLH) is stored for the content blocks that exceed the preset content block threshold to obtain the intermediate current-round input context. This further reduces the number of tokens in the intermediate current-round input context compared to the number of tokens in the initial current-round input context.

[0021] S104: Obtain the current round content fingerprint corresponding to the initial current round input context and the previous round content fingerprint corresponding to the previous round input context.

[0022] After storing content blocks exceeding a preset content block threshold as placeholders to obtain the intermediate current-round input context, the current-round content fingerprint corresponding to the initial current-round input context and the previous-round content fingerprint corresponding to the previous-round input context are obtained. The current-round content fingerprint is the identification information representing the initial current-round input context, and the previous-round content fingerprint is the identification information of the previous-round input context of the initial current-round input context.

[0023] S105: Based on the content fingerprint of the current round and the content fingerprint of the previous round, perform duplicate segment filtering on the intermediate current round input context to obtain the target current round input context.

[0024] After obtaining the current round content fingerprint corresponding to the initial current round input context and the previous round content fingerprint corresponding to the previous round input context, the intermediate current round input context is filtered for duplicate segments based on the current round content fingerprint and the previous round content fingerprint. For example, for content with the same fingerprint, the previous round content is directly referenced by fingerprint reference to obtain the target current round input context.

[0025] This application, by employing a three-part pruning and placeholder backfilling mechanism for the meta-information area, result area, and history area, can strictly control the context provided to the large language model in each round within the upper limit of the window without omitting important content, significantly reducing generation interruptions or call failures caused by excessively long context. The fingerprint deduplication strategy avoids carrying the same content repeatedly across rounds, greatly reducing the growth rate of the input context in each round. By reducing invalid repetitive information and delaying the provision of unnecessary details, the number of lexical units and processing latency in each round of interaction are reduced, lowering the computational resources and time overhead consumed by model inference. Therefore, it can solve the technical problems that easily lead to missing necessary parameters and formats, repeated embedding of meta-information, and direct insertion of long results, achieving the technical effect of effectively controlling the input context size in multi-round dialogue processing and improving the stability of model context protocol execution.

[0026] See Figure 2 , Figure 2 A flowchart illustrating another multi-turn dialogue information processing method provided in this application embodiment is shown. The method may include the following steps: S201: Obtain the initial input context corresponding to the current round of dialogue, and count the number of meta-information region lexical units, result region lexical units, history region lexical units, and total context length in the initial input context.

[0027] S202: Obtain context interaction information.

[0028] After obtaining the initial input context corresponding to the current round of dialogue, and counting the number of meta-information region lexical units, result region lexical units, history region lexical units, and total context length in the initial input context, the context interaction information is obtained.

[0029] Contextual interaction information may include the currently invoked toolset, the length and changes of content in each area in recent rounds, and changes in the topic of the conversation.

[0030] S203: Based on the number of lexical units in the meta-information area, the number of lexical units in the result area, the number of lexical units in the history area, the total context length, and the context interaction information, adjust the lexical unit quota ratios for the meta-information area, the result area, and the history area to obtain the lexical unit quotas for the meta-information area, the result area, and the history area.

[0031] Pre-set initial word quota ratios or absolute upper limits for the metadata area, results area, and history area (e.g., initial quotas could be set to 30% for the metadata area, 45% for the results area, and 25% for the history area, or a corresponding fixed number of words). Set the step size for dynamic quota adjustment, for example: Used for expanding the result area. For historical zone expansion, the total quota remains constant. Before each round of interaction, the three-zone quota management module dynamically rebalances the quota ratios of the three zones based on factors such as the currently invoked toolset, the length and changes of content in each zone in recent rounds, and changes in the dialogue topic. By dynamically adjusting the step size according to the corresponding preset quotas, the quotas for meta-information zone, result zone, and historical zone are gradually and smoothly adjusted, thus achieving a gradual and stable adjustment of the quotas for the three zones.

[0032] After obtaining the contextual interaction information, the token quota ratios for the metadata area, result area, and history area are adjusted based on the number of tokens in the metadata area, the result area, and the history area, as well as the total context length and contextual interaction information. This results in token quotas for the metadata area, result area, and history area. For example, if it is predicted that search tools will still be used in this round and the average result length continues to increase, the result area quota is appropriately increased while the metadata area and history area quotas are decreased. Conversely, if the tool set remains stable for a long time and its version remains unchanged, the metadata area is compressed and replaced with fingerprint referencing. Quota adjustments follow the principle of maintaining a constant total context length and are allocated using a strategy of "prioritizing necessary information." By adjusting the quota ratios for the metadata area, result area, and history area, important areas receive larger quotas, thus preserving information from important areas as much as possible.

[0033] S204: When any one or more of the number of lexical units in the meta-information area, the number of lexical units in the result area, the number of lexical units in the history area, and the total context length exceed the corresponding threshold, the content of the meta-information area, the result area, and the history area is truncated according to the lexical unit quotas of the meta-information area, the result area, and the history area, resulting in truncated content blocks of the meta-information area, truncated content blocks of the result area, and truncated content blocks of the history area.

[0034] When any one or more of the following exceed the corresponding thresholds: the number of lexical units in the meta-information area, the number of lexical units in the result area, the number of lexical units in the history area, and the total context length, content is pruned in the meta-information area, result area, and history area based on their respective lexical unit quotas. This results in pruned content blocks for the meta-information area, result area, and history area. By adjusting the quota ratios for these three areas, more important areas receive larger quotas, reducing the pruning of information in these areas and preserving important information, thus improving pruning accuracy.

[0035] Implement a customized pruning strategy for each partition's content to ensure that important information stays within the quota while secondary information is reduced.

[0036] Metadata area pruning: Only essential metadata fields for tool calls are retained, such as tool name, version fingerprint, required parameter formats and / or constraints, and return result formats. Lengthy descriptive text and examples are removed. When a tool's version remains unchanged across multiple rounds, only its version fingerprint reference is passed, without repeating the full description.

[0037] Results area cropping: For long text results, key points (such as titles, sentences containing answer support, important indicator data, anchor references, etc.) are extracted to form the top K summaries (3-5 by default). For tabular data, the most critical columns and top-N rows (e.g., the first 10-30 rows) are retained, and statistical values ​​(such as minimum, maximum, average, quantiles, etc.) are calculated to summarize the overall trend. Full-text content exceeding the input length is not directly placed into the input context but is temporarily stored externally and replaced with placeholders.

[0038] Historical section pruning: The most recent r rounds (e.g., r=2~3) of complete dialogue are retained to ensure that the most recent context is not lost in detail; for earlier rounds, the "issue-conclusion-basis" triplet summary is extracted as a brief description, omitting detailed information or marking it with anchor references. This way, historical dialogue retains its core structure without consuming a large number of words.

[0039] S205: When the size of any one or more of the content blocks in the cropped metadata area, the cropped result area, and the cropped history area exceeds the preset content block threshold, placeholders are used to store the content blocks that exceed the preset content block threshold to obtain the intermediate input context for this round.

[0040] For content blocks that are still too long after pruning (mainly from the results area, and possibly some details from the history area), the placeholder backfilling management module is responsible for transferring them to external storage and replacing them with placeholder markers. External storage can be a database, object storage, or memory cache, storing long text blocks according to content type and identifier key. Placeholders use a uniform format, such as "PLH:: <zone> :: <key> :: <hash> [: <range>The symbol ] is embedded in the corresponding position in the input context to indicate that content has been replaced.

[0041] S206: Obtain the fingerprint of the current round content corresponding to the initial current round input context and the fingerprint of the previous round content corresponding to the previous round input context.

[0042] S207: Based on the content fingerprint of the current round and the content fingerprint of the previous round, perform duplicate segment filtering on the intermediate current round input context to obtain the target current round input context.

[0043] In one specific embodiment of this application, after storing placeholders for content blocks exceeding a preset content block threshold, the method may further include the following steps: Step 1: When generating an answer from the initial input context of this round, placeholders representing requests for more details are detected; Step 2: When a placeholder is detected to represent a request for more details, the corresponding original content paragraph is retrieved from external storage and then populated back into the original content paragraph.

[0044] For ease of description, the two steps above can be combined for explanation.

[0045] After storing content blocks exceeding a preset threshold as placeholders, when generating an answer from the initial input context, a placeholder-represented request for more information is detected. If such a request is detected, the corresponding original content paragraph is retrieved from external storage and refilled into the input context before the model continues generating. For example, when the large language model explicitly requests expansion of a placeholder or needs to verify specific details during answer generation, the system queries the corresponding storage, retrieves the original text fragment as needed, and refills it into the input context before allowing the model to continue generating. Through this placeholder-refill mechanism, large blocks of content are only provided to the model when necessary, significantly reducing the average context length.

[0046] In one specific embodiment of this application, the method may further include the following steps: Step 1: During the process of refilling the original content paragraph, obtain the preset number of words / characters; Step 2: When it is determined that the number of inserted words exceeds the preset number of words, the original content paragraphs are trimmed or filled back in batches.

[0047] For ease of description, the two steps above can be combined for explanation.

[0048] During the process of refilling the original content paragraph, a preset number of words is obtained. When it is determined that the inserted content exceeds the preset number of words, the original content paragraph is trimmed or filled in batches.

[0049] During backfilling, the budget is reassessed. If inserting the entire fragment directly would cause the input context to become excessively long, a shorter summary can be provided first, or backfilling can be done in stages with pagination, ensuring that the budget limit is not exceeded. Through the placeholder-backfilling mechanism, large blocks of content are only provided to the model when necessary, significantly reducing the average context length. This not only ensures that the answer conclusion is well-founded (providing a citation index facilitates review), but also makes the final answer both concise and includes the path to obtaining complete evidence.

[0050] In one specific embodiment of this application, filtering duplicate segments in the intermediate input context based on the current round's content fingerprint and the previous round's content fingerprint may include the following steps: Step 1: Obtain the current round's toolset and tool version used for the initial input context; Step 2: Obtain the front wheel tool set and front wheel tool version used by the front wheel input context; Step 3: If the current round's toolset is the same as the previous round's toolset, and the current round's tool version is the same as the previous round's tool version, then the previous round's toolset and previous round's tool version are referenced through version fingerprints to filter duplicate fragments in the metadata area of ​​the intermediate current round's input context.

[0051] For ease of description, the three steps above can be combined for explanation.

[0052] The system retrieves the current round's toolset and tool version used in the initial input context, and also retrieves the previous round's toolset and tool version used in the previous round's input context. If the current round's toolset and tool version are identical to the previous round's, then the previous round's toolset and tool version are referenced via version fingerprints. This filters out duplicate fragments in the metadata area of ​​the intermediate current round's input context. This ensures that for metadata such as tool lists and versions, if there are no changes across multiple rounds of dialogue, the complete information is not repeatedly sent each time; only fingerprints are sent to reference previous content or to indicate that the tool version remains unchanged. By comparing the toolset and tool version, the system avoids copying and pasting the same text across rounds, ensuring that the context input is concise and non-repetitive in each round.

[0053] In one specific embodiment of this application, obtaining the current round content fingerprint corresponding to the initial current round input context and the previous round content fingerprint corresponding to the previous round input context, and filtering duplicate segments in the intermediate current round input context based on the current round content fingerprint and the previous round content fingerprint, may include the following steps: Step 1: Obtain the fingerprints of the content blocks in each round of the initial input context; Step 2: Obtain the fingerprints of the front wheel content blocks corresponding to each front wheel content block contained in the front wheel input context; And step three: compare the fingerprint of each content block in this round with the fingerprint of each content block in the previous round; Step 4: For any current round content block fingerprint, if the current round content block fingerprint is the same as any previous round content block fingerprint, filter duplicate segments in the intermediate current round input context by referencing the corresponding previous round content block.

[0054] For ease of description, the four steps above can be combined for explanation.

[0055] The process involves obtaining the fingerprints of each content block in the initial current input context and the fingerprints of each content block in the previous input context. The content blocks primarily include result area content blocks and history area content blocks. Each current content block fingerprint is compared with the fingerprints of each previous content block. If a current content block fingerprint matches any previous content block fingerprint, the intermediate current input context is filtered for duplicate segments by referencing the corresponding previous content block, ensuring only newly added or changed parts are transmitted. For example, fingerprints are calculated for the result and history area content blocks. If a content block has already appeared before, it is marked as duplicate and will not be re-constructed in the input context; it can be referenced or omitted. By comparing the fingerprints of each current content block with those of each previous content block, and filtering for duplicate segments in the intermediate current input context by referencing the corresponding previous content block fingerprint, the process achieves rapid referencing of previous content blocks and reduces the size of the input context.

[0056] For tool results and history in multi-turn dialogues, only the newly added or changed parts (ΔR or ΔH) are transmitted, while the unchanged parts reference existing content or are omitted. For example, if the search results in the current turn overlap with those in the previous turn, only the different new content is appended. This strategy avoids copying and pasting the same text across turns, ensuring that the context input is concise and non-repetitive in each turn. By using fingerprint deduplication and Δ incremental transmission strategies, the repeated carrying of the same content across turns is avoided, significantly reducing the growth rate of the input context in each turn.

[0057] In one specific embodiment of this application, the method may further include the following steps: Step 1: When the content generated by the large language model reaches the context length threshold or stops generating during the content generation process, use the breakpoint continuation module to save the preset number of tokens generated before the stop and the generation status. Step 2: Based on the generation status, append a preset number of tokens to the beginning of the next round of input context to guide the large language model to continue output.

[0058] For ease of description, the two steps above can be combined for explanation.

[0059] When the content generated by the large language model reaches the context length threshold or generation is interrupted during the content generation process, the breakpoint resume module saves the last preset number of words generated before the interruption and the generation state. Based on the generation state, the preset number of words are appended to the beginning of the next round of input context to guide the large language model to continue output. That is, the preset number of words are appended to the beginning of the last user message or the first system prompt word to guide the large language model to continue output. By appending the preset number of words to the beginning of the next round of input context to guide the large language model to continue output, the model can continue generating unfinished content following the previous round's train of thought after receiving these contexts. Breakpoint resume ensures that even if a response is not completed in one round, it can be smoothly continued in the next round, making the multi-round dialogue connection more stable and reliable.

[0060] When a large language model approaches the context length limit or experiences a truncation while generating long answers, the management layer records the breakpoint signature of the current generation process. This includes: the last N token sequences output (used for concatenation), the model's internal planning state (if there is task planning or chained thinking state information), and the content fingerprint of the last tool call context. This information is used to continue the unfinished generation in the next round. Specifically, when constructing the input context in the next round, in addition to the three normal types of content, an extra "minimum recovery context" is injected. This includes an unfinished sentence or logical fragment from the last generation (last_N_tokens, e.g., the last 64-256 tokens), the necessary meta-information fingerprint reference for the current round, and the result area summary needed for this round. After receiving this context, the model can continue generating unfinished content following the previous round's logic. The granularity of the segments during generation can be determined according to the natural structure of the answer (e.g., chapters, sections, or paragraphs). After each segment is generated, the budget is re-evaluated before proceeding to the next segment. For segmented mode, a maximum length for each segment can also be set to ensure that no single segment is too long to continue.

[0061] In one specific embodiment of this application, continuing the output based on the recorded generation state in the next round may include the following steps: Step 1: In the next round, output the answer outline based on the generated status; Step 2: When a confirmation instruction for the answer outline is received, the answer outline is expanded and output segment by segment. During the process of expanding and outputting the answer outline segment by segment, the length of the generated content is checked.

[0062] For ease of description, the two steps above can be combined for explanation.

[0063] In the next round, an answer outline is output based on the generation status. When a confirmation instruction for the answer outline is received, the outline is expanded and output segment by segment. During the segment-by-segment expansion, the length of the generated content is checked. Each segment is generated in a closed loop, and the length estimate is checked after each segment is completed to ensure that the context between segments does not exceed the limit. The breakpoint continuation module ensures that no matter how long the answer is, it can be generated completely by continuing or segmenting.

[0064] For exceptionally long answers, this application also supports a "outline → detailed segmentation" generation mode: the model first outputs an outline of the answer for user confirmation or adjustment, and then generates detailed segments for each outline item. Under this strategy, the input context before each segment generation only needs to include context relevant to that segment, avoiding excessive length by including all details at once. The combination of breakpoint continuation and segmentation ensures that the model can ultimately provide a complete answer to extremely long questions.

[0065] In one specific embodiment of this application, the method may further include the following steps: Step 1: When a model context protocol call failure or exception is detected, obtain the exception type; Step 2: Find the target recovery strategy corresponding to the anomaly type from the recovery strategy table; Step 3: Perform model context protocol call recovery according to the target recovery strategy.

[0066] For ease of description, the three steps above can be combined for explanation.

[0067] When a model context protocol call failure or exception is detected, the exception type is obtained, the target recovery strategy corresponding to the exception type is found in the recovery strategy table, and the model context protocol call is recovered according to the target recovery strategy.

[0068] The exception recovery module provides a tiered and degraded handling mechanism for common failure scenarios in MCP multi-round interactions. Depending on the exception type, the following recovery strategies are adopted progressively (degraded sequentially from L1 to L4).

[0069] Level 1 (Forced Pruning and Retry): When parsing fails due to excessively long tool output, the input context is immediately and more forcefully pruned, retaining only the essential metadata and key result fragments required for the current tool call, removing secondary or optional information, and then the call request is re-initiated. This method reduces the size of the input context and improves the success rate of the call.

[0070] Level 2 (Minimum Executable Parameter Set): When a tool call fails due to missing or incorrectly formatted parameters, the system automatically derives a minimum set of parameters that the tool can currently execute. For example, it ensures reasonable default values ​​are provided for required parameters, omits unnecessary parameter fields, and reorganizes a concise call request for re-execution. This minimizes context length and complexity while ensuring the tool's executable capability.

[0071] Level 3 (Delayed Backfilling): When the model's response time becomes too long due to excessive placeholder backfilling requests, or when the tool cannot provide all results at once, a delayed backfilling strategy is adopted. That is, the model first outputs a skeleton-like answer or outline, providing reference indexes or placeholders for parts that need to be supplemented later, without elaborating in detail. The system places these details to be backfilled into a queue, retrieving and presenting them individually when needed by the user. This approach ensures that the user receives the main conclusions first, with details provided later, avoiding excessively long output at once.

[0072] Level 4 (Idempotent Token + Deduplication Retries): When external service instability causes request timeouts or duplicate submissions (retry avalanche), the system assigns an idempotent token, such as a Universally Unique Identifier (UUID), to each tool request and sets a short time-to-live (TTL) period (e.g., 30-120 seconds). The tool service executes duplicate requests carrying the same token only once within the TTL; the rest are either returned to a cached result or discarded. Simultaneously, when the call management layer detects a large number of duplicate errors within a short period, it automatically reduces the content budget of the metadata area and / or the result area and enforces conservative strategies such as "minimum executable parameter set" to prevent infinite retries.

[0073] Through progressive processing from L1 to L4, the system can automatically take remedial measures based on the error type, ensuring the stability of the Service Level Agreement (SLA) for the dialogue service, greatly improving the system's robustness under various abnormal conditions, and preventing the entire dialogue from crashing due to a single failure.

[0074] In this application embodiment, the hierarchical recovery strategy corresponding to different types of model context protocol anomalies can be illustrated by the following examples.

[0075] Parsing failure scenario: For example, if a log analysis tool returns an excessively long JSON log, the large language model may fail to parse the entire result format and report an error. In this case, the system triggers L1 forced pruning and retry, retaining only the most critical error stack traces or error messages in the JSON, along with necessary tool metadata, while removing all other lengthy log content. Then, the large language model is allowed to parse the more concise content again. This makes it more likely that the model will successfully extract the cause of the error.

[0076] Missing parameter scenario: For example, if the request parameters are incomplete when calling a tool, causing the call to fail. The system will identify the missing parameters and use the L2 minimum executable parameter set strategy to automatically fill in safe default values ​​or simplify the request for the missing items, retaining only the minimum set of parameters required for the tool to execute normally before calling it again. This ensures that the tool can run its basic functions.

[0077] In scenarios with excessively long response times, such as when a model needs to elaborate on a placeholder but the content is extremely long, directly filling it in would exceed the budget, the system employs L3 delayed filling and / or alternative presentation. The model first returns a summary answer along with an index of the placeholder content, indicating which parts can be further queried by the user. Detailed content is then placed in a queue for filling and provided page by page only when the user confirms their need. This method of delaying the provision of details avoids excessively long initial responses.

[0078] Request avalanche scenario: For example, network fluctuations may cause the same tool request to be sent repeatedly. The system uses L4 idempotent tokens and deduplication retry measures to assign a unique token to each request and cache the result. When a duplicate request is detected, if the token already exists and is within its short lifespan, the cached result is returned directly or the duplicate is ignored to prevent the tool from being overwhelmed. At the same time, in this avalanche situation, the system automatically tightens quotas and frequency to avoid further exacerbating retries.

[0079] For typical multi-turn tool-invoking question-answering scenarios, such as users asking questions repeatedly on the same topic (e.g., "company financial reports and industry news"), the system repeatedly calls search tools (e.g., xxxSearch) and web crawlers (e.g., xxxCrawl) to obtain long text results such as multiple web pages, tables, and logs as the basis for the answer. In this scenario, the problem is that each round of input context needs to include the tool's metadata (e.g., descriptions of the search and crawler's capabilities and parameter formats), a summary of the long text results from the previous round, and some dialogue history. As the rounds increase, this content accumulates repeatedly, causing the context length to quickly approach the model's limit, leading to problems such as mid-response truncation, failure to parse model context protocol parameters, and even retry avalanche.

[0080] The goal of this application is to stably support the aforementioned multi-turn question-and-answer and tool call processes without altering the underlying large language model. This solution ensures that regardless of the number of interaction rounds, the length of the input context is controlled within the model context window, preventing model output interruptions due to excessively long contexts and ensuring that model context protocol tool calls do not fail due to missing or incorrectly formatted parameters.

[0081] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods according to the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method.

[0082] Embodiments of this application also provide a multi-turn dialogue information processing apparatus.

[0083] See Figure 3 , Figure 3 This application provides an implementation flowchart of a multi-turn dialogue information processing device, which may include: The quantity and length statistics module 31 is used to obtain the initial input context of the current round of dialogue and to count the number of lexical units in the meta-information area, the number of lexical units in the result area, the number of lexical units in the history area, and the total context length in the initial input context. The content trimming module 32 is used to trim the content of the meta-information area, the result area and the history area when any one or more of the number of lexical units in the meta-information area, the number of lexical units in the result area, the number of lexical units in the history area and the total context length exceed the corresponding threshold, so as to obtain the trimmed meta-information area content block, the trimmed result area content block and the trimmed history area content block. The placeholder storage module 33 is used to store the content block exceeding the preset content block threshold as a placeholder when any one or more of the content blocks of the cropped meta-information area, the content blocks of the cropped result area, and the content blocks of the cropped history area exceed the preset content block threshold, so as to obtain the intermediate current round input context. Content fingerprint acquisition module 34 is used to acquire the content fingerprint of the current round corresponding to the initial current round input context and the content fingerprint of the previous round corresponding to the previous round input context; The duplicate segment filtering module 35 is used to filter duplicate segments of the intermediate current round input context based on the current round content fingerprint and the previous round content fingerprint to obtain the target current round input context.

[0084] This application, by employing a three-part pruning and placeholder backfilling mechanism for the meta-information area, result area, and history area, can strictly control the context provided to the large language model in each round within the upper limit of the window without omitting important content, significantly reducing generation interruptions or call failures caused by excessively long context. The fingerprint deduplication strategy avoids carrying the same content repeatedly across rounds, greatly reducing the growth rate of the input context in each round. By reducing invalid repetitive information and delaying the provision of unnecessary details, the number of lexical units and processing latency in each round of interaction are reduced, lowering the computational resources and time overhead consumed by model inference. Therefore, it can solve the technical problems that easily lead to missing necessary parameters and formats, repeated embedding of meta-information, and direct insertion of long results, achieving the technical effect of effectively controlling the input context size in multi-round dialogue processing and improving the stability of model context protocol execution.

[0085] In one specific embodiment of this application, the content trimming module 32 may include: The context interaction information acquisition submodule is used to acquire context interaction information; The quota acquisition submodule is used to adjust the quota ratio of the meta-information area, the result area, and the historical area based on the number of lexical units in the meta-information area, the number of lexical units in the result area, the number of lexical units in the historical area, the total context length, and the context interaction information, so as to obtain the lexical unit quotas in the meta-information area, the lexical unit quotas in the result area, and the lexical unit quotas in the historical area. The content trimming submodule is used to trim the content of the metadata area, result area, and history area based on the metadata area's lexical quota, the result area's lexical quota, and the history area's lexical quota.

[0086] In one specific embodiment of this application, the device may further include: The request detection module is used to detect requests for more details when generating an answer from the initial input context of the current round after storing content blocks that exceed a preset content block threshold as placeholders. The content filling module is used to retrieve the corresponding original content paragraph from external storage and refill the original content paragraph when a placeholder is detected to represent a request for more details.

[0087] In one specific embodiment of this application, the device may further include: The preset word count acquisition module is used to acquire the preset word count during the process of refilling the original content paragraph; The batch fill module is used to trim or fill back the original content paragraphs in batches when it is determined that the number of inserted words exceeds the preset number of words.

[0088] In one specific embodiment of this application, the repeating fragment filtering module 35 may include: The submodule for obtaining the current round's toolset and version is used to obtain the current round's toolset and version of the tools used in the initial current round's input context. The Front Wheel Toolset and Version Acquisition Submodule is used to obtain the front wheel toolset and front wheel tool version used in the front wheel input context. The duplicate fragment filtering submodule is used to filter duplicate fragments in the metadata area of ​​the intermediate input context if the current round toolset is the same as the previous round toolset and the current round tool version is the same as the previous round tool version, by referencing the previous round toolset and the previous round tool version through version fingerprint.

[0089] In one specific embodiment of this application, the content fingerprint acquisition module 34 may include: The current round content block fingerprint acquisition submodule is used to obtain the current round content block fingerprints corresponding to each current round content block contained in the initial current round input context; The front wheel content block fingerprint acquisition submodule is used to acquire the front wheel content block fingerprints corresponding to each front wheel content block contained in the front wheel input context. The repeating fragment filtering module 35 may include: The content block fingerprint comparison submodule is used to compare the fingerprint of each current round content block with the fingerprint of each previous round content block. The first duplicate fragment filtering submodule is used to filter duplicate fragments in the intermediate input context by referencing the corresponding previous content block when the fingerprint of the current content block is the same as the fingerprint of any previous content block.

[0090] In one specific embodiment of this application, the device may further include: The lexical and state saving module is used to save the last preset number of lexical units and the generation state before the termination when the content generated by the large language model reaches the context length threshold or the generation is stopped during the content generation process. The continuation output module is used to append a preset number of tokens to the beginning of the next round of input context based on the generation state to guide the continuation output of the large language model.

[0091] In one specific embodiment of this application, the continuation output module may include: The answer outline output submodule is used to output the answer outline in the next round based on the generation status; The length check submodule is used to expand and output the answer outline segment by segment when a confirmation instruction for the answer outline is received, and to check the length of the generated content during the process of expanding and outputting the answer outline segment by segment.

[0092] In one specific embodiment of this application, the device may further include: The exception type acquisition module is used to obtain the exception type when a model context protocol call failure or exception is detected. The target recovery strategy lookup module is used to find the target recovery strategy corresponding to the exception type from the recovery strategy table; The Model Context Protocol Call Recovery module is used to recover Model Context Protocol calls according to the target recovery strategy.

[0093] For a description of the features in the embodiments corresponding to the multi-turn dialogue information processing device, please refer to the relevant descriptions in the embodiments corresponding to the multi-turn dialogue information processing method, which will not be repeated here.

[0094] Embodiments of this application also provide an electronic device, including a memory and a processor, wherein the memory stores a computer program and the processor is configured to run the computer program to perform the steps in any of the above embodiments of the multi-turn dialogue information processing method.

[0095] Embodiments of this application also provide a computer-readable storage medium storing a computer program, wherein the computer program is configured to execute the steps in any of the above embodiments of the multi-turn dialogue information processing method when it is run.

[0096] In one exemplary embodiment, the aforementioned computer-readable storage medium may include, but is not limited to, various media capable of storing computer programs, such as a USB flash drive, read-only memory (ROM), random access memory (RAM), portable hard disk, magnetic disk, or optical disk.

[0097] The embodiments of this application also provide a computer program product, which includes a computer program that, when executed by a processor, implements the steps in any of the above embodiments of the multi-turn dialogue information processing method.

[0098] Embodiments of this application also provide another computer program product, including a non-volatile computer-readable storage medium storing a computer program, which, when executed by a processor, implements the steps in any of the above embodiments of the multi-turn dialogue information processing method.

[0099] Those skilled in the art will further recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of the various examples have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.

[0100] The foregoing has provided a detailed description of a multi-turn dialogue information processing method, apparatus, storage medium, and program product provided in this application. Specific examples have been used to illustrate the principles and implementation methods of this application. The descriptions of the embodiments above are only intended to aid in understanding the method and core ideas of this application. It should be noted that those skilled in the art can make various improvements and modifications to this application without departing from its principles, and these improvements and modifications also fall within the protection scope of this application.< / range> < / hash> < / key> < / zone>

Claims

1. A method for processing multi-turn dialogue information, characterized in that, include: Obtain the initial input context corresponding to the current round of dialogue, and count the number of lexical units in the meta-information area, the number of lexical units in the result area, the number of lexical units in the history area, and the total context length in the initial input context; When any one or more of the number of lexical units in the meta-information area, the number of lexical units in the result area, the number of lexical units in the history area, and the total context length exceed the corresponding threshold, the content of the meta-information area, the result area, and the history area is truncated to obtain truncated meta-information area content blocks, truncated result area content blocks, and truncated history area content blocks. When the size of any one or more of the cropped metadata area content block, the cropped result area content block, and the cropped history area content block exceeds a preset content block threshold, placeholders are used to store the content blocks that exceed the preset content block threshold to obtain the intermediate current round input context. Obtain the current round content fingerprint corresponding to the initial current round input context and the previous round content fingerprint corresponding to the previous round input context; Based on the current round content fingerprint and the previous round content fingerprint, the intermediate current round input context is filtered for duplicate segments to obtain the target current round input context.

2. The multi-turn dialogue information processing method according to claim 1, characterized in that, Content clipping is performed on the metadata area, results area, and history area, including: Obtain context interaction information; Based on the number of lexical units in the meta-information area, the number of lexical units in the result area, the number of lexical units in the history area, the total context length, and the context interaction information, the lexical unit quota ratios of the meta-information area, the result area, and the history area are adjusted to obtain the lexical unit quotas for the meta-information area, the result area, and the history area. Based on the meta-information area word quota, the result area word quota, and the history area word quota, content is trimmed in the meta-information area, the result area, and the history area.

3. The multi-turn dialogue information processing method according to claim 1, characterized in that, After storing placeholders for content blocks exceeding the preset content block threshold, the method further includes: When the initial input context generates an answer, a placeholder representing a request for more details is detected. When the placeholder is detected to represent a request for more details, the corresponding original content paragraph is retrieved from external storage and then refilled.

4. The multi-turn dialogue information processing method according to claim 3, characterized in that, Also includes: During the process of refilling the original content paragraph, the preset number of words and units is obtained; When it is determined that the inserted content exceeds the preset number of terms, the original content paragraph is trimmed or filled back in batches.

5. The multi-turn dialogue information processing method according to claim 1, characterized in that, Based on the current round content fingerprint and the previous round content fingerprint, the intermediate current round input context is filtered for duplicate segments, including: Obtain the current round toolset and current round toolset version used in the initial current round input context; Obtain the front wheel tool set and front wheel tool version used by the front wheel input context; If the current round toolset is the same as the previous round toolset, and the current round toolset version is the same as the previous round toolset version, then the previous round toolset and the previous round toolset version are referenced by version fingerprint to filter duplicate fragments in the metadata area of ​​the intermediate current round input context.

6. The multi-turn dialogue information processing method according to claim 1, characterized in that, Obtaining the current round content fingerprint corresponding to the initial current round input context and the previous round content fingerprint corresponding to the previous round input context, and filtering duplicate segments in the intermediate current round input context based on the current round content fingerprint and the previous round content fingerprint, including: Obtain the fingerprint of each content block in the current round corresponding to each content block in the initial current round input context; Obtain the fingerprint of each front wheel content block corresponding to each front wheel content block contained in the front wheel input context; And compare the fingerprints of each current round content block with the fingerprints of each previous round content block; For any current round content block fingerprint, when the current round content block fingerprint is the same as any previous round content block fingerprint, the intermediate current round input context is filtered for duplicate segments by referencing the corresponding previous round content block.

7. The multi-turn dialogue information processing method according to claim 1, characterized in that, Also includes: When the content generated by the large language model reaches the context length threshold or stops generating during the content generation process, the breakpoint continuation module is used to save the preset number of words and the generation status before the stop. Based on the generated state, the preset number of lexical units are appended to the beginning of the next round of input context to guide the large language model to continue outputting.

8. The multi-turn dialogue information processing method according to claim 7, characterized in that, In the next round, the output will continue based on the recorded generation status, including: In the next round, output a response outline based on the generated state; When a confirmation instruction for the answer outline is received, the answer outline is expanded and output segment by segment, and the length of the generated content is checked during the process of expanding and outputting the answer outline segment by segment.

9. The multi-turn dialogue information processing method according to any one of claims 1 to 8, characterized in that, Also includes: When a model context protocol call failure or exception is detected, obtain the exception type; Find the target recovery strategy corresponding to the anomaly type from the recovery strategy table; Model context protocol call recovery is performed according to the target recovery strategy.

10. An electronic device, characterized in that, include: Memory, used to store computer programs; A processor, configured to implement the steps of the multi-turn dialogue information processing method as described in any one of claims 1 to 9 when executing the computer program.