Skip to content

The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]

Fix flaky proxy_e2e_azure_batches_tests: populate _hidden_params for DB-cached batch retrieval

yuneng-jiang31e6393458c9
diff --git a/.circleci/config.yml b/.circleci/config.yml
index 23db0b1ed4e..f38111e28df 100644
--- a/.circleci/config.yml
+++ b/.circleci/config.yml
@@ -3817,7 +3817,7 @@ jobs:
--maxfail=3 \
--durations=10 \
--junitxml=test-results/junit.xml
- no_output_timeout: 30m
+ no_output_timeout: 15m
upload-coverage:
docker:
diff --git a/litellm/proxy/batches_endpoints/endpoints.py b/litellm/proxy/batches_endpoints/endpoints.py
index 32501fdc54b..04358f136a9 100644
--- a/litellm/proxy/batches_endpoints/endpoints.py
+++ b/litellm/proxy/batches_endpoints/endpoints.py
@@ -412,6 +412,22 @@ async def retrieve_batch( # noqa: PLR0915
"cancelled",
"expired",
]:
+ # Populate _hidden_params so managed files hook can translate IDs.
+ # When the response comes from the DB, _hidden_params is empty.
+ # Only set if output_file_id is still a raw provider ID (not yet unified).
+ # The DB may store unified IDs after a previous hook run; setting
+ # _hidden_params in that case would cause double-encoding.
+ if unified_batch_id:
+ _output_fid = getattr(response, "output_file_id", None)
+ _needs_translation = _output_fid and not _is_base64_encoded_unified_file_id(_output_fid)
+ if _needs_translation:
+ response._hidden_params["unified_batch_id"] = unified_batch_id
+ model_id_from_batch = get_model_id_from_unified_batch_id(
+ unified_batch_id
+ )
+ if model_id_from_batch:
+ response._hidden_params["model_id"] = model_id_from_batch
+
# Call hooks and return
response = await proxy_logging_obj.post_call_success_hook(
data=data, user_api_key_dict=user_api_key_dict, response=response
diff --git a/tests/proxy_e2e_azure_batches_tests/test_proxy_e2e_azure_batches.py b/tests/proxy_e2e_azure_batches_tests/test_proxy_e2e_azure_batches.py
index 3a6ed5244c1..29d40738413 100644
--- a/tests/proxy_e2e_azure_batches_tests/test_proxy_e2e_azure_batches.py
+++ b/tests/proxy_e2e_azure_batches_tests/test_proxy_e2e_azure_batches.py
@@ -205,7 +205,7 @@ class TestManagedFilesAPI(ManagedFilesBase, UserKeyTestMixin):
return metadata
- def _delete_file(self, file_id, label, max_retries=9, retry_delay=20):
+ def _delete_file(self, file_id, label, max_retries=6, retry_delay=5):
print(f"\nDeleting {label}: {self.shorten_id(file_id)}")
for attempt in range(max_retries):
try:
@@ -235,7 +235,7 @@ class TestManagedFilesAPI(ManagedFilesBase, UserKeyTestMixin):
# Tests
# ------------------------------------------------------------------
- @pytest.mark.flaky(reruns=5)
+ @pytest.mark.flaky(reruns=2)
@pytest.mark.parametrize(
"model_name",
get_batch_model_names(),