Skip to content

fix(codex): entrypoint.sh accumulates duplicate config keys on PVC restarts #299

Description

@aakankshaduggal

Problem

The base Codex entrypoint.sh (from PR #251) re-appends model, model_provider, and [model_providers.vllm] to config.toml on every container start. Since config.toml lives on a persistent PVC, multiple rollouts (e.g., the two-patch deployment flow in the MLflow tracing docs) can accumulate duplicate TOML keys, causing:

config.toml:4:1: duplicate key model

Codex refuses to load when this happens.

Workaround: Clear /workspace/.codex/config.toml and do a clean restart.

Root Cause

setup_model_provider() uses sed -i '/^model\s*=/d' to remove existing keys before re-inserting. The \s escape is a GNU sed extension, not POSIX BRE — on some container images it may not match, leaving the old keys in place while new ones are inserted at line 1.

Even when the sed works, the two-patch deployment flow triggers two rollouts in quick succession. If the first rollout's entrypoint writes config and the second rollout starts before the pod is fully replaced, the PVC-backed config can end up with duplicate entries.

Suggested Fix

Add an idempotency guard — check whether keys already exist with the correct values before writing:

if ! grep -q "^model = \"${model}\"" "${config_file}" 2>/dev/null; then
    # remove old + insert new
fi

Or use POSIX-compatible patterns: '/^model[[:space:]]*=/d' instead of '/^model\s*=/d'.

Context

Flagged by @Nehanth during clean-room testing of PR #284 (MLflow tracing). Not a blocker for tracing — this is a base-image issue.

References

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions