Guided programming of autonomous agents

EP4802418A1Pending Publication Date: 2026-09-09NEC LAB EURO GMBH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
EP2024702196
Authority / Receiving Office
EP · EP
Patent Type
Applications
Current Assignee / Owner
Priority Date
2023-10-30
Filing Date
2024-01-18
Publication Date
2026-09-09

AI Technical Summary

Technical Problem

Users lack control over how LLM-powered autonomous agents complete tasks, as they cannot specify preferred steps, tool usage, or data preparation, leading to potential misalignment with user intentions and missed opportunities for improving agent performance with user experience.

Method used

The method involves intercepting LLM prompts between an LLM autonomous agent and an LLM, selecting and injecting guiding prompts based on context to modify the LLM prompts, and forwarding the modified prompts and answers back to the agent, allowing users to influence the agent's actions without altering its architecture.

Benefits of technology

This approach enables users to guide the behavior of LLM-powered autonomous agents, ensuring tasks are completed according to user preferences while maintaining the agent's original capabilities, thus improving task efficiency and effectiveness.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure IB2024050480_08052025_PF_FP_ABST
    Figure IB2024050480_08052025_PF_FP_ABST
Patent Text Reader

Abstract

In an embodiment, the present invention provides a computer-implemented, machine learning method for guided programming of autonomous agents. A large language model (LLM) prompt is intercepted between an LLM autonomous agent and an LLM. A guiding prompt is selected from a plurality of guiding prompts to inject into the LLM prompt based on a context of the LLM prompt. A modified LLM prompt that includes the selected guiding prompt is sent to the LLM. The modified LLM prompt and answer generated by the LLM is forwarded to the LLM autonomous agent. The method has applications including, but not limited to, use cases in medicine / healthcare, Cyber Threat Intelligence and performance portability of computer code, to optimize processes or predictions or to support decision making.
Need to check novelty before this filing date? Find Prior Art

Description

GUIDED PROGRAMMING OF AUTONOMOUS AGENTSCROSS-REFERENCE TO PRIOR APPLICATION

[0001] Priority is claimed to U.S. Provisional Application Serial No. 63 / 546,303 filed on October 30, 2023, the entire contents of which is hereby incorporated by reference herein.FIELD

[0002] The present invention relates to Artificial Intelligence (Al) and machine learning (ML), and in particular to a method, system, data structure, computer program product and computer-readable medium for guided programming of autonomous agents, in particular, for Large Language Models (LLMs), and to the autonomous agents.BACKGROUND

[0003] LLM-powered autonomous agents include software programs that operate independently, responding to states and events in their environment without relying on direct user or owner instructions. They act on behalf of and in the best interest of their users while utilizing the advanced capabilities of LLMs to make informed decisions and use given tools to perform specific actions including interactions with the environment.SUMMARY

[0004] In an embodiment, the present invention provides a computer-implemented, machine learning method for guided programming of autonomous agents. A large language model (LLM) prompt is intercepted between an LLM autonomous agent and an LLM. A guiding prompt is selected from a plurality of guiding prompts to inject into the LLM prompt based on a context of the LLM prompt. A modified LLM prompt that includes the selected guiding prompt is sent to the LLM. The modified LLM prompt and answer generated by the LLM is forwarded to the LLM autonomous agent. The method has applications including, but not limited to, use cases in medicine / healthcare, Cyber Threat Intelligence and performance portability of computer code, to optimize processes or predictions or to support decision making.BRIEF DESCRIPTION OF THE DRAWINGS

[0005] Embodiments of the present invention will be described in even greater detail below based on the exemplary figures. The present invention is not limited to the exemplary embodiments. All features described and / or illustrated herein can be used alone or combined in different combinations in embodiments of the present invention. The features and advantages of various embodiments of the present invention will become apparent by reading the following detailed description with reference to the attached drawings which illustrate the following:

[0006] FIG. 1 schematically illustrates an LLM autonomous agent and operations performed by the autonomous agent in accordance with an embodiment of the present invention;

[0007] FIG. 2 illustrates an offline phase in accordance with an embodiment of the present invention;;

[0008] FIG. 3 illustrates the operation of the LLM autonomous agent when using guided programming in accordance with an embodiment of the present invention; and

[0009] FIG. 4 is a block diagram of an exemplary processing system, which can be configured to perform any and all operations disclosed herein.DETAILED DESCRIPTION

[0010] Embodiments of the present invention provide an approach to program (guide) LLM- powered autonomous agents by intercepting and analyzing prompts sent from the agent to the LLM and injecting user-written guiding prompts in a context-aware and safe manner.

[0011] To use an LLM-powered autonomous agent, a user can simply provide a task (e.g., answering a specific question or completing a particular assignment) to the LLM-powered agent, along with a set of tools that the agent can use to execute specific actions required for completing the task. The LLM agent then autonomously carries out the task using the provided tools, without the need for direct, step-by-step instructions / logic from the user.

[0012] While this feature offers a clear advantage, it also presents technical problems. In particular, the user lacks control over how the agent completes the task since it is not possible to specify preferred steps to reach the final goal. For example, the user cannot instruct the agent on which steps to prioritize or avoid, how to use a specific tool, or how to prepare input data or process its output. The agent acts autonomously based on its understanding, which may not always align with the user's preferences or intentions. Furthermore, the agent cannot utilize the user’s prior experience in a specific field, which could improve its reasoning and planning within tasks of this field. Embodiments of the present invention provide solutions to overcome these technical problems.

[0013] The general architecture of an LLM agent 100 (referred to as LLM autonomous agent) can be described as follows. Its principal component is the planning / reasoning module 102 (referred to as planner). Here, the LLM agent 100 plans the execution steps required to perform a given task. It executes these steps and, based on the results, makes decisions about the next course of action. Depending on the complexity of each step, the LLM agent 100 may choose to employ a specific tool. The LLM agent 100 invokes this module 102 in a loop until the task is successfully completed.

[0014] This module 102 interacts with an LLM 104 to perform the planning and reasoning, utilizing one or more hard-coded and well-defined prompts. All interactions with the LLM 104, including hard coded prompts templates, inputs, and outputs, are logged and then utilized as input for the next planning / reasoning iteration. These logs contain all the reasoning, interactions,and events that occur throughout the agent's 100 lifespan. They are saved in the agent's 100 so called short-term memory or scratchpad 106 (referred to as working memory). Having access to this temporal information enables the agent 100 to be “aware” of its current state and make informed decisions when selecting the best next step / action.

[0015] Tools 108: There are tasks such as calculation, web search, or code execution, for which the LLM 104 is less effective and less efficient. Thus, these tasks are solved by a set of pre-defined tools 108 instead. A tool 108 consists of a unique name, a description of its capabilities, and inputs / outputs. The agent 100 can choose a specific tool 108 as its next action. A tool 108 execution can take various forms, including simple functions like summing two numbers in Python, complete programs like using a browser to visit a webpage, or specific LLM-based actions like performing information extraction from a text. Some tools 108 even rely on other LLM-based agents, referred to as task-specific agents. Tools 108 can further employ LLMs for processing input, such as extracting information from natural language, and analyzing / filtering output. As in the planning / reasoning module 102, hard-coded LLM prompts templates are used to interact with the LLM 104.

[0016] Long term memory 110: For some tasks, the agent 100 needs to interact with large sets of data. In other cases, the scratchpad 106 becomes too large to be used as the LLM’s 104 input. To address this, the LLM 104 can utilize a memory component 110 to store the agent's 100 past history or to access large datasets. The memory 110 is typically based on vector storage, providing an “unlimited” capacity. The agent 100 uses vector similarity to find and retrieve information from the memory 110 and an LLM to pre-process this information for the specific use case. In an embodiment, the LLM may encode data into an N-dimensional vector space and then decode the data back into data. In the current disclosure the data can include text. This process can be used to find similar sentences by encoding text batch by batch as vectors in the vector space and saving these vectors. If new text is encoded into a vector, the system can look for the closest vectors (e.g., by distance) saved in the vector space to the new text that was encoded into the vector.

[0017] Independent of the agent’s 100 module 102, if the user intends to modify the behavior of the agent 100, they must directly intervene with the hard-coded prompts utilized to communicate with the LLM 104. However, this approach carries the risk of compromising the architecture of the agents, their generalization abilities, and reasoning capabilities. It is evident that this task is not one that can be easily undertaken by typical users. Modifying the hard-coded prompts requires a deep understanding of the underlying architecture and intricate workings of the agents. Inadvertent changes to the prompts can lead to unintended consequences, impactingthe agent's performance and potentially rendering it less effective or even dysfunctional. Embodiments of the present invention provide solutions to overcome these technical problems.

[0018] In a first aspect, the present invention provides a computer-implemented, machine learning method for guided programming of autonomous agents. A large language model (LLM) prompt is intercepted between an LLM autonomous agent and an LLM. A guiding prompt is selected from a plurality of guiding prompts to inject into the LLM prompt based on a context of the LLM prompt. A modified LLM prompt that includes the selected guiding prompt is sent to the LLM. The modified LLM prompt and answer generated by the LLM is forwarded to the LLM autonomous agent.

[0019] In a second aspect, the present invention provides the method according to the first aspect, wherein selecting the guiding prompt from the plurality of guiding prompts includes examining the LLM prompt to identify the context of the LLM prompt, and computing similarities of the context of the LLM prompt to context identifiers for the guiding prompts to select the guiding prompt based on the similarities.

[0020] In a third aspect, the present invention provides the method according to the first aspect or second aspect, wherein the LLM prompt is associated with a user-defined task, and wherein the method is repeated until the user-defined task is complete.

[0021] In a fourth aspect, the present invention provides the method according to any of the first to third aspects, further comprising defining the plurality of guiding prompts, each of which include a user hint and context identifying where to apply the user hint.

[0022] In a fifth aspect, the present invention provides the method according to any of the first to fourth aspects, further comprising storing the plurality of guiding prompts and corresponding contexts in a database implemented as a vector store.

[0023] In a sixth aspect, the present invention provides the method according to any of the first to fifth aspects, further comprising determining an insertion point in a prompt template of the LLM autonomous agent, and inserting the selected guiding prompt into the prompt template at the insertion point.

[0024] In a seventh aspect, the present invention provides the method according to any of the first to sixth aspects, wherein determining the insertion point in the prompt template includes comparing the context of the guiding prompt to the context of the prompt template using an embedding distance or providing the context of the guiding prompt and the context of the prompt template to another LLM as a question.

[0025] In an eighth aspect, the present invention provides the method according to any of the first to seventh aspects, wherein the LLM prompt is pre-processed to inject a guiding promptplaceholder, the method further comprising replacing the guiding prompt placeholder of the LLM prompt with the guiding prompt to generate the modified LLM prompt.

[0026] In a ninth aspect, the present invention provides the method according to any of the first to eighth aspects, further comprising: analyzing the modified LLM prompt to determine whether inserting the selecting guiding prompt causes the modified LLM prompt to be unsafe, and marking the selected guiding prompt as unsafe and excluding future use of the selected guiding prompt.

[0027] In a tenth aspect, the present invention provides the method according to any of the first to ninth aspects, wherein the LLM autonomous agent includes a working memory configured to receive a user-defined task that is inserted into the LLM prompt, and to receive the modified LLM prompt and an answer generated by the LLM, wherein the modified LLM prompt and the answer comprise a new LLM prompt that is sent to the LLM.

[0028] In an eleventh aspect, the present invention provides the method according to any of the first to tenth aspects, wherein the LLM autonomous agent includes tools, and wherein the answer suggests to use one of the tools, the method further comprising invoking the suggested tool in response to receiving the answer.

[0029] In a twelfth aspect, the present invention provides the method according to any of the first to eleventh aspects, wherein the LLM autonomous agent includes memory for storing previous iterations of LLM prompts and answers generated by the LLM, and for accessing data sets associated with the LLM prompt.

[0030] In a thirteenth aspect, the present invention provides the method according to any of the first to twelfth aspects, further comprising, prior to injecting the selected guiding prompt into the LLM prompt, verifying the selected guiding prompt using another LLM.

[0031] In a fourteenth aspect, the present invention provides a computer system for guided programming of autonomous agents comprising one or more processors, which, alone or in combination, are configured to perform a machine learning method for guided programming of autonomous agents according to any of the first to thirteenth aspects.

[0032] In a fifteenth aspect, the present invention provides a tangible, non-transitory computer-readable medium for guided programing of autonomous agents which, upon being executed by one or more hardware processors, provide for execution of a machine learning method according to any of the first to thirteenth aspects.

[0033] The LLM-powered autonomous agent 100 according to an embodiment of the present invention is configured to perform the following operations:1. The user-defined task 112 is inserted into the LLM reasoning prompt of the planning / reasoning module 102.2. The scratchpad 106 (containing the LLM reasoning prompt) is sent to the LLM 104 and processed by the model.3. The LLM 104 response is inserted into the scratchpad 106, along with all previous prompts and answers.4. The updated scratchpad 106 (containing all previous prompts, answers, and the new LLM 104 response) is sent to the LLM 104 again, suggesting possible tool 108 use.5. The agent 100 invokes the appropriate tool 108 based on the LLM's 104 suggestion.6. The tool 108 performs the task and interacts with the LLM 104 as needed.7. The tool 108 provides its answer to the agent 100, which is then inserted into the scratchpad 106.8. The updated scratchpad 106 (containing all previous prompts, answers, tool outputs) is sent to the LLM 104 once more.9. Steps 4 to 8 are repeated iteratively until the task is completed successfully. Note that not all the iteration will involve the use of a tool 108.N. The final answer 114 is provided to the user once the task is fully completed.

[0034] Embodiments of the present invention provide an approach for guiding the behavior of LLM-powered autonomous agents without the necessity of directly modifying their architecture or the hard-coded prompt templates that define their behavior, planning / reasoning, and interactions with tools and memory. The approach involves injecting guiding prompts into the original prompt templates utilized by the agent for its operations. These guiding prompts contain user knowledge and suggestions on how to perform a task without altering the agent's inherent capabilities. By injecting these guiding prompts, users can influence and steer the agent's actions, making it follow specific instructions or approaches while maintaining its original abilities and general behavior. This approach empowers users to shape the agent's behavior without requiring deep technical expertise or risking the integrity of the agent's underlying architecture.

[0035] Guiding prompts consist of two parts. The first part is the user’s know- how / experience / suggestion, the second part specifies the context in which the prompt should be injected. Embodiments of the present invention introduce a method to safely inject guiding prompts inside LLM-powered autonomous agents and offers an interface to program the agent’s behavior which is referred to herein as guided programming. The method acts in two different phases: offline and online.Offline Phase:

[0036] During the offline phase, the method according to an embodiment of the present invention involves analyzing prompt templates 200 and user-provided guiding prompts 202 to achieve the following technical improvements:User guiding prompt 202 storage: User guiding prompts 202, along with their context descriptions, are stored in a database 204, typically implemented as a vector store. The context or context descriptions for the user guiding prompts 202 are provided by a user. Context descriptions are later used to retrieve the right guiding prompt 202. An example of a user guiding prompt and the context or context description is “when exploring links for recent attacks” (context) “refer to national CSIRTs” (user suggestion). The similarity between the specific task and the context is used to retrieve the user suggestion, i.e., the guiding prompt with the most similar context will be retrieved by the system. In the above scenario, the task “I should explore the links to the find the latest attack” may be similar to the context and user suggestion above.Determining insertion points: The method identifies the appropriate insertion points within the agent's prompt templates 200. These insertion points are where the guiding prompts 202 will be added to effectively steer how the associated tasks are performed. To facilitate this, a placeholder 206 is added to the agent's prompt templates 200 during the offline phase, which will be replaced with the specific guiding prompts during the online phase. In embodiments insertion points are typically at the beginning, middle, or end of the prompt template 200. One method for identifying the appropriate insertion points includes analyzing the original prompt and checking if there are any existing suggestions in the prompt. If there are, placeholders can be inserted next to them to indicate where the user suggestions should be placed. Another method includes using predefined locations such as the end, middle, or start of the prompt template 200 that are tested with the guiding prompt 202. The prompt template 200 can then be executed with and without the guiding prompts 202 to verify if the desired behavior occurs. By trying different positions of the predefined locations the system can determine the optimal insertion point. These are only two examples and the current disclosure can combine these methods or use other suitable methods or processes to identify the optimal insertion points within the prompt templates 200.Verification of safety: The injected guiding prompts are examined to ensure they do not compromise the agent's capabilities or introduce undesirable behavior. If any guiding prompt is found to adversely affect the agent's functionality or safety, it is marked as unsafe and excluded from further use. Examining the injected guiding prompts to ensure they do not compromise the agent’s capabilities or introduce undesirable behavior include testing the prompt templates 200during the offline phase with and without the guiding prompts 202. If the scope of a task associated with a prompt template 200 is altered this may potentially lead to unsafe behavior.

[0037] The prompt analysis and preparation module 208 (referred to as preparer) is responsible for thoroughly examining and processing both the agent's user-provided guiding prompts 202 and the hard-coded prompt templates 200 for identifying optimal insertion points. For agents with available source code, the hard-coded prompt templates 200 are obtained through code analysis. In this case, prompts 200 with placeholders 206 are injected back into the original code. If the agent's source code is not accessible, the prompts are retrieved in a preprocessing step by intercepting communications between the agent and the LLM beforehand by the guided programming proxy module 300 (described below). The prompt analysis and preparation module 208 further identifies any unsafe guiding prompts that may lead to undesirable behavior. During the online phase, these prompts 200 with placeholders 206 are then injected back into the agent, thereby modifying the LLM's responses.Online Phase:

[0038] During the online phase, the guided programming proxy module 300 (referred to as programming proxy) intercepts every communication between the agent's 302 planning / reasoning module 304, tools 306, and memory 308 with the LLM engine 310. The guided programming proxy 300 performs the following functions:Analyze the prompt: The guided programming proxy module 300 examines the prompt 312 to understand the context and the specific task at hand. During the online phase the agent 302 may fill in the prompt templates with the actual input of the task at hand (e.g., user’s task 318). The prompt template and the actual input are analyzed to understand the context and the task. This analysis may be performed applying one of the following techniques (but not limited to): using an embedding similarity (e.g., cosine, Euclidean, etc.) between the full prompt and guiding prompt context, or using an LLM to extract context details from the full prompt (e.g. direct question: “what tools are used in this prompt? What is its scope?” etc.).Select the most suitable guiding prompt: Based on the context and the task, the guided programming proxy module 300 selects the most suitable guiding prompt, if necessary. In embodiments the most suitable guiding prompt may be determined by comparing the context of the prompt template to the context associated with the user suggestions in the guiding prompts. The guiding prompt with the most fitting / similar context is used by the system. Several techniques can be used to compute the similarity of the contexts such as using an embedding distance (e.g., cosine, Euclidean, etc.), by providing a question to an LLM (e.g. “Given this sentence . . . select the most similar among the one below. . . . ”), or a hybrid of both of these approaches.Insert the guiding prompt: If a guiding prompt is deemed appropriate, the guided programming proxy module 300 inserts it to the original prompt to generate a modified prompt 314, effectively combining the agent's inherent capabilities with the user's guidance.Forward modified prompt 314 and LLM Answer: The guided programming proxy module 300 then forwards the modified prompt 314, along with any appended guiding prompt, to the LLM 310 for processing. Once the LLM 310 generates an answer, the module 300 relays the LLM's 310 response back to the agent 302.

[0039] The agent 302 fills a prompt template with content and submits this prompt to the LLM 310. The method according to an embodiment of the present invention intercepts the prompt and employs an LLM to comprehend its context. The vector store 316 contains various guiding prompts along with their own corresponding context descriptions. The guided programming proxy module 300 accesses this vector store 316 to identify the most relevant guiding prompt that aligns with the current context.

[0040] It can also be provided that the selected guiding prompt can be further verified using an LLM (this may be a different LLM than LLM 310). This additional verification step ensures that the chosen guiding prompt is well-suited for the context and task, providing an extra layer of validation before appending it to the agent's prompt for execution. Verification may be performed similar to the verification described above by the LLM using the final version of the prompt that includes the user input (e.g., the selected guiding prompt).

[0041] FIG. 3 shows the operation of an LLM autonomous agent 302 when using guided programming:1. The user-defined task 318 is inserted into the LLM reasoning prompt.2. The scratchpad 320 (containing the LLM reasoning prompt) is sent to the guided programming proxy module 300.3. The guided programming proxy module 300 extracts context information from the prompt 312 and uses the context information to retrieve from the guiding prompt vector store316 the appropriate guiding prompt. In an embodiment, an LLM can be used to further verify the retrieved guiding prompt.4. The placeholder (represented in FIG. 3 as “Guiding Prompt: ***”) in the agent prompt312 is replaced with the retrieved guiding prompt (represented in FIG. 3 as “Guiding Prompt: <- ->”).5. An LLM 310 process the modified prompt 314.6. The modified prompt 314 and answer are inserted into the scratchpad 320.N. The final answer 322 is provided to the user once the task is fully completed.

[0042] Embodiments of the present invention thus provide for general improvements to computers in machine learning systems to provide for guided programming of autonomous agents, as well as improving the performance and functionality of the autonomous agents and machine learning system as a whole. Moreover, embodiments of the present invention can be practically applied to use cases to effect further improvements in a number of technical fields including, but not limited to, Cyber Threat Intelligence (CTI), web searching, performance portability of computer code, medical (e.g., digital medicine, personalized healthcare, AI- assisted drug or vaccine development, etc.), smart cities (e.g., automated traffic or vehicle control, smart districts, smart buildings, smart industrial plants, smart agriculture, energy management, etc.) and other technical applications that use or could benefit from autonomous agents.

[0043] In an exemplary embodiment, the present invention can be applied for Cyber Threat Intelligence (CTI) - web search. A common approach in CTI is the search of web questions about current events or threats. Thus, the task is to find the correct answer with sources to this answer. An LLM-powered autonomous agent (the agent), equipped with the tools “custom search” and “explore link” can support the CTI analyst (the user) with this task. In the best case, the agent finds and chooses the correct link to give the answer with source. Often, the agent does not know how to choose the correct link and can only propose a list of websites that the user can analyze to find the correct answer. The user generally knows which website contains the needed information to answer the question. However, they do not have the possibility to “program” or “guide” the agent to choose this website.

[0044] Guided programming overcomes this technical problem. By applying an embodiment of the present invention, the user can guide the agent to follow their experience and mimic the user’s approach. Guided programming is applied through the following steps:1. The user formulates a guiding prompt with their context, e.g.,“Task: When exploring links for recent attacks refers to national CSIRTs | Context: Exploring Links”2. Offline phase a. Store the guiding prompt in a database. b. Analyze the agent's prompt templates for identifying appropriate insertion points, e.g., insertion point after choosing the tool “explore links”. c. Examine and verify possible injected guiding prompts (optionally: filter inappropriate guiding prompts).3. Online phase a. Analyze the prompt before the LLM input, e.g., find “explore links” tool use.b. Select and insert the task of the guiding prompt “When exploring . . . ”. c. Forward the guiding prompt to the LLM.

[0045] The following is an example of the agent’s behavior without and with guiding prompts. Here, a simple autonomous agent is considered using the following prompt template in its planning / reasoning module.Example:Answer the following questions as best you can. You have access to the following tools: Custom search: Useful for when you need to search the web questions about current events, it provides as output a list of links to be explored.Explore link: Useful when you need to explore a website and understand if it contains contents that can help you answering a question.Use the following format:Question: The input question you must answer.Thought: You should always think about what to do.Action: The action to take, should be one of [custom search, explore link].Action Input: The input to the actionObservation: The result of the action... (this Thought / Action / Action Input / Observation can repeat N times)Thought: I now know the final answerFinal Answer: The final answer to the original input question

[0046] A CTI analyst (the user) requests the agent to answer the following question: Which is the latest hacker attack against Italy?Question: Which is the latest hacker attack against Italy?Thought: I should search the web for recent news.Action: custom_searchAction Input: Which is the latest hacker attack against Italy?Observation: [https: / / www.reuters.com / ..., https: / / www.cnn.com / .... https: / / www.ibtimes.com / .... https: / / www.csirt.gov.it / ...]Thought: I should explore the links to find the latest attack.Action: explore_link https: / / www.reuters.com / ...

[0047] The agent will use the search tool to look up links containing information to be used to answer the question and simply select the first link available. Unfortunately, the first link of the list is not from the Computer Security Incident Response Team of involved entities, which an experienced CTI analyst would use first to look for information.

[0048] Embodiments of the present invention enhance computer functionality of the machine learning system using guiding prompts injected into the agent prompt template that can guide the agent’s behavior to mimic the user’s approach, for example as follows:Question: Which is the latest hacker attack against Italy?Thought: I should search the web for recent news.Action: custom_searchAction Input: Which is the latest hacker attack against Italy?Observation: [https: / / www.reuters.com / ..., https: / / www.cnn.com / .... https: / / www.ibtimes.com / .... https: / / www.csirt.gov.it / ...]Thought: I should explore the links to find the latest attack.Guiding Prompt: When exploring links for recent attacks refers to national CSIRTs.Action: explore_link https: / / www.csirt.gov.it / ...

[0049] The agent will then advantageously behave exactly as the expert CTI analyst.

[0050] In another exemplary embodiment, the present invention can be applied for preprocessing code using LLMs for performance portability. Performance portability of legacy code is a huge problem for academia and industry. Especially in scientific computing many code bases still use Fortran. To use these codes on newer hardware or architectures, they often manually need to be ported, or specialized compilers and code annotations need to be used. An LLM-assisted method can be used to automatically transform old code bases to modem tensor computational codes. The LLM is utilized in 3 components of the model:1. Extracting performance critical code segments.2. Transpiling original code into a tensor computation language (TCL) template3. Optimizing TCL candidates

[0051] By applying an embodiment of the present invention, guiding prompts can be used optimize each of these single steps, respectively.

[0052] For extracting performance critical code segments (1), an embodiment of the present invention can guide the model to more easily find critical code segments. Before using LLMs, this step has been executed by hand by a small number of experts. Their knowledge can be used as hints (guiding prompts) for improving the LLM to more effectively find critical code segments such as loops or double loops.

[0053] Transpiling the original code into a TCL template using LLMs (2) often needs to be done in a feedback loop, since the LLM is rarely able to solve the task in the first try.Sometimes, the LLM is even unable to generate any candidate, e.g., if the used functionality is not available in the TCL (e.g., specialized rounding modes for floating point operations) or the code contains hacks such as pointer arithmetic tricks, integer under- / overflow or other hardwarespecific trickery that the LLM is unable to understand. Experts know of these problems and usually know how to solve or at least how to mitigate them. By applying an embodiment of the present invention, the LLM can be guided to follow the experts’ solutions to reduce the failure rate drastically.

[0054] Optimizing TCL candidates (3) is often not very straight-forward and is usually executed by trial -and-error. Including expert’s knowledge can drastically reduce the number of trials and improve this search procedure by guiding the LLM by suggesting known optimization tricks.

[0055] In an embodiment, the present invention provides a method for guided programming of autonomous agents, comprising the following steps:1. Define guiding prompts as the unions of user know-how / experience / suggestions and context where to apply those suggestions. a. Input the user written hints (e.g., know-how / experience / suggestions). b. Analyze these inputs to assign each hint a specific context. In embodiments, the user written hints can define the suggestions and context portions of the guiding prompt. If the user does not define these portions then the system may utilize a machine learning model or LLM to extract the suggestions and context portions of the guiding prompt. c. The hints combined with their context are the guiding prompts.2. Store the user-provided guiding prompts and their corresponding context in a database.3. Pre-process the LLM powered agent’s prompt templates such that they can be connected with guiding prompts, e.g., insertion points. a. Select best insertion points for the guiding prompts. b. Mark as unsecure a guiding prompt that modifies the capability of the agent, if applicable.4. Intercept communication between agent, tools, memory and LLM.5. Understand the context and select the best guiding prompt to inject.6. Send the modified prompt to the LLM.7. forward the prompt and the answer back into the agent scratchpad, tool and memory.

[0056] Embodiments of the present invention provide for the following improvements and technical advantages over existing technology:1. A guiding prompt consisting of a prompt instruction and a context identifier makes the hard-coded prompt template programmable by including the user’s individual instructions without the necessity of directly changing the prompt templates.a. The prompt instruction is matched with the appropriate insertion points within the agent's prompt templates by computing the similarities of the context identifier and the prompt templates. b. The prompt templates are improved by adding placeholders at the insertion points, which can be replaced with the specific guiding prompts instructions.2. A guided programming proxy intercepting the communication between the agent and the LLM engine. a. The proxy chooses the best fitting guiding prompt by intercepting, reading, and understanding the agent’s LLM request and computing the similarities of the request and the guiding prompt context identifiers. b. The proxy extends the prompt by inserting fitting guiding prompts into the placeholders, thereby increasing the performance by improving the answers of the LLM.3. Enabling companies to utilize their know-how and experience to improve computational performance of their agents.4. Enabling users to guide the agent by influencing its reasoning process.5. Providing that the agent can solve more complicated tasks.6. Providing that the agent can solve tasks more efficiently.7. No need to modify the agent code.8. No need of access to the agent code.

[0057] Wei, Jason, et al., “Chain-of-Thought Prompting Elicits Reasoning in Large Language Models,” arXiv:2201.11903 (2023) describe modifying a prompt template by adding a command of “think before act” into the prompt. This generally improves prompts, but, in contrast to an embodiment of the present invention, cannot be used for specific hints.

[0058] Shinn, Noah, et al., “Reflexion: Language Agents with Verbal Reinforcement Learning,” arXiv:2303. 11366 (2023) describe using reflexion to modify LLM prompt templates. In contrast to embodiments of the present invention, the user can only provide information on whether the agent has succeeded or not. Moreover, the system according to embodiments of the present invention can deep dive into the agents steps and change exactly the parts that need to change.

[0059] Bran, Andres M., et al., “ChemCrow: Augmenting large-language models with chemistry tools,” arXiv:2304.05376 (2023) describe a system which uses very specific prompt templates to achieve the right answer. Each prompt template is fixed and hand-crafted. In contrast, the system according to embodiments of the present invention can use the same model to learn new tasks fully by adapting the prompt templates in a flexible way.

[0060] Referring to FIG. 4, a processing system 400 can include one or more processors 402, memory 404, one or more input / output devices 406, one or more sensors 408, one or more user interfaces 410, and one or more actuators 412. Processing system 400 can be representative of each computing system disclosed herein.

[0061] Processors 402 can include one or more distinct processors, each having one or more cores. Each of the distinct processors can have the same or different structure. Processors 402 can include one or more central processing units (CPUs), one or more graphics processing units (GPUs), circuitry (e.g., application specific integrated circuits (ASICs)), digital signal processors (DSPs), and the like. Processors 402 can be mounted to a common substrate or to multiple different substrates.

[0062] Processors 402 are configured to perform a certain function, method, or operation (e.g., are configured to provide for performance of a function, method, or operation) at least when one of the one or more of the distinct processors is capable of performing operations embodying the function, method, or operation. Processors 402 can perform operations embodying the function, method, or operation by, for example, executing code (e.g., interpreting scripts) stored on memory 404 and / or trafficking data through one or more ASICs. Processors 402, and thus processing system 400, can be configured to perform, automatically, any and all functions, methods, and operations disclosed herein. Therefore, processing system 400 can be configured to implement any of (e.g., all of) the protocols, devices, mechanisms, systems, and methods described herein.

[0063] For example, when the present disclosure states that a method or device performs task “X” (or that task “X” is performed), such a statement should be understood to disclose that processing system 400 can be configured to perform task “X”. Processing system 400 is configured to perform a function, method, or operation at least when processors 402 are configured to do the same.

[0064] Memory 404 can include volatile memory, non-volatile memory, and any other medium capable of storing data. Each of the volatile memory, non-volatile memory, and any other type of memory can include multiple different memory devices, located at multiple distinct locations and each having a different structure. Memory 404 can include remotely hosted (e.g., cloud) storage.

[0065] Examples of memory 404 include a non-transitory computer-readable media such as RAM, ROM, flash memory, EEPROM, any kind of optical storage disk such as a DVD, a Blu- Ray® disc, magnetic storage, holographic storage, a HDD, a SSD, any medium that can be used to store program code in the form of instructions or data structures, and the like. Any and all of the methods, functions, and operations described herein can be fully embodied in the form oftangible and / or non-transitory machine-readable code (e.g., interpretable scripts) saved in memory 404.

[0066] Input-output devices 406 can include any component for trafficking data such as ports, antennas (i.e., transceivers), printed conductive paths, and the like. Input-output devices 406 can enable wired communication via USB®, DisplayPort®, HDMI®, Ethernet, and the like. Input-output devices 406 can enable electronic, optical, magnetic, and holographic, communication with suitable memory 406. Input-output devices 406 can enable wireless communication via WiFi®, Bluetooth®, cellular (e.g., LTE®, CDMA®, GSM®, WiMax®, NFC®), GPS, and the like. Input-output devices 406 can include wired and / or wireless communication pathways.

[0067] Sensors 408 can capture physical measurements of environment and report the same to processors 402. User interface 410 can include displays, physical buttons, speakers, microphones, keyboards, and the like. Actuators 412 can enable processors 402 to control mechanical forces.

[0068] Processing system 400 can be distributed. For example, some components of processing system 400 can reside in a remote hosted network service (e.g., a cloud computing environment) while other components of processing system 400 can reside in a local computing system. Processing system 400 can have a modular design where certain modules include a plurality of the feature s / functions shown in FIG. 4. For example, I / O modules can include volatile memory and one or more processors. As another example, individual processor modules can include read-only-memory and / or local caches.

[0069] While subject matter of the present disclosure has been illustrated and described in detail in the drawings and foregoing description, such illustration and description are to be considered illustrative or exemplary and not restrictive. Any statement made herein characterizing the invention is also to be considered illustrative or exemplary and not restrictive as the invention is defined by the claims. It will be understood that changes and modifications may be made, by those of ordinary skill in the art, within the scope of the following claims, which may include any combination of features from different embodiments described above.

[0070] The terms used in the claims should be construed to have the broadest reasonable interpretation consistent with the foregoing description. For example, the use of the article “a” or “the” in introducing an element should not be interpreted as being exclusive of a plurality of elements. Likewise, the recitation of “or” should be interpreted as being inclusive, such that the recitation of “A or B” is not exclusive of “A and B,” unless it is clear from the context or the foregoing description that only one of A and B is intended. Further, the recitation of “at least one of A, B and C” should be interpreted as one or more of a group of elements consisting of A, Band C, and should not be interpreted as requiring at least one of each of the listed elements A, B and C, regardless of whether A, B and C are related as categories or otherwise. Moreover, the recitation of “A, B and / or C” or “at least one of A, B or C” should be interpreted as including any singular entity from the listed elements, e.g., A, any subset from the listed elements, e.g., A and B, or the entire list of elements A, B and C.

Claims

CLAIMSWhat is claimed is:

1. A computer-implemented method for guided programming of autonomous agents, the computer-implemented method comprising: intercepting a large language model (LLM) prompt between an LLM autonomous agent and an LLM; selecting a guiding prompt from a plurality of guiding prompts to inject into the LLM prompt based on a context of the LLM prompt; sending a modified LLM prompt that includes the selected guiding prompt to the LLM; and forwarding the modified LLM prompt and an answer generated by the LLM to the LLM autonomous agent.

2. The computer-implemented method according to claim 1, wherein selecting the guiding prompt from the plurality of guiding prompts includes examining the LLM prompt to identify the context of the LLM prompt, and computing similarities of the context of the LLM prompt to context identifiers for the guiding prompts to select the guiding prompt based on the similarities.

3. The computer-implemented method according to claim 1 or claim 2, wherein the LLM prompt is associated with a user-defined task, and wherein the method is repeated until the user- defined task is complete.

4. The computer-implemented method according to any of the preceding claims, further comprising defining the plurality of guiding prompts, each of which include a user hint and context identifying where to apply the user hint.

5. The computer-implemented method according to claim 4, further comprising storing the plurality of guiding prompts and corresponding contexts in a database implemented as a vector store.

6. The computer-implemented method according to any of the preceding claims, further comprising determining an insertion point in a prompt template of the LLM autonomous agent, and inserting the selected guiding prompt into the prompt template at the insertion point.

7. The computer-implemented method according to claim 6, wherein determining the insertion point in the prompt template includes comparing the context of the guiding prompt to the context of the prompt template using an embedding distance or providing the context of the guiding prompt and the context of the prompt template to another LLM as a question.

8. The computer-implemented method according to any of the preceding claims, wherein the LLM prompt is pre-processed to inject a guiding prompt placeholder, the method furthercomprising replacing the guiding prompt placeholder of the LLM prompt with the guiding prompt to generate the modified LLM prompt.

9. The computer-implemented method according to any of the preceding claims, further comprising: analyzing the modified LLM prompt to determine whether inserting the selecting guiding prompt causes the modified LLM prompt to be unsafe; and marking the selected guiding prompt as unsafe and excluding future use of the selected guiding prompt.

10. The computer-implemented method according to any of the preceding claims, wherein the LLM autonomous agent includes a working memory configured to receive a user-defined task that is inserted into the LLM prompt, and to receive the modified LLM prompt and an answer generated by the LLM, wherein the modified LLM prompt and the answer comprise a new LLM prompt that is sent to the LLM.

11. The computer-implemented method according to claim 9, wherein the LLM autonomous agent includes tools, and wherein the answer suggests to use one of the tools, the method further comprising invoking the suggested tool in response to receiving the answer.

12. The computer-implemented method according to any of the preceding claims, wherein the LLM autonomous agent includes memory for storing previous iterations of LLM prompts and answers generated by the LLM, and for accessing data sets associated with the LLM prompt.

13. The computer-implemented method according to any of the preceding claims, further comprising, prior to injecting the selected guiding prompt into the LLM prompt, verifying the selected guiding prompt using another LLM.

14. A computer system for guided programming of autonomous agents, the computer system comprising one or more hardware processors which, alone or in combination, are configured to provide for execution of the following steps: intercepting a large language model (LLM) prompt between an LLM autonomous agent and an LLM; selecting a guiding prompt from a plurality of guiding prompts to inject into the LLM prompt based on a context of the LLM prompt; sending a modified LLM prompt that includes the selected guiding prompt to the LLM; and forwarding the modified LLM prompt and an answer generated by the LLM to the LLM autonomous agent.

15. A tangible, non-transitory computer-readable medium having instructions thereon which, upon being executed by one or more processors, provide for guided programming of autonomous agents by execution of the following steps: intercepting a large language model (LLM) prompt between an LLM autonomous agent and an LLM; selecting a guiding prompt from a plurality of guiding prompts to inject into the LLM prompt based on a context of the LLM prompt; sending a modified LLM prompt that includes the selected guiding prompt to the LLM; and forwarding the modified LLM prompt and an answer generated by the LLM to the LLM autonomous agent.