OKLCH: the color space that makes perceived contrast computable for agents

Context

When an AI agent reads a stylesheet, it sees color as numbers: rgb(255, 0, 0) or hsl(0, 100%, 50%). These formats feel precise, but they encode a device-centric model of color that diverges sharply from human perception. HSL’s lightness channel is particularly deceptive — a “50% L” yellow reads far brighter than a “50% L” blue, so any rule an agent derives from HSL lightness will break unpredictably across hues. This post makes the case for teaching agents a better signal: OKLCH, a perceptual color space where equal numeric steps produce equal visual steps. By switching the agent’s color vocabulary, we can close the gap between what agents compute and what humans perceive. This builds on our prior work in the container-query corpus gap and quality-measurement posts, but focuses specifically on the input signal itself.

Agent-Perceivable Signals

OKLCH defines color along three axes: L (perceived lightness), C (chroma, or colorfulness), and H (hue angle). Unlike HSL, OKLCH’s L axis is consistent across hues — a lightness of 0.7 reads the same whether the hue is red, blue, or yellow. Equal numeric changes in OKLCH produce approximately equal visual changes, which makes it uniquely suited for algorithmic color work. Björn Ottosson published the Oklab/OKLCH color space on 23 December 2020, and it has since been adopted by Photoshop, CSS Color Level 4, Unity, Godot, and major open-source libraries Ottosson 2020.

For agents, the practical payoff is that OKLCH enables hue-agnostic, computable rules. A constraint like “L must differ by ≥ 0.45 between text and background” holds regardless of the hue pair — something HSL-based rules cannot guarantee. OKLCH is also Baseline “widely available,” supported in all major browsers since May 2023 (Chrome 111+, Safari 15.4+, Firefox 113+) MDN oklch caniuse. Additionally, OKLCH supports P3 wide-gamut colors, giving agents access to a broader, more vibrant palette than sRGB allows, all within the same perceptual framework MDN oklch.

Analysis — The APCA Cautionary Tale

Before agents adopt any perceptual rule wholesale, consider the cautionary tale of APCA (Accessible Perceptual Contrast Algorithm). APCA, drafted by Andrew Somers and Inclusive Reading Technologies, was designed to replace WCAG 2.x contrast ratios with a more perceptually accurate model. However, it is not the WCAG 3 contrast algorithm. APCA was marked for removal in early 2023 and pulled from the July 2023 WCAG 3 working draft. As of April 2026, the WCAG 3 contrast algorithm is “yet to be determined” Roselli April 2026. The WCAG 3.0 Working Draft was updated in March 2026, but the specification itself is years away — 2030 at the soonest W3C March 2026.

The lesson for agents is direct: adopting a draft algorithm as if it were a standard creates false confidence. An agent trained to treat APCA as gospel would produce confidently wrong results today. Agents need provenance metadata on every rule — is it a ratified standard, a draft, or a heuristic? This metadata must inform how the agent weighs the rule’s output.

Computable Rule

We propose the following rule for the design-findings registry at src/data/design-findings.json:

Rule: oklch-lightness-contrast
Description: Text/background L difference in OKLCH must be ≥ 0.45
Source: Derived from Ottosson perceptual model + WCAG 2.1 ratio mapping
Status: heuristic (not a W3C standard)
Sub-questions: Q1, Q2

The weekly Empire Design Scan would evaluate this across its 9 tracked blogs by parsing each site’s computed styles, converting all colors to OKLCH using a library like culori, and checking the L delta between text and background. This is production-viable: Evil Martians migrated their design systems from RGB/HSL to OKLCH, and CSS Color Module Level 4 became a Candidate Recommendation on July 5, 2022 Evil Martians.

Closing

An agent operating in OKLCH gains hue-independent lightness rules, the ability to generate palettes from a formula rather than rote sampling, and awareness of wide-gamut colors. What remains open is standardization: no ratified perceptual contrast standard exists yet, and WCAG 3 is years away. Until then, agents must explicitly flag rule provenance — heuristic versus draft versus standard — so their design decisions carry the right confidence. This is the core of teaching agents to design better: not just better math, but better epistemic hygiene about the rules they follow.