{"record":{"id":"5abed22ca5628c0f","repo":"BerriAI/litellm","slug":"key-already-has-an-active-data-direction-shadow","errorCode":null,"errorMessage":"Key already has an active {data.direction} shadow eval job ({active.id}). Stop it first.","messagePattern":"Key already has an active (.+?) shadow eval job \\((.+?)\\)\\. Stop it first\\.","errorType":"http","errorClass":"HTTPException","httpStatus":409,"severity":"error","filePath":"litellm/proxy/management_endpoints/auto_router_endpoints.py","lineNumber":688,"sourceCode":"            detail=(\n                f\"api_key_id '{data.api_key_id}' is not a key on this proxy; pass the key's token hash, \"\n                \"the value the key list and key info endpoints report\"\n            ),\n        )\n\n    # A job that expired or exhausted its turn budget stopped sampling on its own, but\n    # still holds its slot in the per-key, per-direction partial unique index until\n    # stamped; free it so a new eval can start. Sweeping both directions is deliberate.\n    await prisma_client.db.execute_raw(_SWEEP_FINISHED_JOBS_SQL, data.api_key_id)\n    active: Final = await prisma_client.db.litellm_shadowevaljob.find_first(\n        where={  # mutable-ok: Prisma filter\n            \"api_key_id\": data.api_key_id,\n            \"direction\": data.direction,\n            \"stopped_at\": None,\n        },\n    )\n    if active is not None:\n        raise HTTPException(\n            status_code=409,\n            detail=f\"Key already has an active {data.direction} shadow eval job ({active.id}). Stop it first.\",\n        )\n    now: Final = datetime.now(timezone.utc)\n    try:\n        job: Final = await prisma_client.db.litellm_shadowevaljob.create(\n            data={  # mutable-ok: Prisma payload\n                \"api_key_id\": data.api_key_id,\n                \"router_name\": data.router_name,\n                \"direction\": data.direction,\n                \"baseline_model\": data.baseline_model,\n                \"judge_model\": data.judge_model,\n                \"shadow_percentage\": data.shadow_percentage,\n                \"max_turns\": data.max_turns,\n                \"created_by\": user_api_key_dict.user_id,\n                \"ends_at\": now + timedelta(days=data.duration_days),\n            }\n        )","sourceCodeStart":670,"sourceCodeEnd":706,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/proxy/management_endpoints/auto_router_endpoints.py#L670-L706","documentation":"Error \"Key already has an active {data.direction} shadow eval job ({active.id}). Stop it first.\" thrown in BerriAI/litellm.","triggerScenarios":"Thrown at litellm/proxy/management_endpoints/auto_router_endpoints.py:688 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Stop the existing shadow eval job for the key before starting a new one.","Reuse the active job instead of creating another."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}