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 1616
1717package com .google .adk .tools ;
1818
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}. */
2022public 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." )
2144 public static void exitLoop (ToolContext toolContext ) {
22- // Exits the loop.
23- // Call this function only when you are instructed to do so.
2445 toolContext .setActions (toolContext .actions ().toBuilder ().escalate (true ).build ());
2546 }
2647
Original file line number Diff line number Diff line change 2525import com .google .adk .agents .SequentialAgent ;
2626import com .google .adk .tools .AgentTool ;
2727import com .google .adk .tools .BaseTool ;
28+ import com .google .adk .tools .ExitLoopTool ;
2829import com .google .adk .tools .GoogleSearchTool ;
2930import com .google .adk .tools .LoadArtifactsTool ;
3031import java .util .Map ;
@@ -97,6 +98,7 @@ private void initializePreWiredEntries() {
9798
9899 registerAdkToolInstance ("google_search" , new GoogleSearchTool ());
99100 registerAdkToolInstance ("load_artifacts" , new LoadArtifactsTool ());
101+ registerAdkToolInstance ("exit_loop" , ExitLoopTool .INSTANCE );
100102
101103 registerAdkToolClass (AgentTool .class );
102104 // TODO: add all python tools that also exist in Java.
You can’t perform that action at this time.
0 commit comments