From a91f78ffb4143a96e8e32d82b0e31ceec527dbae Mon Sep 17 00:00:00 2001 From: Shobhit Singh Date: Fri, 11 Jul 2025 02:09:40 +0000 Subject: [PATCH 1/2] docs: fix the usage of `BuiltInCodeExecutor` in code snippets --- docs/tools/built-in-tools.md | 8 ++++---- .../snippets/tools/built-in-tools/code_execution.py | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/docs/tools/built-in-tools.md b/docs/tools/built-in-tools.md index 03ef4a6f7..7ee8c140f 100644 --- a/docs/tools/built-in-tools.md +++ b/docs/tools/built-in-tools.md @@ -115,9 +115,9 @@ to use built-in tools with other tools by using multiple agents: model='gemini-2.0-flash', name='CodeAgent', instruction=""" - You're a specialist in Code Execution + You're a specialist in Code Execution """, - code_executor=[BuiltInCodeExecutor], + code_executor=BuiltInCodeExecutor(), ) root_agent = Agent( name="RootAgent", @@ -204,7 +204,7 @@ to use built-in tools with other tools by using multiple agents: model="gemini-2.0-flash", description="Root Agent", tools=[custom_function], - executor=[BuiltInCodeExecutor] # <-- not supported when used with tools + code_executor=BuiltInCodeExecutor() # <-- not supported when used with tools ) ``` @@ -244,7 +244,7 @@ is **not** currently supported: instruction=""" You're a specialist in Code Execution """, - executor=[BuiltInCodeExecutor], + code_executor=BuiltInCodeExecutor(), ) root_agent = Agent( name="RootAgent", diff --git a/examples/python/snippets/tools/built-in-tools/code_execution.py b/examples/python/snippets/tools/built-in-tools/code_execution.py index 0dc525b1e..e1b7b7750 100644 --- a/examples/python/snippets/tools/built-in-tools/code_execution.py +++ b/examples/python/snippets/tools/built-in-tools/code_execution.py @@ -29,7 +29,7 @@ code_agent = LlmAgent( name=AGENT_NAME, model=GEMINI_MODEL, - executor=[BuiltInCodeExecutor], + code_executor=BuiltInCodeExecutor(), instruction="""You are a calculator agent. When given a mathematical expression, write and execute Python code to calculate the result. Return only the final numerical result as plain text, without markdown or code blocks. @@ -39,9 +39,9 @@ # Session and Runner session_service = InMemorySessionService() -session = session_service.create_session( +session = asyncio.run(session_service.create_session( app_name=APP_NAME, user_id=USER_ID, session_id=SESSION_ID -) +)) runner = Runner(agent=code_agent, app_name=APP_NAME, session_service=session_service) From 7f7f65edbc95c98bcabc6e90b8ba46dbad052f28 Mon Sep 17 00:00:00 2001 From: Shobhit Singh Date: Fri, 11 Jul 2025 02:12:10 +0000 Subject: [PATCH 2/2] revert stray spaces --- docs/tools/built-in-tools.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/tools/built-in-tools.md b/docs/tools/built-in-tools.md index 7ee8c140f..41fb2c2e5 100644 --- a/docs/tools/built-in-tools.md +++ b/docs/tools/built-in-tools.md @@ -115,7 +115,7 @@ to use built-in tools with other tools by using multiple agents: model='gemini-2.0-flash', name='CodeAgent', instruction=""" - You're a specialist in Code Execution + You're a specialist in Code Execution """, code_executor=BuiltInCodeExecutor(), )