diff --git a/k8s/helm/commonly/templates/agents/cloud-codex-deployment.yaml b/k8s/helm/commonly/templates/agents/cloud-codex-deployment.yaml index 369b00db..0a58edc9 100644 --- a/k8s/helm/commonly/templates/agents/cloud-codex-deployment.yaml +++ b/k8s/helm/commonly/templates/agents/cloud-codex-deployment.yaml @@ -147,25 +147,35 @@ spec: EOF chmod 600 /state/.commonly/tokens/${COMMONLY_AGENT_NAME}.json - # Wait for codex auth.json. ChatGPT binds OAuth to the IP that - # ran device-auth; running `codex login --device-auth` INSIDE - # this pod is the whole point. If auth.json is missing, sit - # idle and log clear instructions so the operator's first - # `kubectl exec` shows them exactly what to do. - if [ ! -s /state/.codex/auth.json ]; then - echo "[cloud-codex] no codex auth.json on PVC — waiting for device-auth" - echo "[cloud-codex] run this once to bind the cluster session:" - echo "[cloud-codex] kubectl exec -n {{ include "commonly.namespace" $ }} -it deploy/cloud-codex-{{ $name }} -- codex login --device-auth" - echo "[cloud-codex] (after completing in browser, the pod will resume on next reboot)" - # Sleep loop so operator can exec in. Restart-on-success is the - # cleanest UX — when auth.json appears, we want to re-enter the - # main path, and the simplest way to do that is a fresh boot. - while [ ! -s /state/.codex/auth.json ]; do sleep 10; done - echo "[cloud-codex] auth.json present — restarting to enter run loop" - exit 0 + # Seed ~/.codex/config.toml so codex CLI routes its model calls + # through LiteLLM instead of straight to chatgpt.com. The LiteLLM + # pod already holds cluster-IP-bound auth.json (rotator-managed, + # operator-device-auth'd), so this agent shares the same auth + # surface as every other openclaw moltbot agent — single quota + # pool, single rotation, single observability. + # + # Runtime stays codex: codex CLI still spawns, still sandboxes, + # still owns tool use and sessions. Only the HTTPS layer is proxied. + cat > /state/.codex/config.toml <.litellmBaseUrl. + litellmBaseUrl: http://litellm:4000/v1 # Per-agent map. Each key is the agent name that maps to an # AgentInstallation already created via /api/registry/install. The # token secret should be pre-populated with the cm_agent_* runtime