From 6fd58f93ef12df9cca18aed37d306a5588acebd2 Mon Sep 17 00:00:00 2001 From: Ilja Zakharov Date: Wed, 29 Jul 2026 11:00:14 +0200 Subject: [PATCH] docs(quickstart): force tool_choice in OpenAI function-calling example The OpenAI "Function calling" example in connect-llms.mdx left tool_choice at its default ("auto"), so gpt-4o was free to answer questions like "how many r's are in strawberry" directly from its own knowledge instead of calling execute_python. The example still looked like it demonstrated the E2B sandbox, but the `if response_message.tool_calls:` block could be skipped entirely, silently returning an answer that never touched the sandbox. Pass tool_choice explicitly requesting the execute_python function so the example always exercises the sandbox, matching what it claims to show. --- docs/quickstart/connect-llms.mdx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/quickstart/connect-llms.mdx b/docs/quickstart/connect-llms.mdx index adfbc664..468a9f4b 100644 --- a/docs/quickstart/connect-llms.mdx +++ b/docs/quickstart/connect-llms.mdx @@ -102,6 +102,8 @@ response = client.chat.completions.create( model=model, messages=messages, tools=tools, + # Force the model to call execute_python instead of letting it answer directly + tool_choice={"type": "function", "function": {"name": "execute_python"}}, ) # Append the response message to the messages list