diff --git a/infra/ai-stack/bootstrap-omniroute.sh b/infra/ai-stack/bootstrap-omniroute.sh index 0f74acc..e5e8770 100644 --- a/infra/ai-stack/bootstrap-omniroute.sh +++ b/infra/ai-stack/bootstrap-omniroute.sh @@ -594,6 +594,25 @@ PY echo "OmniRoute combo ${combo_name}: configured with ${model_count} runtime-validated model(s)" } +remove_combo_if_exists() { + local cookie_jar="$1" + local auth_header="$2" + local combo_name="$3" + local body_file="$4" + local existing_id + local delete_status + + if existing_id="$(combo_id_for "${cookie_jar}" "${auth_header}" "${combo_name}" "${body_file}" 2>/dev/null)" && [[ -n "${existing_id}" ]]; then + delete_status="$(api_delete "${cookie_jar}" "${auth_header}" "/api/combos/${existing_id}" "${body_file}")" + if [[ "${delete_status}" != "200" && "${delete_status}" != "204" && "${delete_status}" != "404" ]]; then + echo "Failed to remove stale OmniRoute combo ${combo_name}; DELETE HTTP ${delete_status}." >&2 + sed -n '1,3p' "${body_file}" >&2 || true + return 1 + fi + echo "OmniRoute combo ${combo_name}: removed stale combo" + fi +} + write_model_routes_file() { local routes_json="$1" local fast_json="$2" @@ -697,6 +716,8 @@ print( sys.exit(0 if fast or smart else 1) PY then + remove_combo_if_exists "${cookie_jar}" "${auth_header}" "agent-fast-free" "${body_file}" + remove_combo_if_exists "${cookie_jar}" "${auth_header}" "agent-smart-free" "${body_file}" write_invalid_model_routes_file "${validated_routes_json}" "${MODEL_ROUTES_FILE}" echo "No OmniRoute models passed runtime validation; refusing to keep or create stale AI routes." >&2 echo "Check provider quota/cooldown or seed a known-good provider key, then rerun ./jeannie deploy-ai-stack." >&2