Skip to content

Commit da5ce68

Browse files
fix: code executor examples for python (#377)
* fix: code executor examples for python * fix: updated snippet for code executor --------- Co-authored-by: Joe Fernandez <[email protected]>
1 parent 75b6d8a commit da5ce68

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

docs/tools/built-in-tools.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ to use built-in tools with other tools by using multiple agents:
117117
instruction="""
118118
You're a specialist in Code Execution
119119
""",
120-
tools=[BuiltInCodeExecutor],
120+
code_executor=BuiltInCodeExecutor(),
121121
)
122122
root_agent = Agent(
123123
name="RootAgent",
@@ -203,7 +203,8 @@ to use built-in tools with other tools by using multiple agents:
203203
name="RootAgent",
204204
model="gemini-2.0-flash",
205205
description="Root Agent",
206-
tools=[custom_function, BuiltInCodeExecutor], # <-- BuiltInCodeExecutor not supported when used with tools
206+
tools=[custom_function],
207+
code_executor=BuiltInCodeExecutor() # <-- not supported when used with tools
207208
)
208209
```
209210

@@ -243,7 +244,7 @@ is **not** currently supported:
243244
instruction="""
244245
You're a specialist in Code Execution
245246
""",
246-
tools=[BuiltInCodeExecutor],
247+
code_executor=BuiltInCodeExecutor(),
247248
)
248249
root_agent = Agent(
249250
name="RootAgent",

examples/python/snippets/tools/built-in-tools/code_execution.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@
4141
session_service = InMemorySessionService()
4242
session = asyncio.run(session_service.create_session(
4343
app_name=APP_NAME, user_id=USER_ID, session_id=SESSION_ID
44-
))
45-
runner = Runner(agent=code_agent, app_name=APP_NAME, session_service=session_service)
46-
44+
)
45+
runner = Runner(agent=code_agent, app_name=APP_NAME,
46+
session_service=session_service)
4747

4848
# Agent Interaction (Async)
4949
async def call_agent_async(query):
@@ -89,7 +89,8 @@ async def call_agent_async(query):
8989
final_response_text = event.content.parts[0].text.strip()
9090
print(f"==> Final Agent Response: {final_response_text}")
9191
else:
92-
print("==> Final Agent Response: [No text content in final event]")
92+
print(
93+
"==> Final Agent Response: [No text content in final event]")
9394

9495
except Exception as e:
9596
print(f"ERROR during agent run: {e}")

0 commit comments

Comments
 (0)