BerriAI/litellm · error · HTTPException

Key already has an active {data.direction} shadow eval job (

Error message

Key already has an active {data.direction} shadow eval job ({active.id}). Stop it first.

What it means

Error "Key already has an active {data.direction} shadow eval job ({active.id}). Stop it first." thrown in BerriAI/litellm.

Source

Thrown at litellm/proxy/management_endpoints/auto_router_endpoints.py:688

            detail=(
                f"api_key_id '{data.api_key_id}' is not a key on this proxy; pass the key's token hash, "
                "the value the key list and key info endpoints report"
            ),
        )

    # A job that expired or exhausted its turn budget stopped sampling on its own, but
    # still holds its slot in the per-key, per-direction partial unique index until
    # stamped; free it so a new eval can start. Sweeping both directions is deliberate.
    await prisma_client.db.execute_raw(_SWEEP_FINISHED_JOBS_SQL, data.api_key_id)
    active: Final = await prisma_client.db.litellm_shadowevaljob.find_first(
        where={  # mutable-ok: Prisma filter
            "api_key_id": data.api_key_id,
            "direction": data.direction,
            "stopped_at": None,
        },
    )
    if active is not None:
        raise HTTPException(
            status_code=409,
            detail=f"Key already has an active {data.direction} shadow eval job ({active.id}). Stop it first.",
        )
    now: Final = datetime.now(timezone.utc)
    try:
        job: Final = await prisma_client.db.litellm_shadowevaljob.create(
            data={  # mutable-ok: Prisma payload
                "api_key_id": data.api_key_id,
                "router_name": data.router_name,
                "direction": data.direction,
                "baseline_model": data.baseline_model,
                "judge_model": data.judge_model,
                "shadow_percentage": data.shadow_percentage,
                "max_turns": data.max_turns,
                "created_by": user_api_key_dict.user_id,
                "ends_at": now + timedelta(days=data.duration_days),
            }
        )

View on GitHub (pinned to 77b7c6c40c)

Solutions

  1. Stop the existing shadow eval job for the key before starting a new one.
  2. Reuse the active job instead of creating another.

When it happens

Trigger: Thrown at litellm/proxy/management_endpoints/auto_router_endpoints.py:688 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18). Data as JSON: /api/errors/5abed22ca5628c0f. Report an issue: GitHub.