@@ -217,7 +217,9 @@ def __init__(
217217 max_guardrail_retries : int = 3 ,
218218 handoffs : Optional [List [Union ['Agent' , 'Handoff' ]]] = None ,
219219 base_url : Optional [str ] = None ,
220- api_key : Optional [str ] = None
220+ api_key : Optional [str ] = None ,
221+ gemini_google_search : bool = False ,
222+ gemini_code_execution : bool = False ,
221223 ):
222224 """Initialize an Agent instance.
223225
@@ -308,6 +310,10 @@ def __init__(
308310 If provided, automatically creates a custom LLM instance. Defaults to None.
309311 api_key (Optional[str], optional): API key for LLM provider. If not provided,
310312 falls back to environment variables. Defaults to None.
313+ gemini_google_search (bool, optional): Enable Google Search grounding for Gemini models.
314+ Defaults to False.
315+ gemini_code_execution (bool, optional): Enable code execution for Gemini models.
316+ Defaults to False.
311317
312318 Raises:
313319 ValueError: If all of name, role, goal, backstory, and instructions are None.
@@ -479,6 +485,10 @@ def __init__(
479485 self .handoffs = handoffs if handoffs else []
480486 self ._process_handoffs ()
481487
488+ # Gemini-specific tools
489+ self .gemini_google_search = gemini_google_search
490+ self .gemini_code_execution = gemini_code_execution
491+
482492 # Check if knowledge parameter has any values
483493 if not knowledge :
484494 self .knowledge = None
@@ -1199,6 +1209,18 @@ def chat(self, prompt, temperature=0.2, tools=None, output_json=None, output_pyd
11991209 tool_param = [openai_tool ]
12001210 logging .debug (f"Converted MCP tool: { tool_param } " )
12011211
1212+ # Add Gemini-specific tools if enabled
1213+ gemini_tools = []
1214+ if self .gemini_google_search :
1215+ gemini_tools .append ({"google_search_retrieval" : {}})
1216+ if self .gemini_code_execution :
1217+ gemini_tools .append ({"code_execution" : {}})
1218+
1219+ if gemini_tools :
1220+ if tool_param is None :
1221+ tool_param = []
1222+ tool_param .extend (gemini_tools )
1223+
12021224 # Store chat history length for potential rollback
12031225 chat_history_length = len (self .chat_history )
12041226
@@ -1517,6 +1539,18 @@ async def achat(self, prompt: str, temperature=0.2, tools=None, output_json=None
15171539 prompt = f"{ prompt } \n \n Knowledge: { knowledge_content } "
15181540
15191541 if self ._using_custom_llm :
1542+ # Add Gemini-specific tools if enabled
1543+ gemini_tools = []
1544+ if self .gemini_google_search :
1545+ gemini_tools .append ({"google_search_retrieval" : {}})
1546+ if self .gemini_code_execution :
1547+ gemini_tools .append ({"code_execution" : {}})
1548+
1549+ if gemini_tools :
1550+ if tools is None :
1551+ tools = []
1552+ tools .extend (gemini_tools )
1553+
15201554 # Store chat history length for potential rollback
15211555 chat_history_length = len (self .chat_history )
15221556
0 commit comments