Databricks GLM (/glm)
Make coding agents use Databricks-hosted GLM with full tool calling via a local patch proxy.
Why a proxy
Databricks SSE often omits "model" on tool_calls chunks. Strict clients fail with serialization error: missing field model. Proxy on 127.0.0.1:8787 injects model.
Paths
| Item | Path |
|---|---|
| Proxy | ~/.grok/proxies/databricks_glm_proxy.py |
| Durable config | ~/.grok/proxies/glm.env (tokens — never commit) |
| Ensure | ~/.grok/proxies/ensure-proxy.ps1 / ensure-proxy.sh |
| Change config | ~/.grok/proxies/change-config.ps1 / change-config.sh |
| Grok model id | databricks-glm |
| Auth | DATABRICKS_TOKEN + glm.env |
Arguments
| Arg | Action |
|---|---|
(none) / start |
Ensure proxy + remind /model databricks-glm |
status |
Show masked token, upstream, model, port, listening? |
stop |
Kill listener on proxy port (confirm first) |
switch |
Remind model switch only |
change / config |
Interactive: ask user for token, URLs, model; save + restart proxy |
install |
Re-run package install |
/glm change (or /glm config) — REQUIRED FLOW
When user runs /glm change, /glm config, or asks to change token / base URL / model:
A. Collect settings (ask the user — do not invent secrets)
Ask one field at a time (chat or structured questions). Show current values first via status (mask token).
- Access token (
DATABRICKS_TOKEN) — Databricks PAT / bearer. User may say "keep" to leave unchanged. - Upstream base URL (
DATABRICKS_UPSTREAM) — Databricks OpenAI-compatible root, e.g.https://dbc-XXXX.cloud.databricks.com/ai-gateway/mlflow/v1(no/chat/completionssuffix). - API model id (
DATABRICKS_DEFAULT_MODEL) — e.g.system.ai.glm-5-2(sent as JSON"model"). - Local proxy host (default
127.0.0.1). - Local proxy port (default
8787). - Grok local base_url (default
http://127.0.0.1:8787— must point at proxy, not Databricks direct). - Persist to User env? Yes/No (Windows User env / shell profile).
If user only wants one field changed, only ask that field; pass only those flags to the script.
B. Apply (Windows)
powershell -NoProfile -ExecutionPolicy Bypass -File $env:USERPROFILE\.grok\proxies\change-config.ps1 `
-NonInteractive -RestartProxy -SetUserEnv `
-Token "<from user or omit to keep>" `
-Upstream "<url>" `
-ApiModel "<model id>" `
-ProxyHost "127.0.0.1" `
-ProxyPort "8787" `
-GrokLocalBaseUrl "http://127.0.0.1:8787"
Rules for flags:
- Only pass
-Tokenif user provided a new token (never log full token). - If user said keep token: omit
-Tokenentirely. - Always pass fields they changed.
- Prefer
-SetUserEnvwhen user wants persistence across terminals. - Always
-RestartProxyafter URL/token change so proxy reloadsglm.env.
Status only:
powershell -NoProfile -File $env:USERPROFILE\.grok\proxies\change-config.ps1 -StatusOnly
Interactive terminal (user runs themselves):
powershell -NoProfile -File $env:USERPROFILE\.grok\proxies\change-config.ps1
C. Apply (Unix)
# Interactive:
bash ~/.grok/proxies/change-config.sh
# Or export vars then:
DATABRICKS_TOKEN='...' DATABRICKS_UPSTREAM='...' DATABRICKS_DEFAULT_MODEL='...' \
bash ~/.grok/proxies/change-config.sh --non-interactive --restart --set-profile
D. After change
- Confirm status (masked).
- Tell user: Grok
/model databricks-glm; new session if API model id changed. - Never write tokens into git, SKILL.md, AGENTS.md, chat logs if avoidable.
/glm start / default
- Status / token check (
change-config.ps1 -StatusOnlyor env). ensure-proxy.ps1/ensure-proxy.sh./model databricks-glm.
/glm status
powershell -NoProfile -File $env:USERPROFILE\.grok\proxies\change-config.ps1 -StatusOnly
/glm stop
Confirm, then kill process listening on PROXY_PORT (default 8787).
Failures
| Symptom | Fix |
|---|---|
missing field model |
Proxy down or Grok base_url is Databricks direct → /glm change fix local base_url + start |
| 401 | Bad token → /glm change |
| Wrong model | /glm change API model id |
| Connection refused | /glm start |
Do not
- Store tokens in repos.
- Point Grok
base_urlat Databricks direct for tool-heavy turns. - Print full access tokens in replies (mask: first/last 4 chars only).