The experiment fails before it starts if you cannot say which prompt produced a given response. System prompts set role, constraints and output format before the user says anything, which is why a small edit can move output format, refusal rate, latency and cost at the same time (Currai). Treat each prompt as a versioned object with a stable identifier, and resolve the active version at request time rather than at deploy time. Prompt management tooling exists precisely so teams can change prompts at runtime, roll out to segments and roll back without a redeploy (LaunchDarkly).
The minimum viable instrumentation is five fields per request: a request ID, the resolved prompt version, the variant label used by the experiment, a binary failure flag and a latency in milliseconds. Write them as structured log fields, not as text buried in a message string, so aggregation is a group-by rather than a parsing project.
Keep the resolution step deterministic within a request. Resolve the variant once, pin it for the whole conversation, and pass the same identifier into every downstream call and trace. Mixing variants inside one session confuses both users and analysis.
One trap deserves its own warning: keep the prompt prefix stable when you can. Even a single-token difference can invalidate cached prefix computation from that token onward, and cached versus uncached input tokens can differ in price by roughly an order of magnitude on some providers (Manus). If variant A and variant B share a long common preamble, put the differing instructions at the end so most of the prefix still caches.
Two further habits keep the data honest. First, log the version that was actually used, not the version you intended to use. A fallback path that silently serves a cached prompt under a different name will corrupt the split. Second, log the prompt text hash alongside the version label. If someone edits the prompt in place without bumping the version, the hash mismatch makes the mistake visible in the logs rather than invisible in the results.



