2626import com .google .adk .agents .ConfigAgentUtils .ConfigurationException ;
2727import com .google .adk .agents .LlmAgent ;
2828import com .google .adk .events .Event ;
29+ import com .google .adk .plugins .Plugin ;
2930import com .google .adk .runner .InMemoryRunner ;
3031import com .google .adk .runner .Runner ;
3132import com .google .adk .sessions .State ;
@@ -46,6 +47,7 @@ public class AgentTool extends BaseTool {
4647
4748 private final BaseAgent agent ;
4849 private final boolean skipSummarization ;
50+ private final List <Plugin > plugins ;
4951
5052 public static BaseTool fromConfig (ToolArgsConfig args , String configAbsPath )
5153 throws ConfigurationException {
@@ -62,21 +64,32 @@ public static BaseTool fromConfig(ToolArgsConfig args, String configAbsPath)
6264 }
6365
6466 BaseAgent agent = resolvedAgents .get (0 );
65- return AgentTool .create (agent , args .getOrDefault ("skipSummarization" , false ).booleanValue ());
67+ return AgentTool .create (
68+ agent , args .getOrDefault ("skipSummarization" , false ).booleanValue (), ImmutableList .of ());
69+ }
70+
71+ public static AgentTool create (
72+ BaseAgent agent , boolean skipSummarization , List <? extends Plugin > plugins ) {
73+ return new AgentTool (agent , skipSummarization , plugins );
6674 }
6775
6876 public static AgentTool create (BaseAgent agent , boolean skipSummarization ) {
69- return new AgentTool (agent , skipSummarization );
77+ return new AgentTool (agent , skipSummarization , ImmutableList . of () );
7078 }
7179
7280 public static AgentTool create (BaseAgent agent ) {
73- return new AgentTool (agent , false );
81+ return new AgentTool (agent , false , ImmutableList . of () );
7482 }
7583
7684 protected AgentTool (BaseAgent agent , boolean skipSummarization ) {
85+ this (agent , skipSummarization , ImmutableList .of ());
86+ }
87+
88+ protected AgentTool (BaseAgent agent , boolean skipSummarization , List <? extends Plugin > plugins ) {
7789 super (agent .name (), agent .description ());
7890 this .agent = agent ;
7991 this .skipSummarization = skipSummarization ;
92+ this .plugins = ImmutableList .copyOf (plugins != null ? plugins : ImmutableList .of ());
8093 }
8194
8295 @ VisibleForTesting
@@ -159,7 +172,7 @@ public Single<Map<String, Object>> runAsync(Map<String, Object> args, ToolContex
159172 content = Content .fromParts (Part .fromText (input .toString ()));
160173 }
161174
162- Runner runner = new InMemoryRunner (this .agent , toolContext .agentName ());
175+ Runner runner = new InMemoryRunner (this .agent , toolContext .agentName (), this . plugins );
163176 // Session state is final, can't update to toolContext state
164177 // session.toBuilder().setState(toolContext.getState());
165178 return runner
@@ -219,3 +232,4 @@ private void updateState(Map<String, Object> stateDelta, Map<String, Object> sta
219232 });
220233 }
221234}
235+
0 commit comments