Skip to content

Commit ae18ef6

Browse files
docs: fix the usage of BuiltInCodeExecutor in code snippets (#503)
* docs: fix the usage of `BuiltInCodeExecutor` in code snippets * revert stray spaces --------- Co-authored-by: Lavi Nigam <[email protected]>
1 parent 90bde3c commit ae18ef6

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

docs/tools/built-in-tools.md

Lines changed: 3 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-
code_executor=[BuiltInCodeExecutor],
120+
code_executor=BuiltInCodeExecutor(),
121121
)
122122
root_agent = Agent(
123123
name="RootAgent",
@@ -204,7 +204,7 @@ to use built-in tools with other tools by using multiple agents:
204204
model="gemini-2.0-flash",
205205
description="Root Agent",
206206
tools=[custom_function],
207-
executor=[BuiltInCodeExecutor] # <-- not supported when used with tools
207+
code_executor=BuiltInCodeExecutor() # <-- not supported when used with tools
208208
)
209209
```
210210

@@ -244,7 +244,7 @@ is **not** currently supported:
244244
instruction="""
245245
You're a specialist in Code Execution
246246
""",
247-
executor=[BuiltInCodeExecutor],
247+
code_executor=BuiltInCodeExecutor(),
248248
)
249249
root_agent = Agent(
250250
name="RootAgent",

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
code_agent = LlmAgent(
3030
name=AGENT_NAME,
3131
model=GEMINI_MODEL,
32-
executor=[BuiltInCodeExecutor],
32+
code_executor=BuiltInCodeExecutor(),
3333
instruction="""You are a calculator agent.
3434
When given a mathematical expression, write and execute Python code to calculate the result.
3535
Return only the final numerical result as plain text, without markdown or code blocks.
@@ -39,9 +39,9 @@
3939

4040
# Session and Runner
4141
session_service = InMemorySessionService()
42-
session = session_service.create_session(
42+
session = asyncio.run(session_service.create_session(
4343
app_name=APP_NAME, user_id=USER_ID, session_id=SESSION_ID
44-
)
44+
))
4545
runner = Runner(agent=code_agent, app_name=APP_NAME, session_service=session_service)
4646

4747

0 commit comments

Comments
 (0)