File tree Expand file tree Collapse file tree 2 files changed +26
-3
lines changed
core/src/main/java/com/google/adk Expand file tree Collapse file tree 2 files changed +26
-3
lines changed Original file line number Diff line number Diff line change 16
16
17
17
package com .google .adk .tools ;
18
18
19
- /** Exits the loop. */
19
+ import com .google .adk .tools .Annotations .Schema ;
20
+
21
+ /** Tool for exiting execution of {@link com.google.adk.agents.LoopAgent}. */
20
22
public final class ExitLoopTool {
23
+ public static final FunctionTool INSTANCE = FunctionTool .create (ExitLoopTool .class , "exitLoop" );
24
+
25
+ /**
26
+ * Exit the {@link com.google.adk.agents.LoopAgent} execution.
27
+ *
28
+ * <p>Usage example in an LlmAgent:
29
+ *
30
+ * <pre>{@code
31
+ * LlmAgent subAgent = LlmAgent.builder()
32
+ * .addTool(ExitLoopTool.INSTANCE)
33
+ * .build();
34
+ * }</pre>
35
+ *
36
+ * <p>The @Schema name and description is consistent with the Python version.
37
+ *
38
+ * <p>Refer to:
39
+ * https://github.com/google/adk-python/blob/main/src/google/adk/tools/exit_loop_tool.py
40
+ */
41
+ @ Schema (
42
+ name = "exit_loop" ,
43
+ description = "Exits the loop.\n \n Call this function only when you are instructed to do so." )
21
44
public static void exitLoop (ToolContext toolContext ) {
22
- // Exits the loop.
23
- // Call this function only when you are instructed to do so.
24
45
toolContext .setActions (toolContext .actions ().toBuilder ().escalate (true ).build ());
25
46
}
26
47
Original file line number Diff line number Diff line change 25
25
import com .google .adk .agents .SequentialAgent ;
26
26
import com .google .adk .tools .AgentTool ;
27
27
import com .google .adk .tools .BaseTool ;
28
+ import com .google .adk .tools .ExitLoopTool ;
28
29
import com .google .adk .tools .GoogleSearchTool ;
29
30
import com .google .adk .tools .LoadArtifactsTool ;
30
31
import java .util .Map ;
@@ -97,6 +98,7 @@ private void initializePreWiredEntries() {
97
98
98
99
registerAdkToolInstance ("google_search" , new GoogleSearchTool ());
99
100
registerAdkToolInstance ("load_artifacts" , new LoadArtifactsTool ());
101
+ registerAdkToolInstance ("exit_loop" , ExitLoopTool .INSTANCE );
100
102
101
103
registerAdkToolClass (AgentTool .class );
102
104
// TODO: add all python tools that also exist in Java.
You can’t perform that action at this time.
0 commit comments