mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-29 21:48:03 +02:00
2.2 KiB
2.2 KiB
summary, read_when, title
| summary | read_when | title | |||
|---|---|---|---|---|---|
| code_execution -- run sandboxed remote Python analysis with xAI |
|
Code Execution |
Code Execution
code_execution runs sandboxed remote Python analysis on xAI's Responses API.
This is different from local exec:
execruns shell commands on your machine or nodecode_executionruns Python in xAI's remote sandbox
Use code_execution for:
- calculations
- tabulation
- quick statistics
- chart-style analysis
- analyzing data returned by
x_searchorweb_search
Do not use it when you need local files, your shell, your repo, or paired
devices. Use exec for that.
Setup
You need an xAI API key. Any of these work:
XAI_API_KEYplugins.entries.xai.config.webSearch.apiKey
Example:
{
plugins: {
entries: {
xai: {
config: {
webSearch: {
apiKey: "xai-...",
},
codeExecution: {
enabled: true,
model: "grok-4-1-fast",
maxTurns: 2,
timeoutSeconds: 30,
},
},
},
},
},
}
How To Use It
Ask naturally and make the analysis intent explicit:
Use code_execution to calculate the 7-day moving average for these numbers: ...
Use x_search to find posts mentioning OpenClaw this week, then use code_execution to count them by day.
Use web_search to gather the latest AI benchmark numbers, then use code_execution to compare percent changes.
The tool takes a single task parameter internally, so the agent should send
the full analysis request and any inline data in one prompt.
Limits
- This is remote xAI execution, not local process execution.
- It should be treated as ephemeral analysis, not a persistent notebook.
- Do not assume access to local files or your workspace.
- For fresh X data, use
x_searchfirst.