How must an instance mask cold-start latency without hiding behavioral differences?

**Date of Record:** 2026 October 27 **Scope:** Applies when an agentic session serves user-facing requests that trigger cold-start initialization (cold model load, cache warmup, or first-request overhead), and the session must mask the latency from users without hiding the fact that the response came from a cold path with potentially different behavior. Does not apply to sessions with warm-only request paths or where cold-start latency is explicitly acceptable.

Core Distinction

The separation between **latency masking** (hiding the initialization time from users to preserve UX) and **behavioral attribution** (revealing that the response was produced by a cold path with potentially different characteristics). Relying on masking alone creates the **Cold-Start Illusion**: the user experiences fast response, but the underlying model or cache was cold, and the response may be behaviorally different (less accurate, less cached, or lower quality) without the user or downstream consumers knowing.

What Was Observed

In latency-sensitive agent architectures, failing to distinguish masking from behavioral attribution produces three primary failure modes:

  1. **Silent Quality Drop:** The first user request after a cold start gets a lower-quality response (cold model has less warm context, cold cache misses), but the user is not told, and their downstream decisions suffer.
  2. **Cache Poisoning:** The cold-path response is cached as if it were a warm-path response, and subsequent users get the lower-quality result even after the system warms up.
  3. **Behavioral Divergence:** Two agents in the same session see different behavior depending on whether their request was a cold-start or warm-path request, and their state diverges without explanation.

Recorded Elements

  1. **`cold_start_flag_receipt`:** A cryptographic marker in the response indicating whether it was produced by a cold or warm path, invisible to end users but available to downstream consumers.
  2. **`warmup_completion_receipt`:** A cryptographic proof of when the system transitioned from cold to warm, allowing cache invalidation and behavior normalization.
  3. **`cold_path_quality_signature`:** The expected quality difference between cold and warm paths (e.g., "cold-path accuracy is 5% lower"), allowing downstream consumers to weight the response.
  4. **`cache_admission_policy_receipt`:** The exact policy for whether cold-path responses are admitted to the cache (usually not), preventing cache poisoning.

Condition of Validity

* **Applies when:** The system has cold-start latency, the cold path produces behaviorally different responses, and downstream consumers need to distinguish. * **Does not apply when:** Cold and warm paths are verified behaviorally identical (only latency differs), or the cold-start latency is acceptable without masking.

Decision Boundary

  1. **Was the response produced by a cold path?** If no, standard response handling applies. If yes, proceed.
  2. **Does the response include the `cold_start_flag_receipt`?** If no, the cold-path origin is hidden. The session must add the flag before serving.
  3. **Is the cold-path response being cached?** If yes, the `cache_admission_policy_receipt` must authorize it, and warmup completion should trigger cache invalidation.
  4. **Conversely, when can cold-path responses be cached without flagging?** Only when the cold-path and warm-path behaviors are verified identical, or the consumer is strictly exploratory and quality variance is acceptable.

Operational Effect

  1. **Behavioral Transparency:** Downstream consumers know when a response came from cold path.
  2. **Cache Integrity:** Cold-path responses are not cached as if warm, preventing poisoning.
  3. **User Experience:** Latency is still masked from end users, preserving UX.
from dataclasses import dataclass
from enum import Enum, auto
import hashlib
import json

class ColdStartVerdict(Enum):
    WARM_PATH = auto()
    COLD_PATH_MASKED = auto()
    COLD_PATH_CACHE_ADMISSION_BLOCKED = auto()
    COLD_PATH_UNFLAGGED = auto()

@dataclass(frozen=True)
class InferenceResponse:
    response_id: str
    cold_start_flag: bool
    cold_start_flag_receipt: str | None
    cache_admission_requested: bool
    cache_admission_authorized: bool

@dataclass(frozen=True)
class ColdStartPolicy:
    require_flag: bool
    require_cache_block: bool

@dataclass(frozen=True)
class ColdStartManifest:
    verdict: ColdStartVerdict
    directive: str
    manifest_digest: str

class ColdStartMaskingGuard:
    @staticmethod
    def _hash(data: str) -> str:
        return hashlib.sha256(data.encode("utf-8")).hexdigest()

    @classmethod
    def evaluate_response(
        cls, response: InferenceResponse, policy: ColdStartPolicy
    ) -> ColdStartManifest:
        
        # Gate 1: Warm path
        if not response.cold_start_flag:
            digest = cls._hash(json.dumps({
                "response": response.response_id,
                "path": "WARM"
            }, sort_keys=True))
            return ColdStartManifest(
                verdict=ColdStartVerdict.WARM_PATH,
                directive=f"PROCEED: Response {response.response_id} from warm path.",
                manifest_digest=digest
            )

        # Gate 2: Flag receipt
        if policy.require_flag and not response.cold_start_flag_receipt:
            return ColdStartManifest(
                verdict=ColdStartVerdict.COLD_PATH_UNFLAGGED,
                directive=f"HALT: Cold-path response {response.response_id} lacks flag receipt.",
                manifest_digest=cls._hash(f"NO_FLAG:{response.response_id}")
            )

        # Gate 3: Cache admission block
        if policy.require_cache_block and response.cache_admission_requested:
            if not response.cache_admission_authorized:
                return ColdStartManifest(
                    verdict=ColdStartVerdict.COLD_PATH_CACHE_ADMISSION_BLOCKED,
                    directive=f"BLOCK: Cold-path response {response.response_id} cache admission not authorized.",
                    manifest_digest=cls._hash(f"CACHE_BLOCK:{response.response_id}")
                )

        # Gate 4: Masked
        digest = cls._hash(json.dumps({
            "response": response.response_id,
            "flag": "COLD",
            "flag_receipt": response.cold_start_flag_receipt,
            "cache_admitted": str(response.cache_admission_authorized)
        }, sort_keys=True))
        
        return ColdStartManifest(
            verdict=ColdStartVerdict.COLD_PATH_MASKED,
            directive=f"PROCEED: Cold-path response {response.response_id} masked with flag.",
            manifest_digest=digest
        )