Intelligent agent implementation method, equipment and medium

By combining trajectory databases and large-scale language models into an agent workflow, this approach addresses several shortcomings of existing agent systems in handling complex tasks, enabling multi-step interactive reasoning and self-optimization, thereby improving the agent's task processing capabilities and efficiency.

CN121765067APending Publication Date: 2026-03-31BEIJING KNOWNSEC INFORMATION TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-12-18
Publication Date
2026-03-31

AI Technical Summary

Technical Problem

Existing intelligent agent systems suffer from problems such as poor architectural generalization ability, high communication overhead and latency, high system complexity, lack of interactivity and multi-step reasoning ability, low upper limit of task solving ability, and lack of dynamic error correction ability when handling complex tasks.

Method used

By employing an agent workflow based on historical experience retrieval, combined with a trajectory database and a large language model, the system retrieves historical success cases during inference and leverages the contextual learning capabilities of LLM for multi-step interactive task planning and decision-making, forming a continuously self-optimizing closed-loop system.

Benefits of technology

It improves the reliability and efficiency of agents in handling complex tasks, optimizes the implementation performance of agents, enables multi-step interactive reasoning and in-depth research, dynamically adjusts action planning, and alleviates the physical limitations of LLM context windows.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121765067A_ABST
    Figure CN121765067A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides an agent implementation method and device and a medium, and relates to the technical field of large models.The method comprises the steps that a problem request is received, retrieval is conducted in a maintained track database based on the problem request, and a historical task track is obtained. The problem request is combined based on the historical task trajectory, the target cue word is constructed, the large language model is called, the action plan for the problem request is generated based on the target cue word, and the action trajectory is obtained, so that reliable processing of the problem request is realized based on the intelligent agent, the trajectory database and the large language model, and the implementation performance of the intelligent agent is ensured.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of large model technology, and more specifically, to a method, device, and medium for implementing an intelligent agent. Background Technology

[0002] With the development of large-scale language model technology, equipping it with the ability to use tools and interact with the real world has become a core direction of artificial intelligence research. Among these, intelligent agents capable of performing complex tasks have attracted significant attention. These agents answer complex, open-ended questions by invoking tools such as web search, web browsing, and code execution. These tasks not only require the agent to accurately invoke tools but also demand that it possess the ability to perform complex planning, reasoning, and information integration in multi-step interactions. Ensuring the performance of these agents is a crucial issue that needs attention. Summary of the Invention

[0003] One of the objectives of this invention includes, for example, providing a method, apparatus, and medium for implementing an intelligent agent to at least partially improve the implementation performance of the intelligent agent.

[0004] The embodiments of the present invention can be implemented as follows: In a first aspect, embodiments of the present invention provide a method for implementing an intelligent agent, comprising: Receive issue requests; Based on the aforementioned problem, a search is performed in the maintained trajectory database to obtain historical task trajectories; Based on the historical task trajectory and the question request, target prompt words are constructed; A large language model is invoked to generate an action plan for the question request based on the target prompt words, thus obtaining the action trajectory.

[0005] In an optional implementation, the step of retrieving historical task trajectories from a maintained trajectory database based on the problem request includes: The question requests are categorized and identified to determine the corresponding topic category; Based on the stated topic category, a search is performed in the maintained trajectory database to obtain historical task trajectories belonging to the same topic category.

[0006] In an optional implementation, the step of constructing target prompt words based on the historical task trajectory and the question request includes: The historical task trajectory is scored to obtain the scoring results; Select a task trajectory example based on the scoring results; Based on the task trajectory example and the question request, a target prompt word is constructed, which includes a role definition and a step plan for the question request, referring to the task trajectory example.

[0007] In an optional implementation, the step of invoking a large language model to generate an action plan for the question request based on the target prompt words, and obtaining an action trajectory, includes: The target prompt word is sent to a large language model so that the large language model can sequentially execute tool calls based on the step plan in the target prompt word; The execution results after each tool call are fed back to the large language model, and the next action is requested. The large language model is allowed to dynamically adjust its action plan based on the execution results to obtain the action trajectory.

[0008] In an optional implementation, the step of feeding back the execution result of each tool call to the large language model and querying the next action includes: Before each invocation of the large language model, monitor the total number of tokens in the current dialogue history in real time and record the number of dialogue rounds; Determine whether the total number of tokens exceeds a preset threshold of the upper limit of the context window of the large language model, or whether the number of dialogue rounds has reached a preset upper limit; If the total number of tokens exceeds the preset threshold, or if the number of dialogue rounds reaches the preset upper limit, the large language model is invoked to summarize the content already processed for the question request into a structured summary. The question request, structured summary, and execution result after the last tool call are fed back to the large language model, and the next action is requested. The large language model discards the total tokens of the history and uses the question request, structured summary, and execution result after the last tool call as the new dialogue history to generate the next action plan.

[0009] In an optional implementation, the method further includes: The movement trajectory is scored; The action trajectory and scoring results are stored as historical task trajectories in the trajectory database.

[0010] In an optional implementation, scoring the movement trajectory includes: Provided the results are accurate, action trajectories with fewer execution steps are given higher scores.

[0011] In an optional implementation, the scoring result is calculated according to the following formula: Score=(r-MEAN(R)) / (STD_DEV(R)*Ti) Wherein, Score is the rating result of the action trajectory; r is the reward value of the task result, which corresponds to different values ​​based on whether the task is successful or unsuccessful; R is the set of steps of historical task trajectories in the trajectory database that belong to the same category as the topic category corresponding to the question request; MEAN(R) is the average number of steps of historical task trajectories that belong to the same category as the topic category corresponding to the question request; STD_DEV(R) is the standard deviation of the set of steps R; and Ti is the total number of steps of the current task trajectory.

[0012] In a second aspect, embodiments of the present invention provide an electronic device, including: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the intelligent agent implementation method described in any of the foregoing embodiments.

[0013] Thirdly, embodiments of the present invention provide a computer-readable storage medium, the computer-readable storage medium including a computer program, wherein the computer program, when running, controls the electronic device on which the computer-readable storage medium is located to execute the intelligent agent implementation method described in any of the foregoing embodiments.

[0014] The beneficial effects of the embodiments of the present invention include, for example: based on the intelligent agent architecture, retrieval is performed in the trajectory database, and combined with the powerful context learning capabilities of a large language model, it guides the agent to plan and make decisions in response to problem requests, thereby forming a closed-loop system that continuously self-optimizes during use, improving the reliability of problem request processing and optimizing the implementation performance of the intelligent agent. Attached Figure Description

[0015] To more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings used in the embodiments will be briefly introduced below. It should be understood that the following drawings only show some embodiments of the present invention and should not be regarded as a limitation on the scope. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.

[0016] Figure 1 The diagram illustrates an application scenario provided by an embodiment of the present invention.

[0017] Figure 2 This is a flowchart illustrating one of the intelligent agent implementation methods provided by an embodiment of the present invention.

[0018] Figure 3 The second schematic flowchart of an intelligent agent implementation method provided by an embodiment of the present invention is shown.

[0019] Figure 4 The third schematic flowchart of an intelligent agent implementation method provided by an embodiment of the present invention is shown.

[0020] Figure 5 The fourth flowchart illustrates an intelligent agent implementation method provided by an embodiment of the present invention.

[0021] Icons: 100 - Electronic device; 110 - Memory; 120 - Processor; 130 - Communication module. Detailed Implementation

[0022] Definitions of some terms: Large Language Model (LLM): refers to a deep learning model trained on massive amounts of data that is capable of understanding and generating human language.

[0023] Intelligent Agent: Refers to a system driven by LLM that can autonomously plan, invoke external tools, such as search engines, and interact with the environment to complete complex tasks.

[0024] Trajectory: A series of ordered actions performed by an agent to solve a problem, including intermediate thinking, tool invocation instructions, and tool return results.

[0025] Trajectory Database: A structured database used to store historical mission trajectories and their related metadata, such as problem classification, final score, and scores of each component of the trajectory.

[0026] Retrieval-augmented generation (RAG) is a technique that endows generative artificial intelligence models with information retrieval capabilities. RAG optimizes the interaction of large language models, allowing them to respond to user queries based on a specified set of documents and use this information to enhance the information extracted from their massive static training data. RAG technology enables large language models to utilize domain-specific or updated information.

[0027] To adapt to the needs of various scenarios and ensure the performance of intelligent agents, a collaborative model based on multi-agent systems can be used to solve complex problems. A multi-agent system contains multiple agents with specialized roles. For example, a "planner" is responsible for breaking down the main task into sub-tasks, a "researcher" is responsible for using search tools to collect data, a "coder" is responsible for executing code to perform data analysis, and a "reporter" is responsible for integrating all results into a final answer. These agents perform their respective duties within a predefined, relatively fixed workflow, collaboratively completing a large-scale task.

[0028] However, this type of multi-agent system has the following drawbacks: Poor architecture generalization ability: The system relies heavily on pre-defined workflows. When encountering new types of tasks that cannot be covered by existing processes, the system performance will drop sharply, making it difficult to adapt and generalize.

[0029] High communication overhead and latency: State synchronization and information transmission between multiple agents generate significant communication overhead and execution latency, reducing the overall execution efficiency of the task.

[0030] High system complexity: Designing, developing, and maintaining a complex collaborative system with multiple roles is costly and error-prone.

[0031] To improve the performance of intelligent agents, it's possible to combine retrieval-enhanced generation to form a widely applicable solution for integrating LLM with external knowledge. Its workflow is typically linear and single-round. For example, it includes the following steps: 1. The system receives a question from the user. 2. The system transforms the question into one or more search queries. 3. An external search engine is invoked to retrieve a series of relevant text snippets or webpage summaries. 4. The original question is concatenated with the retrieved text content to form a prompt. 5. This prompt is input into the LLM, which generates a final comprehensive answer based on the provided context information.

[0032] However, this linear, single-round workflow has the following drawbacks: Lack of interactivity and multi-step reasoning capabilities: This approach is essentially a "one-off" "retrieval-generation" process, rather than a dynamic, interactive one. It cannot perform tasks requiring multi-step exploration, such as deciding the next step to search for B based on the first search result A. This makes it unsuitable for complex research tasks that require progressive, in-depth analysis.

[0033] Passive information processing: The role of LLM is merely to summarize and restate information retrieved from external sources. It cannot actively determine whether the current information is sufficient, nor can it actively decide whether to call other types of tools, such as code interpreters for calculations or web browsing tools to obtain full text.

[0034] The system has a low upper limit to its task-solving capabilities: its capacity is strictly limited to the information returned by a single search engine query. It is ineffective for problems requiring the integration of multiple different sources or involving computational or logical deduction to reach a conclusion.

[0035] Lack of dynamic error correction capability: If the initial search results are of poor quality or contain misleading information, the system lacks a feedback and correction mechanism, which often leads to "garbage in, garbage out," ultimately generating incorrect answers.

[0036] Based on the above research, this invention provides an intelligent agent implementation scheme. Addressing the rigidity and complexity of multi-agent systems, and the shortcomings of retrieval-enhanced generation schemes in lacking multi-step interaction and proactive exploration capabilities, this invention proposes an intelligent agent workflow based on historical experience retrieval without model training. It constructs a single-agent architecture capable of performing multi-step, interactive, and multi-tool tasks, and provides dynamic guidance through an external, continuously growing experience base (trajectory database). The workflow retrieves historical success cases during inference, leveraging the powerful contextual learning capabilities of LLM to guide complex planning and decision-making, thus forming a closed-loop system that continuously self-optimizes during use.

[0037] The shortcomings of the above solutions are the result of the inventors' practical experience and careful research. Therefore, the discovery process of the above problems and the solutions proposed by the embodiments of the present invention in the following text should be considered as contributions made by the inventors during the invention process.

[0038] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. The components of the embodiments of the present invention described and shown in the accompanying drawings can generally be arranged and designed in various different configurations.

[0039] Therefore, the following detailed description of the embodiments of the invention provided in the accompanying drawings is not intended to limit the scope of the claimed invention, but merely to illustrate selected embodiments of the invention. All other embodiments obtained by those skilled in the art based on the embodiments of the invention without inventive effort are within the scope of protection of the invention.

[0040] It should be noted that the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.

[0041] It should be noted that similar labels and letters in the following figures indicate similar items. Therefore, once an item is defined in one figure, it does not need to be further defined and explained in subsequent figures.

[0042] It should be noted that, where there is no conflict, the features in the embodiments of the present invention can be combined with each other.

[0043] Please refer to Figure 1 This is a block diagram of an electronic device 100 provided in this embodiment. The electronic device 100 in this embodiment can be a server, processing device, processing platform, etc., capable of data interaction and processing. For example, the electronic device 100 can be a device carrying an intelligent agent. The electronic device 100 includes a memory 110, a processor 120, and a communication module 130. The memory 110, processor 120, and communication module 130 are electrically connected directly or indirectly to each other to realize data transmission or interaction. For example, these components can be electrically connected to each other through one or more communication buses or signal lines.

[0044] The memory 110 is used to store programs or data. The memory 110 may be, but is not limited to, random access memory (RAM), read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), etc.

[0045] The processor 120 is used to read / write data or programs stored in the memory 110 and to perform corresponding functions.

[0046] The communication module 130 is used to establish a communication connection between the electronic device 100 and other communication terminals through the network, and to send and receive data through the network.

[0047] It should be understood that, Figure 1 The structure shown is only a schematic diagram of the electronic device 100. The electronic device 100 may also include components that are larger than... Figure 1 The more or fewer components shown, or having the same Figure 1 The different configurations shown. Figure 1 The components shown can be implemented using hardware, software, or a combination thereof.

[0048] Please refer to the following: Figure 2 This is a flowchart illustrating a method for implementing an intelligent agent according to an embodiment of the present invention. It can be derived from... Figure 1The electronic device 100 executes the commands, for example, by the processor 120 within the electronic device 100. The method for implementing the intelligent agent includes steps S110, S120, S130, and S140. S110, Receive problem request.

[0049] S120, based on the aforementioned problem request, a search is performed in the maintained trajectory database to obtain the historical task trajectory.

[0050] S130, Based on the historical task trajectory and the question request, construct the target prompt word.

[0051] S140, invoke a large language model to generate an action plan for the question request based on the target prompt words, and obtain the action trajectory.

[0052] In the implementation of the intelligent agent for problem requests, action planning is carried out by combining trajectory database and large language model. This allows performance to be improved by updating the trajectory database, achieving a self-optimizing closed loop. By combining the powerful context learning capability of large language model, planning and decision-making are carried out for problem requests. Thus, reliable processing of problem requests can be achieved based on a single intelligent agent, optimizing the implementation performance of the intelligent agent.

[0053] In S110, the problem requests received by the intelligent agent can be user problems in various scenarios.

[0054] Please refer to the following: Figure 3 In S120, the historical task trajectory is retrieved from the maintained trajectory database based on the problem request, which can be achieved through S121 and S122.

[0055] S121, classify and identify the question request to determine the topic category corresponding to the question request.

[0056] S122, based on the topic category, a search is performed in the maintained trajectory database to obtain historical task trajectories that belong to the same category as the topic category.

[0057] For example, after receiving a new user question request, the agent can analyze the question request based on the task classification module, using a lightweight classification model or keyword matching rules, and attach one or more topic category tags to the question request, such as "financial analysis", "scientific research", "personal background investigation", etc.

[0058] Using the obtained topic category labels, search the trajectory database to find all historical mission trajectories belonging to the same category.

[0059] Please refer to the following: Figure 4In S130, the target prompt word is constructed based on the historical task trajectory and the question request, which can be achieved through S131, S132 and S133.

[0060] S131, score the historical task trajectory to obtain the score result.

[0061] S132, Select a task trajectory example according to the scoring results.

[0062] S133, Based on the task trajectory example and the problem request, construct target prompt words, the target prompt words include role definitions, and refer to the task trajectory example to formulate a step plan for the problem request.

[0063] For example, for the retrieved historical task trajectories, the total score calculated by the trajectory scoring algorithm can be sorted in reverse order (from high to low). From the sorted results, select a few historical task trajectories with the highest scores, such as 50 to 100, as high-quality task trajectory examples.

[0064] High-quality task trajectory examples, along with the current issue request, are combined to form a rich contextual cue word, which serves as the target cue word.

[0065] Depending on the richness of the task trajectory examples, target prompts can be generated based on complete task trajectory examples and the current problem request, or the task trajectory examples can be extracted into a summary and then combined with the current problem request to generate target prompts.

[0066] For example, the structure of the target prompt could be: "You are a research assistant. Please refer to the following examples of task trajectories for successfully solving 'financial analysis' type problems:\n\nCase 1: [Problem, Thoughts, Tool Usage, Result...]\nCase 2: [Problem, Thoughts, Tool Usage, Result...]\n\nNow, please develop a detailed step-by-step plan for the following new problem: [Current New Problem]".

[0067] Based on the generated target prompts, in step S140, a large language model is invoked to generate an action plan for the question request based on the target prompts. The resulting action trajectory can be achieved by sending the target prompts to the large language model, causing the model to sequentially execute tool calls based on the step plan within the target prompts. The execution results after each tool call are fed back to the large language model, and the next action is requested.

[0068] The large language model is allowed to dynamically adjust its action plan based on the execution results to obtain the action trajectory.

[0069] The ability to dynamically adjust action plans based on implementation results can be flexibly achieved. For example, please refer to the following: Figure 5 It can be implemented based on S141, S142, S143 and S144.

[0070] S141, Before each invocation of the large language model, monitor the total number of tokens in the current dialogue history in real time and record the number of dialogue rounds.

[0071] S142, determine whether the total number of tokens exceeds a preset threshold of the upper limit of the context window of the large language model, or whether the number of dialogue rounds has reached a preset upper limit.

[0072] S143, if the total number of tokens exceeds the preset threshold, or if the number of dialogue rounds reaches the preset upper limit, the large language model is invoked to summarize the content already processed for the question request into a structured summary.

[0073] S144, based on the question request, structured summary, and execution result after the last tool call, the large language model is fed back, and the next action is queried, so that the large language model discards the total token of the history, uses the question request, structured summary, and execution result after the last tool call as the new dialogue history, and generates the next action plan.

[0074] For example, when sending target prompts to an LLM and requesting the LLM to output a preliminary action plan for the current problem, the process can be executed sequentially and dynamically compressed within the context.

[0075] The workflow controller in the system where the agent resides can execute tool calls sequentially according to the steps planned by the LLM.

[0076] After each tool call is executed, the returned result is fed back to the LLM, and the next action is requested, allowing the LLM to dynamically adjust its strategy based on the intermediate results.

[0077] The triggering mechanism for context-based dynamic compression can be designed as follows: Before each interaction with the LLM, the workflow controller performs dual condition monitoring, including real-time monitoring of the total number of tokens in the current dialogue history and simultaneously recording the number of dialogue rounds. When the total number of tokens exceeds a preset threshold of the LLM context window limit, such as 80%, or when the number of dialogue rounds reaches a preset limit, such as 15 rounds, the compression process is automatically triggered to generate a context summary.

[0078] By employing dual conditions, it is ensured that tasks with either lengthy content (high number of tokens) or frequent interactions (multiple rounds) can be effectively managed, thus guaranteeing the reliability and adaptability of the intelligent agent implementation.

[0079] During the implementation of the context-based dynamic compression trigger mechanism, the main task flow is paused, and the LLM is invoked to execute the "context summarization" meta-task. A dedicated, structured prompt word template can be configured to ensure high-quality summary output.

[0080] For example, a prompt template for generating a context summary could be: "[System Instruction] You are a context summary assistant. Your task is to summarize all the conversations and explorations conducted so far to solve the ultimate goal [original problem]. Please clearly include the following in your summary: 1. Key facts and data that have been confirmed; 2. Exploration paths that have been tried and disproven or ruled out; 3. The core questions that are currently unresolved and require further action to answer. The summary must be highly concise, complete, and solely aimed at directly guiding subsequent steps.\n\n[Insert the complete multi-turn conversation history to be compressed here]... ".

[0081] LLM generates a structured summary based on the aforementioned prompt template. Subsequently, the workflow controller performs a context replacement operation, achieving context reconstruction. Discard the original, lengthy, multi-turn dialogue history.

[0082] Construct a new, compressed context. The new context consists of three ordered parts: [original problem] + [newly generated summary] + [tool return result that triggered the last step before compression].

[0083] Task Resumption: The compressed, concise context is used as a new dialogue history to continue asking the LLM for the next action, thereby restoring the main task flow.

[0084] In order to realize a closed-loop, self-optimizing intelligent agent implementation process, after obtaining the action trajectory based on S140, the action trajectory can be scored, and the action trajectory and the scoring result can be stored in the trajectory database as historical task trajectories.

[0085] In order to reward correct and efficient solutions, higher scores can be given to action trajectories with fewer execution steps, provided that the results are correct.

[0086] For example, the scoring result can be calculated using the following formula: Score=(r-MEAN(R)) / (STD_DEV(R)*Ti) Wherein, Score is the rating result of the action trajectory; r is the reward value of the task result, which corresponds to different values ​​based on whether the task is successful or unsuccessful; R is the set of steps of historical task trajectories in the trajectory database that belong to the same category as the topic category corresponding to the question request; MEAN(R) is the average number of steps of historical task trajectories that belong to the same category as the topic category corresponding to the question request; STD_DEV(R) is the standard deviation of the set of steps R; and Ti is the total number of steps of the current task trajectory.

[0087] For example, after the task is completed, the trajectory can be scored and archived. This could involve automatically invoking the scoring module to calculate a comprehensive score for the newly generated trajectory, and then storing the comprehensive score along with all metadata in the trajectory database.

[0088] To reward correct and efficient solutions, when scoring action trajectories, higher scores can be awarded to trajectories with fewer steps, provided the results are accurate. The calculation formula is as follows: Score=(r-MEAN(R)) / (STD_DEV(R)*Ti) The parameters are defined as follows: Score: The final overall score of the current trajectory.

[0089] R: The reward value for the task result, which is a binary signal representing the correctness of the task. It is 1 when the task is successfully completed and 0 when it fails.

[0090] R: In the trajectory database, the set of step counts for all historical task trajectories belonging to the same category as the task corresponding to the current issue request.

[0091] MEAN(R): The average value of the R set, which is the historical average number of steps for this type of task.

[0092] STD_DEV(R): The standard deviation of the R set, used to measure the dispersion of the number of historical steps for this type of task.

[0093] Ti: The length of the task trajectory corresponding to the current problem request, that is, the total number of steps or the length of the Markov chain required to complete the task, which is a key indicator for measuring efficiency.

[0094] In the above calculation formula, the length Ti of the current task trajectory is placed in the denominator. A smaller Ti value (meaning fewer execution steps) leads to a smaller denominator, which significantly increases the final calculated score. This ensures that shorter steps result in a higher score, thus establishing a direct efficiency incentive mechanism. When a trajectory task is successfully completed (r=1), the numerator is positive. At this point, the size of the denominator directly determines the final score, ensuring that efficiency plays a decisive role, provided the result is correct.

[0095] Based on the above calculation formula, combined with trajectory database updates and target prompt word generation, the optimization direction is clearly defined. For example, for two action trajectories that both successfully solved the problem (r = 1), one took 5 steps (T1=5) and the other took 10 steps (T2=10). Under the same conditions, the score of the first action trajectory will be twice that of the second action trajectory. This design enables the automatic and quantitative prioritization of concise and efficient successful cases when archiving, retrieving, and selecting task trajectory examples based on scores. This ensures that the agent prioritizes the most efficient and highest-quality solutions when learning from historical experience. It can clearly distinguish between good solutions and better solutions, and explicitly reward action trajectories with shorter steps and better paths.

[0096] Based on the above, embodiments of the present invention also provide a computer-readable storage medium, the computer-readable storage medium including a computer program, wherein the computer program, when running, controls the electronic device in which the computer-readable storage medium is located to execute the above-described intelligent agent implementation method.

[0097] The agent implementation scheme in this invention enables multi-step interactive reasoning based on agents, surpassing the single-round retrieval-generation model. This allows agents to conduct continuous, stateful exploration, verification, and in-depth research like human experts, solving the pain point of related technologies being unable to handle complex tasks.

[0098] Without requiring fine-tuning of the LLM, the "experience base" grows continuously with use by storing each completed task trajectory back into the trajectory database, leading to sustained performance improvements and forming a virtuous cycle of self-optimization. Combined with self-summarizing context compression technology, the physical limitations of the LLM's context window are effectively alleviated, enabling it to handle complex tasks requiring long interaction histories that are unattainable by traditional solutions. When a better solution emerges, the agent can instantly learn the new strategy as long as its action trajectory is stored in the trajectory database with a high score. Furthermore, the LLM's decision-making has historical task examples to follow, making it more interpretable than a purely black-box reasoning process.

[0099] In the several embodiments provided by this invention, it should be understood that the disclosed devices and methods can also be implemented in other ways. The device embodiments described above are merely illustrative; for example, the flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of devices, methods, and computer program products according to various embodiments of the invention. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions marked in the blocks may occur in a different order than those marked in the drawings. For example, two consecutive blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in a block diagram and / or flowchart, and combinations of blocks in block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or action, or using a combination of dedicated hardware and computer instructions.

[0100] In addition, the functional modules in the various embodiments of the present invention can be integrated together to form an independent part, or each module can exist independently, or two or more modules can be integrated to form an independent part.

[0101] If the aforementioned functions are implemented as software functional modules and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this invention, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0102] 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, etc., made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.

Claims

1. An agent implementation method, characterized by, The method comprises the following steps: receiving a problem request; searching a maintained trajectory database based on the problem request to obtain a historical task trajectory; constructing a target prompt word based on the historical task trajectory and the problem request; calling a large language model to generate an action plan for the problem request based on the target prompt word to obtain an action trajectory.

2. The agent implementation method of claim 1, wherein, The searching a maintained trajectory database based on the problem request to obtain a historical task trajectory comprises the following steps: classifying and identifying the problem request to determine a subject category corresponding to the problem request; searching the maintained trajectory database based on the subject category to obtain a historical task trajectory belonging to the same category as the subject category.

3. The agent implementation method of claim 1, wherein, The constructing a target prompt word based on the historical task trajectory and the problem request comprises the following steps: scoring the historical task trajectory to obtain a scoring result; selecting a task trajectory example according to the scoring result; constructing a target prompt word based on the task trajectory example and the problem request, wherein the target prompt word includes a role definition, and a step plan is formulated for the problem request with reference to the task trajectory example.

4. The agent implementation method of claim 3, wherein, The calling a large language model to generate an action plan for the problem request based on the target prompt word to obtain an action trajectory comprises the following steps: sending the target prompt word to the large language model to enable the large language model to sequentially execute tool calls based on the step plan in the target prompt word; feeding back the execution result after each tool call to the large language model and asking the next action; wherein the large language model is allowed to dynamically adjust the action plan according to the execution result to obtain an action trajectory.

5. The agent implementation method of claim 4, wherein, The feeding back the execution result after each tool call to the large language model and asking the next action comprises the following steps: monitoring the total Token number of the current dialogue history in real time and recording the round number of the dialogue before each call of the large language model; determining whether the total Token number exceeds a preset threshold of the upper limit of the context window of the large language model, or whether the round number of the dialogue reaches a preset upper limit; in the case that the total Token number exceeds the preset threshold or the round number of the dialogue reaches the preset upper limit, calling the large language model to summarize the content processed for the problem request into a structured abstract; feeding back the problem request, the structured abstract, and the execution result after the last tool call to the large language model and asking the next action, so that the large language model discards the historical total Token, takes the problem request, the structured abstract, and the execution result after the last tool call as new dialogue history, and generates the next action plan.

6. The agent implementation method according to any one of claims 1 to 5, characterized in that, The method further comprises the following steps: scoring the action trajectory; storing the action trajectory and the scoring result as a historical task trajectory in the trajectory database.

7. The agent implementation method of claim 6, wherein, The scoring the action trajectory comprises the following steps: under the premise of ensuring the correctness of the result, giving a higher score to an action trajectory with fewer execution steps.

8. The agent implementation method of claim 7, wherein, The scoring result is calculated according to the following formula: Score = (r - MEAN(R)) / (STD_DEV(R) * Ti) wherein, Score is a score result of the action trajectory; r is a reward value of a task result, corresponding to different numerical values based on task success or failure; R is a step number set of historical task trajectories in the trajectory database which belong to the same category as the subject category corresponding to the problem request; MEAN(R) is the average step number of historical task trajectories which belong to the same category as the subject category corresponding to the problem request; STD_DEV(R) is the standard deviation of the step number set R; Ti is the total step number of the current task trajectory.

9. An electronic device, comprising: comprising: a memory, a processor, and a computer program stored on the memory and executable on the processor, the processor implementing the method of any one of claims 1 to 8 when executing the program.

10. A computer-readable storage medium, characterized in that, the computer readable storage medium comprises a computer program, the computer program controls the electronic device where the computer readable storage medium is located to execute the method of any one of claims 1 to 8 when running.