Skip to content

Commit 36fd2ab

Browse files
default to 5.2
1 parent 099ff48 commit 36fd2ab

1 file changed

Lines changed: 69 additions & 2 deletions

File tree

docs/agents/openclaw-gateway.mdx

Lines changed: 69 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ const sandbox = await Sandbox.create('openclaw', {
2424
})
2525

2626
// 2. Set the default model
27-
await sandbox.commands.run('openclaw config set agents.defaults.model.primary openai/gpt-5.3-codex')
27+
await sandbox.commands.run('openclaw config set agents.defaults.model.primary openai/gpt-5.2')
2828

2929
// 3. Start the gateway with token auth
3030
sandbox.commands.run(
@@ -58,7 +58,7 @@ sandbox = Sandbox.create("openclaw", envs={
5858
}, timeout=3600)
5959

6060
# 2. Set the default model
61-
sandbox.commands.run("openclaw config set agents.defaults.model.primary openai/gpt-5.3-codex")
61+
sandbox.commands.run("openclaw config set agents.defaults.model.primary openai/gpt-5.2")
6262

6363
# 3. Start the gateway with token auth
6464
sandbox.commands.run(
@@ -158,6 +158,73 @@ Once approved, the browser connects and the gateway UI loads.
158158
| `--token <value>` | The auth token (passed as `?token=` in the URL) |
159159
| `--port <number>` | Gateway listen port (default: `18789`) |
160160

161+
## How to restart the gateway
162+
163+
Use this when the gateway is already running and you want a clean restart (for example, after changing model or env settings).
164+
165+
<Info>
166+
We can't use the `openclaw gateway restart` command here. Some SDK environments cannot target a specific Unix user in `commands.run`. The commands below use the default command user context.
167+
</Info>
168+
169+
<CodeGroup>
170+
```typescript JavaScript & TypeScript
171+
const TOKEN = process.env.OPENCLAW_APP_TOKEN || 'my-gateway-token'
172+
const PORT = 18789
173+
174+
// 1) Kill existing gateway processes if present
175+
await sandbox.commands.run(
176+
`bash -lc 'for p in "[o]penclaw gateway" "[o]penclaw-gateway"; do for pid in $(pgrep -f "$p" || true); do kill "$pid" >/dev/null 2>&1 || true; done; done'`
177+
)
178+
await new Promise((r) => setTimeout(r, 1000))
179+
180+
// 2) Start gateway again
181+
await sandbox.commands.run(
182+
`openclaw gateway --allow-unconfigured --bind lan --auth token --token ${TOKEN} --port ${PORT}`,
183+
{ background: true }
184+
)
185+
186+
// 3) Wait for listening socket
187+
for (let i = 0; i < 45; i++) {
188+
const probe = await sandbox.commands.run(
189+
`bash -lc 'ss -ltn | grep -q ":${PORT} " && echo ready || echo waiting'`
190+
)
191+
if (probe.stdout.trim() === 'ready') break
192+
await new Promise((r) => setTimeout(r, 1000))
193+
}
194+
```
195+
```python Python
196+
import os, time
197+
198+
TOKEN = os.environ.get("OPENCLAW_APP_TOKEN", "my-gateway-token")
199+
PORT = 18789
200+
201+
# 1) Kill existing gateway processes if present
202+
sandbox.commands.run(
203+
"""bash -lc 'for p in "[o]penclaw gateway" "[o]penclaw-gateway"; do
204+
for pid in $(pgrep -f "$p" || true); do
205+
kill "$pid" >/dev/null 2>&1 || true
206+
done
207+
done'"""
208+
)
209+
time.sleep(1)
210+
211+
# 2) Start gateway again
212+
sandbox.commands.run(
213+
f"openclaw gateway --allow-unconfigured --bind lan --auth token --token {TOKEN} --port {PORT}",
214+
background=True,
215+
)
216+
217+
# 3) Wait for listening socket
218+
for _ in range(45):
219+
probe = sandbox.commands.run(
220+
f'bash -lc \'ss -ltn | grep -q ":{PORT} " && echo ready || echo waiting\''
221+
)
222+
if probe.stdout.strip() == "ready":
223+
break
224+
time.sleep(1)
225+
```
226+
</CodeGroup>
227+
161228
## Related
162229

163230
<CardGroup cols={4}>

0 commit comments

Comments
 (0)