 | I will briefly introduce the concept of strategies. While reviewing questions during Andrey's talk, I noticed a question about what a strategy is. Beyond the visuals and components I've mentioned, a strategy is straightforward. The basic agent setup includes an AI agent, a prompt executor, and a strategy, which is currently the simplest default one. We also have other defaults, like the React strategy, which incorporates reasoning steps after certain iterations. The default strategy simply performs basic loop iterations. I will demonstrate how to build a precise, custom strategy that remains simple and effective. First, I will create a strategy using the strategy DSL builder. For both the strategy and the nodes, I need to specify their types. While types can be automatically deduced from context, I will explicitly state that I am building a strategy to convert a string to an integer. I will name this strategy “my strategy.” Inside the strategy, I will create a few nodes. The first node will take a string and convert it to an integer using the .toInt() function. I apologize for the slowness of my IDE. This node takes a string input and produces an integer output. Next, I will create another node for incrementing the integer. It’s important to use “by” instead of an equal sign for the nodes, as this allows for deducing node names from variable names, which is one of the strengths of the Kotlin DSL. You can provide different names for the nodes, which represent the steps in your agentic algorithm. However, with Kotlin, you can leverage the delegating operator to automatically use the variable name as the node name. The increment node takes an integer and returns the next integer. Now, I will connect the nodes by creating edges. The node start, which is always present in the strategy, will connect to the “toInt” node. From “toInt,” I will connect to the increment node, and finally, from the increment node, I will connect to the node finish. This strategy performs a simple operation: it takes a string, parses it, and produces the next integer. For instance, if you pass the string “100” to this agent, it will output “101.” You must provide the strategy name, “my strategy,” and everything is type-safe. If I change the type of the strategy, the nodes will become incompatible. For example, if the start node outputs an integer while “toInt” expects a string, the code will not compile. This illustrates the DSL capabilities of Kotlin, which are advantageous for agentic development. Now, let’s move on to a more complex example: building the out-of-the-box default strategy that you have seen in the previous visuals. This strategy includes three required nodes: “ask LLM,” which initiates the process; “call tool,” which executes any tool provided to the agent; and “send result,” which returns the tool’s result back to the LLM. I will create edges starting from the node start to “ask LLM,” as this is where the process begins. The LLM will then determine the next step. Let me copy this line. While I wait for my IDE to respond, I can explain the roles of the node start and node end. These are special nodes that serve as the input and output for our strategy. |