Skip to content

Build AI methods with your coding agent, then run them anywhere: as an MCP for chatbots, as a webapp for people, or via API for your software.

feature/Manifold-out-of-pipelex · L-261004-d4e065 (#1342)

Louis Choquel63a32719a577
diff --git a/.test_durations b/.test_durations
index c3ff2834c..34bc130ba 100644
--- a/.test_durations
+++ b/.test_durations
@@ -3865,13 +3865,9 @@
"tests/unit/pipelex/cogt/img_gen/test_img_gen_worker_config_faults.py::TestImgGenWorkerConfigFaults::test_unusable_model_spec_is_a_configuration_fault[huggingface-None-does not have rules configured]": 0.0032,
"tests/unit/pipelex/cogt/img_gen/test_img_gen_worker_config_faults.py::TestImgGenWorkerConfigFaults::test_unusable_model_spec_is_a_configuration_fault[huggingface-rules12-unknown prompt taxonomy 'weird']": 0.0033,
"tests/unit/pipelex/cogt/img_gen/test_img_gen_worker_config_faults.py::TestImgGenWorkerConfigFaults::test_unusable_model_spec_is_a_configuration_fault[huggingface-rules6-must include a 'model_choice' entry]": 0.0028,
- "tests/unit/pipelex/cogt/img_gen/test_img_gen_worker_config_faults.py::TestImgGenWorkerConfigFaults::test_unusable_model_spec_is_a_configuration_fault[manifold-None-does not have rules configured]": 0.0027,
- "tests/unit/pipelex/cogt/img_gen/test_img_gen_worker_config_faults.py::TestImgGenWorkerConfigFaults::test_unusable_model_spec_is_a_configuration_fault[manifold-rules8-unknown aspect_ratio taxonomy 'gemini_9_turbo']": 0.002,
"tests/unit/pipelex/cogt/img_gen/test_img_gen_worker_config_faults.py::TestImgGenWorkerConfigFaults::test_unusable_model_spec_is_a_configuration_fault[openai-None-does not have rules configured]": 0.0676,
"tests/unit/pipelex/cogt/img_gen/test_img_gen_worker_config_faults.py::TestImgGenWorkerConfigFaults::test_unusable_model_spec_is_a_configuration_fault[openai-rules10-unknown prompt taxonomy 'weird']": 0.0039,
"tests/unit/pipelex/cogt/img_gen/test_img_gen_worker_config_faults.py::TestImgGenWorkerConfigFaults::test_unusable_model_spec_is_a_configuration_fault[openai-rules7-unknown aspect_ratio taxonomy 'gemini_9_turbo']": 0.0035,
- "tests/unit/pipelex/cogt/img_gen/test_img_gen_worker_config_faults.py::TestImgGenWorkerConfigFaults::test_unusable_model_spec_is_a_configuration_fault[pipelex_hosted-None-does not have rules configured]": 0.088,
- "tests/unit/pipelex/cogt/img_gen/test_img_gen_worker_config_faults.py::TestImgGenWorkerConfigFaults::test_unusable_model_spec_is_a_configuration_fault[pipelex_hosted-rules8-unknown aspect_ratio taxonomy 'gemini_9_turbo']": 0.0059,
"tests/unit/pipelex/cogt/img_gen/test_img_gen_worker_factory.py::TestImgGenWorkerFactory::test_azure_rest_builds_worker_without_registry": 0.0031,
"tests/unit/pipelex/cogt/img_gen/test_img_gen_worker_factory.py::TestImgGenWorkerFactory::test_cached_sdk_instance_skips_client_factory": 0.0038,
"tests/unit/pipelex/cogt/img_gen/test_img_gen_worker_factory.py::TestImgGenWorkerFactory::test_fal_builds_async_client_with_api_key": 0.0022,
@@ -3882,10 +3878,8 @@
"tests/unit/pipelex/cogt/img_gen/test_img_gen_worker_factory.py::TestImgGenWorkerFactory::test_missing_dependency_raises[huggingface_img_gen]": 0.0025,
"tests/unit/pipelex/cogt/img_gen/test_img_gen_worker_factory.py::TestImgGenWorkerFactory::test_routing_builds_expected_worker[blackboxai_img_gen]": 0.0019,
"tests/unit/pipelex/cogt/img_gen/test_img_gen_worker_factory.py::TestImgGenWorkerFactory::test_routing_builds_expected_worker[google]": 0.0033,
- "tests/unit/pipelex/cogt/img_gen/test_img_gen_worker_factory.py::TestImgGenWorkerFactory::test_routing_builds_expected_worker[manifold_img_gen]": 0.0792,
"tests/unit/pipelex/cogt/img_gen/test_img_gen_worker_factory.py::TestImgGenWorkerFactory::test_routing_builds_expected_worker[openai_img_gen]": 0.0027,
"tests/unit/pipelex/cogt/img_gen/test_img_gen_worker_factory.py::TestImgGenWorkerFactory::test_routing_builds_expected_worker[openrouter_img_gen]": 0.0022,
- "tests/unit/pipelex/cogt/img_gen/test_img_gen_worker_factory.py::TestImgGenWorkerFactory::test_routing_builds_expected_worker[pipelex_hosted_img_gen]": 0.0828,
"tests/unit/pipelex/cogt/img_gen/test_img_gen_worker_factory.py::TestImgGenWorkerFactory::test_unknown_sdk_raises_backend_not_found": 0.1559,
"tests/unit/pipelex/cogt/img_gen/test_img_gen_worker_input_images_guard.py::TestImgGenWorkerInputImagesGuard::test_gen_image_list_rejects_before_provider_call": 0.1431,
"tests/unit/pipelex/cogt/img_gen/test_img_gen_worker_input_images_guard.py::TestImgGenWorkerInputImagesGuard::test_gen_image_rejects_before_provider_call": 0.0793,
@@ -3954,7 +3948,7 @@
"tests/unit/pipelex/cogt/inference/test_model_not_allowed.py::TestTheCodeIsRecognized::test_any_other_code_is_not_a_model_not_allowed_refusal[invalid_request_error]": 0.0002,
"tests/unit/pipelex/cogt/inference/test_model_not_allowed.py::TestTheCodeIsRecognized::test_any_other_code_is_not_a_model_not_allowed_refusal[model_not_allowed]": 0.0003,
"tests/unit/pipelex/cogt/inference/test_model_not_allowed.py::TestTheCodeIsRecognized::test_any_other_code_is_not_a_model_not_allowed_refusal[model_not_found]": 0.0005,
- "tests/unit/pipelex/cogt/inference/test_model_not_allowed.py::TestTheCodeIsRecognized::test_any_other_code_is_not_a_model_not_allowed_refusal[pig-01]": 0.0003,
+ "tests/unit/pipelex/cogt/inference/test_model_not_allowed.py::TestTheCodeIsRecognized::test_any_other_code_is_not_a_model_not_allowed_refusal[rate_limit_exceeded]": 0.0003,
"tests/unit/pipelex/cogt/inference/test_model_not_allowed.py::TestTheCodeIsRecognized::test_the_code_is_read_whichever_provider_reported_it[anthropic]": 0.0006,
"tests/unit/pipelex/cogt/inference/test_model_not_allowed.py::TestTheCodeIsRecognized::test_the_code_is_read_whichever_provider_reported_it[azure]": 0.0003,
"tests/unit/pipelex/cogt/inference/test_model_not_allowed.py::TestTheCodeIsRecognized::test_the_code_is_read_whichever_provider_reported_it[bedrock]": 0.0004,
@@ -3970,7 +3964,6 @@
"tests/unit/pipelex/cogt/inference/test_model_not_allowed.py::TestTheCodeIsRecognized::test_the_code_is_read_whichever_provider_reported_it[typesafe]": 0.0002,
"tests/unit/pipelex/cogt/inference/test_model_not_allowed.py::TestTheCodeIsRecognized::test_the_code_is_recognized": 0.0665,
"tests/unit/pipelex/cogt/inference/test_model_not_allowed.py::TestTheCodeSurvivesEveryExtractHop::test_the_refusal_through_every_hop[anthropic-driver]": 0.0051,
- "tests/unit/pipelex/cogt/inference/test_model_not_allowed.py::TestTheCodeSurvivesEveryExtractHop::test_the_refusal_through_every_hop[native-routes-httpx]": 0.0005,
"tests/unit/pipelex/cogt/inference/test_model_not_allowed.py::TestTheCodeSurvivesEveryExtractHop::test_the_refusal_through_every_hop[openai-substrate]": 0.0129,
"tests/unit/pipelex/cogt/inference/test_model_not_allowed.py::TestTheCodeSurvivesEveryExtractHop::test_the_refusal_through_every_hop[portkey-substrate]": 0.0075,
"tests/unit/pipelex/cogt/inference/test_model_not_allowed.py::TestWhatItAnswersOverHTTP::test_it_answers_500_as_an_unrecognized_412_does": 0.0004,
@@ -8231,7 +8224,7 @@
"tests/unit/pipelex/migration/test_migration_run.py::TestTheSchemaVersionFloor::test_a_file_declaring_exactly_the_floor_is_migrated": 0.005,
"tests/unit/pipelex/migration/test_migration_run.py::TestTheSchemaVersionFloor::test_a_file_declaring_nothing_is_migrated": 0.0056,
"tests/unit/pipelex/migration/test_migration_run.py::TestTheWalkIsNotRecursive::test_a_directory_no_surface_owns_is_never_entered": 0.0024,
- "tests/unit/pipelex/migration/test_migration_run.py::TestTheWalkIsNotRecursive::test_the_real_manifold_backend_file_is_claimed_by_its_own_directorys_surface": 0.066,
+ "tests/unit/pipelex/migration/test_migration_run.py::TestTheWalkIsNotRecursive::test_a_legacy_gateway_backend_file_is_claimed_by_its_own_directorys_surface": 0.066,
"tests/unit/pipelex/migration/test_migration_run.py::TestTheWalkIsNotRecursive::test_the_same_file_name_at_the_top_level_is_claimed_by_the_main_configuration": 0.0022,
"tests/unit/pipelex/migration/test_migration_run.py::TestWhichDirectoriesAreWalked::test_a_global_directory_that_does_not_exist_is_skipped": 0.0027,
"tests/unit/pipelex/migration/test_migration_run.py::TestWhichDirectoriesAreWalked::test_a_machine_with_no_project_directory_is_an_ordinary_machine": 0.0028,
@@ -9752,21 +9745,15 @@
"tests/unit/pipelex/plugins/test_import_light_boot.py::TestImportLightBoot::test_building_registrar_imports_no_backend_sdk": 1.758,
"tests/unit/pipelex/plugins/test_inference_backend_coverage.py::TestInferenceBackendCoverage::test_backend_is_registered[extract:docling_sdk]": 0.0006,
"tests/unit/pipelex/plugins/test_inference_backend_coverage.py::TestInferenceBackendCoverage::test_backend_is_registered[extract:linkup_fetch]": 0.0004,
- "tests/unit/pipelex/plugins/test_inference_backend_coverage.py::TestInferenceBackendCoverage::test_backend_is_registered[extract:manifold_extract]": 0.0004,
"tests/unit/pipelex/plugins/test_inference_backend_coverage.py::TestInferenceBackendCoverage::test_backend_is_registered[extract:mistral]": 0.001,
- "tests/unit/pipelex/plugins/test_inference_backend_coverage.py::TestInferenceBackendCoverage::test_backend_is_registered[extract:pipelex_hosted_extract]": 0.0005,
"tests/unit/pipelex/plugins/test_inference_backend_coverage.py::TestInferenceBackendCoverage::test_backend_is_registered[extract:pypdfium2]": 0.001,
"tests/unit/pipelex/plugins/test_inference_backend_coverage.py::TestInferenceBackendCoverage::test_backend_is_registered[img_gen:azure_rest_img_gen]": 0.0008,
"tests/unit/pipelex/plugins/test_inference_backend_coverage.py::TestInferenceBackendCoverage::test_backend_is_registered[img_gen:blackboxai_img_gen]": 0.0009,
"tests/unit/pipelex/plugins/test_inference_backend_coverage.py::TestInferenceBackendCoverage::test_backend_is_registered[img_gen:fal]": 0.0008,
"tests/unit/pipelex/plugins/test_inference_backend_coverage.py::TestInferenceBackendCoverage::test_backend_is_registered[img_gen:google]": 0.0009,
"tests/unit/pipelex/plugins/test_inference_backend_coverage.py::TestInferenceBackendCoverage::test_backend_is_registered[img_gen:huggingface_img_gen]": 0.0004,
- "tests/unit/pipelex/plugins/test_inference_backend_coverage.py::TestInferenceBackendCoverage::test_backend_is_registered[img_gen:manifold_completions]": 0.0004,
- "tests/unit/pipelex/plugins/test_inference_backend_coverage.py::TestInferenceBackendCoverage::test_backend_is_registered[img_gen:manifold_img_gen]": 0.0004,
"tests/unit/pipelex/plugins/test_inference_backend_coverage.py::TestInferenceBackendCoverage::test_backend_is_registered[img_gen:openai_img_gen]": 0.0009,
"tests/unit/pipelex/plugins/test_inference_backend_coverage.py::TestInferenceBackendCoverage::test_backend_is_registered[img_gen:openrouter_img_gen]": 0.0004,
- "tests/unit/pipelex/plugins/test_inference_backend_coverage.py::TestInferenceBackendCoverage::test_backend_is_registered[img_gen:pipelex_hosted_completions]": 0.0005,
- "tests/unit/pipelex/plugins/test_inference_backend_coverage.py::TestInferenceBackendCoverage::test_backend_is_registered[img_gen:pipelex_hosted_img_gen]": 0.19,
"tests/unit/pipelex/plugins/test_inference_backend_coverage.py::TestInferenceBackendCoverage::test_backend_is_registered[judgment:typesafe]": 0.0004,
"tests/unit/pipelex/plugins/test_inference_backend_coverage.py::TestInferenceBackendCoverage::test_backend_is_registered[llm:anthropic]": 0.0005,
"tests/unit/pipelex/plugins/test_inference_backend_coverage.py::TestInferenceBackendCoverage::test_backend_is_registered[llm:azure_openai]": 0.0012,
@@ -9775,24 +9762,16 @@
"tests/unit/pipelex/plugins/test_inference_backend_coverage.py::TestInferenceBackendCoverage::test_backend_is_registered[llm:bedrock_anthropic]": 0.0005,
"tests/unit/pipelex/plugins/test_inference_backend_coverage.py::TestInferenceBackendCoverage::test_backend_is_registered[llm:bedrock_boto3]": 0.0018,
"tests/unit/pipelex/plugins/test_inference_backend_coverage.py::TestInferenceBackendCoverage::test_backend_is_registered[llm:google]": 0.0009,
- "tests/unit/pipelex/plugins/test_inference_backend_coverage.py::TestInferenceBackendCoverage::test_backend_is_registered[llm:manifold_completions]": 0.0532,
- "tests/unit/pipelex/plugins/test_inference_backend_coverage.py::TestInferenceBackendCoverage::test_backend_is_registered[llm:manifold_responses]": 0.0004,
"tests/unit/pipelex/plugins/test_inference_backend_coverage.py::TestInferenceBackendCoverage::test_backend_is_registered[llm:mistral]": 0.0009,
"tests/unit/pipelex/plugins/test_inference_backend_coverage.py::TestInferenceBackendCoverage::test_backend_is_registered[llm:openai]": 0.8573,
"tests/unit/pipelex/plugins/test_inference_backend_coverage.py::TestInferenceBackendCoverage::test_backend_is_registered[llm:openai_responses]": 0.0009,
- "tests/unit/pipelex/plugins/test_inference_backend_coverage.py::TestInferenceBackendCoverage::test_backend_is_registered[llm:pipelex_hosted_completions]": 0.1002,
- "tests/unit/pipelex/plugins/test_inference_backend_coverage.py::TestInferenceBackendCoverage::test_backend_is_registered[llm:pipelex_hosted_responses]": 0.0008,
"tests/unit/pipelex/plugins/test_inference_backend_coverage.py::TestInferenceBackendCoverage::test_backend_is_registered[llm:portkey_completions]": 0.0005,
"tests/unit/pipelex/plugins/test_inference_backend_coverage.py::TestInferenceBackendCoverage::test_backend_is_registered[llm:portkey_responses]": 0.0011,
"tests/unit/pipelex/plugins/test_inference_backend_coverage.py::TestInferenceBackendCoverage::test_backend_is_registered[search:linkup]": 0.0008,
- "tests/unit/pipelex/plugins/test_inference_backend_coverage.py::TestInferenceBackendCoverage::test_backend_is_registered[search:manifold_search]": 0.0004,
- "tests/unit/pipelex/plugins/test_inference_backend_coverage.py::TestInferenceBackendCoverage::test_backend_is_registered[search:pipelex_hosted_search]": 0.0013,
"tests/unit/pipelex/plugins/test_inference_backend_coverage.py::TestInferenceBackendCoverage::test_cross_family_vendor_registers_into_all_its_families[google]": 0.0009,
"tests/unit/pipelex/plugins/test_inference_backend_coverage.py::TestInferenceBackendCoverage::test_cross_family_vendor_registers_into_all_its_families[linkup]": 0.0009,
- "tests/unit/pipelex/plugins/test_inference_backend_coverage.py::TestInferenceBackendCoverage::test_cross_family_vendor_registers_into_all_its_families[manifold]": 0.0005,
"tests/unit/pipelex/plugins/test_inference_backend_coverage.py::TestInferenceBackendCoverage::test_cross_family_vendor_registers_into_all_its_families[mistral]": 0.0008,
"tests/unit/pipelex/plugins/test_inference_backend_coverage.py::TestInferenceBackendCoverage::test_cross_family_vendor_registers_into_all_its_families[openai]": 0.0009,
- "tests/unit/pipelex/plugins/test_inference_backend_coverage.py::TestInferenceBackendCoverage::test_cross_family_vendor_registers_into_all_its_families[pipelex_hosted]": 0.0006,
"tests/unit/pipelex/plugins/test_installed_plugin_group_isolation.py::TestInstalledPluginGroupIsolation::test_a_kernel_only_boot_never_imports_an_installed_interpreter_group_plugin": 2.0545,
"tests/unit/pipelex/plugins/test_log_sink_registry.py::TestLogSinkRegistry::test_contribution_recorded_on_the_active_plugin": 0.001,
"tests/unit/pipelex/plugins/test_log_sink_registry.py::TestLogSinkRegistry::test_duplicate_method_fails_loud_naming_both_plugins": 0.0011,
@@ -10428,9 +10407,7 @@
"tests/unit/pipelex/providers/openai/test_openai_completions_img_gen_worker_error_handling.py::TestOpenAICompletionsImgGenWorkerErrorHandling::test_server_error_is_transient": 0.0737,
"tests/unit/pipelex/providers/openai/test_openai_completions_img_gen_worker_error_handling.py::TestOpenAICompletionsImgGenWorkerErrorHandling::test_timeout_is_transient": 0.0631,
"tests/unit/pipelex/providers/openai/test_openai_completions_img_gen_worker_output_format.py::TestEachRegistrationPassesItsFormat::test_the_registration_builds_the_worker_with_its_format[blackboxai]": 0.0017,
- "tests/unit/pipelex/providers/openai/test_openai_completions_img_gen_worker_output_format.py::TestEachRegistrationPassesItsFormat::test_the_registration_builds_the_worker_with_its_format[manifold]": 0.0018,
"tests/unit/pipelex/providers/openai/test_openai_completions_img_gen_worker_output_format.py::TestEachRegistrationPassesItsFormat::test_the_registration_builds_the_worker_with_its_format[openrouter]": 0.0013,
- "tests/unit/pipelex/providers/openai/test_openai_completions_img_gen_worker_output_format.py::TestEachRegistrationPassesItsFormat::test_the_registration_builds_the_worker_with_its_format[pipelex_hosted]": 0.092,
"tests/unit/pipelex/providers/openai/test_openai_completions_img_gen_worker_output_format.py::TestFixedOutputFormat::test_a_request_for_the_fixed_format_is_served": 0.1264,
"tests/unit/pipelex/providers/openai/test_openai_completions_img_gen_worker_output_format.py::TestFixedOutputFormat::test_a_url_answer_is_read_as_the_fixed_format[jpeg]": 0.0074,
"tests/unit/pipelex/providers/openai/test_openai_completions_img_gen_worker_output_format.py::TestFixedOutputFormat::test_a_url_answer_is_read_as_the_fixed_format[png]": 0.0687,
@@ -10530,424 +10507,6 @@
"tests/unit/pipelex/providers/openai/test_openai_worker_error_handling.py::TestOpenAIWorkerErrorHandling::test_responses_llm_rate_limit_quota": 0.0022,
"tests/unit/pipelex/providers/openai/test_openai_worker_error_handling.py::TestOpenAIWorkerErrorHandling::test_responses_llm_rate_limit_transient": 0.0036,
"tests/unit/pipelex/providers/openai/test_openai_worker_error_handling.py::TestOpenAIWorkerErrorHandling::test_responses_llm_unhandled_4xx_is_configuration": 0.0029,
- "tests/unit/pipelex/providers/pipelex_hosted/test_extract_pipelex_hosted_metadata.py::TestTheRequestIdThePipelexHostedPathReports::test_prefers_the_pipelex_spelling_over_the_vendor_one": 1.7865,
- "tests/unit/pipelex/providers/pipelex_hosted/test_extract_pipelex_hosted_metadata.py::TestTheRequestIdThePipelexHostedPathReports::test_prefers_the_providers_own_request_id_over_any_trace_id": 1.8161,
- "tests/unit/pipelex/providers/pipelex_hosted/test_extract_pipelex_hosted_metadata.py::TestTheRequestIdThePipelexHostedPathReports::test_reads_the_pipelex_spelled_trace_id": 1.7887,
- "tests/unit/pipelex/providers/pipelex_hosted/test_extract_pipelex_hosted_metadata.py::TestTheRequestIdThePipelexHostedPathReports::test_reports_no_request_id_when_no_provider_was_reached": 1.7992,
- "tests/unit/pipelex/providers/pipelex_hosted/test_extract_pipelex_hosted_metadata.py::TestTheRequestIdThePipelexHostedPathReports::test_still_reads_the_vendor_spelling_while_the_gateway_emits_it": 0.101,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_clients.py::TestPipelexHostedCompletionsClient::test_a_handle_from_another_sdk_set_is_refused": 0.0016,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_clients.py::TestPipelexHostedCompletionsClient::test_the_client_gets_the_origin_plus_v1_and_the_token_in_the_service_header": 3.4526,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_clients.py::TestPipelexHostedImageClient::test_debug_is_read_from_the_backend_and_from_nothing_else": 0.049,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_clients.py::TestPipelexHostedImageClient::test_the_vendor_client_is_built_under_the_same_endpoint_rule": 0.0006,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_clients.py::TestPipelexHostedResponsesClient::test_a_handle_from_another_sdk_set_is_refused": 0.0007,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_clients.py::TestPipelexHostedResponsesClient::test_the_client_gets_the_origin_plus_v1_and_the_token_in_the_service_header": 0.0017,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_completions_messages.py::TestPipelexHostedCompletionsMessages::test_a_document_that_is_not_bytes_is_refused[http-url-document]": 0.0012,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_completions_messages.py::TestPipelexHostedCompletionsMessages::test_a_document_that_is_not_bytes_is_refused[local-path-document]": 0.0097,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_completions_messages.py::TestPipelexHostedCompletionsMessages::test_a_document_travels_as_an_image_url_data_url": 0.006,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_completions_messages.py::TestPipelexHostedCompletionsMessages::test_images_become_image_url_parts_at_the_requested_detail[None-auto]": 0.0012,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_completions_messages.py::TestPipelexHostedCompletionsMessages::test_images_become_image_url_parts_at_the_requested_detail[high-high]": 0.0021,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_completions_messages.py::TestPipelexHostedCompletionsMessages::test_images_become_image_url_parts_at_the_requested_detail[low-low]": 0.0011,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_completions_messages.py::TestPipelexHostedCompletionsMessages::test_system_and_user_text": 0.4923,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_endpoint_rule.py::TestPipelexHostedEndpointRule::test_a_trailing_slash_or_surrounding_space_is_forgiven[ https://pipelex_hosted.example.com ]": 0.0003,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_endpoint_rule.py::TestPipelexHostedEndpointRule::test_a_trailing_slash_or_surrounding_space_is_forgiven[https://pipelex_hosted.example.com///]": 0.0015,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_endpoint_rule.py::TestPipelexHostedEndpointRule::test_a_trailing_slash_or_surrounding_space_is_forgiven[https://pipelex_hosted.example.com/]": 0.0034,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_endpoint_rule.py::TestPipelexHostedEndpointRule::test_an_absent_api_key_is_refused_by_name": 0.0003,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_endpoint_rule.py::TestPipelexHostedEndpointRule::test_an_absent_endpoint_is_refused_and_never_defaulted[blank]": 0.0004,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_endpoint_rule.py::TestPipelexHostedEndpointRule::test_an_absent_endpoint_is_refused_and_never_defaulted[empty]": 0.0004,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_endpoint_rule.py::TestPipelexHostedEndpointRule::test_an_absent_endpoint_is_refused_and_never_defaulted[slash-only]": 0.0003,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_endpoint_rule.py::TestPipelexHostedEndpointRule::test_an_absent_endpoint_is_refused_and_never_defaulted[unset]": 0.0004,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_endpoint_rule.py::TestPipelexHostedEndpointRule::test_origin_is_returned_as_declared": 0.55,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_endpoint_rule.py::TestPipelexHostedEndpointRule::test_the_only_header_about_us_is_the_service_token": 0.0871,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_endpoint_rule.py::TestPipelexHostedEndpointRule::test_the_version_segment_is_appended_by_the_factory_not_the_operator": 0.0002,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_error_message.py::TestTheMessageThePipelexHostedPathReports::test_a_request_error_keeps_its_own_text": 0.0026,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_error_message.py::TestTheMessageThePipelexHostedPathReports::test_falls_back_to_the_exception_text_when_the_body_explains_nothing[a blank nested message and no top-level one-json_body1]": 0.0025,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_error_message.py::TestTheMessageThePipelexHostedPathReports::test_falls_back_to_the_exception_text_when_the_body_explains_nothing[a body that is not an object-json_body4]": 0.0012,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_error_message.py::TestTheMessageThePipelexHostedPathReports::test_falls_back_to_the_exception_text_when_the_body_explains_nothing[a message that is not a string-json_body3]": 0.0999,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_error_message.py::TestTheMessageThePipelexHostedPathReports::test_falls_back_to_the_exception_text_when_the_body_explains_nothing[a null message-json_body2]": 0.1395,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_error_message.py::TestTheMessageThePipelexHostedPathReports::test_falls_back_to_the_exception_text_when_the_body_explains_nothing[no message anywhere-json_body0]": 0.0845,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_error_message.py::TestTheMessageThePipelexHostedPathReports::test_falls_back_to_the_exception_text_when_the_body_is_not_json": 0.0008,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_error_message.py::TestTheMessageThePipelexHostedPathReports::test_prefers_the_nested_error_message_over_the_top_level_one": 0.1121,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_error_message.py::TestTheMessageThePipelexHostedPathReports::test_reads_the_top_level_message_when_the_error_object_has_none": 0.1454,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_error_message.py::TestTheMessageThePipelexHostedPathReports::test_reports_the_gateways_own_message": 0.1023,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_error_message.py::TestTheQuotaReadingOfANativeRoute429::test_a_429_whose_body_names_a_quota_is_quota_exhaustion": 0.0023,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_error_message.py::TestTheQuotaReadingOfANativeRoute429::test_a_429_whose_body_names_no_quota_stays_a_rate_limit": 0.0011,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_extract_worker.py::TestPipelexHostedExtractRequestBody::test_a_non_web_page_model_is_handed_the_bytes_inline": 0.5713,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_extract_worker.py::TestPipelexHostedExtractRequestBody::test_a_web_page_model_is_handed_the_url_itself": 0.0687,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_extract_worker.py::TestPipelexHostedExtractRequestBody::test_a_web_page_model_with_no_document_uri_is_refused_by_name": 0.0059,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_extract_worker.py::TestPipelexHostedExtractRequestBody::test_an_unset_optional_parameter_is_omitted_rather_than_sent_as_null": 0.0053,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_extract_worker.py::TestPipelexHostedExtractRequestBody::test_no_input_at_all_is_refused": 0.0087,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_extract_worker.py::TestPipelexHostedExtractRequestBody::test_the_withdrawn_parameters_are_absent_rather_than_sent_at_their_defaults": 0.5887,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_extract_worker.py::TestPipelexHostedExtractUsageTranslation::test_a_usage_block_the_route_did_not_send_leaves_the_abstract_fallback_in_charge[empty-usage]": 0.0064,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_extract_worker.py::TestPipelexHostedExtractUsageTranslation::test_a_usage_block_the_route_did_not_send_leaves_the_abstract_fallback_in_charge[no-usage]": 0.0029,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_extract_worker.py::TestPipelexHostedExtractUsageTranslation::test_a_usage_block_the_route_did_not_send_leaves_the_abstract_fallback_in_charge[non-numeric-pages]": 0.1053,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_extract_worker.py::TestPipelexHostedExtractUsageTranslation::test_a_usage_block_the_route_did_not_send_leaves_the_abstract_fallback_in_charge[null-usage]": 0.003,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_extract_worker.py::TestPipelexHostedExtractUsageTranslation::test_pages_become_megatokens_in_both_categories": 0.0136,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_extras_by_spec.py::TestPipelexHostedExtrasBySpec::test_gemini_image_spec_gets_image_config[nano-banana-2-entry2-landscape_4_1-4k-expected_image_config2]": 0.1701,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_extras_by_spec.py::TestPipelexHostedExtrasBySpec::test_gemini_image_spec_gets_image_config[nano-banana-2-lite-entry3-square-1k-expected_image_config3]": 0.001,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_extras_by_spec.py::TestPipelexHostedExtrasBySpec::test_gemini_image_spec_gets_image_config[nano-banana-entry0-landscape_16_9-None-expected_image_config0]": 0.1076,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_extras_by_spec.py::TestPipelexHostedExtrasBySpec::test_gemini_image_spec_gets_image_config[nano-banana-entry4-portrait_3_4-None-expected_image_config4]": 0.0007,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_extras_by_spec.py::TestPipelexHostedExtrasBySpec::test_gemini_image_spec_gets_image_config[nano-banana-pro-entry1-portrait_9_16-2k-expected_image_config1]": 0.0024,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_extras_by_spec.py::TestPipelexHostedExtrasBySpec::test_mistral_seed_follows_the_model_id_prefix[mistral_handle_only-mistral-large-entry0-True]": 0.0016,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_extras_by_spec.py::TestPipelexHostedExtrasBySpec::test_mistral_seed_follows_the_model_id_prefix[mistral_provider_id-mistral-large-entry1-True]": 0.0013,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_extras_by_spec.py::TestPipelexHostedExtrasBySpec::test_mistral_seed_follows_the_model_id_prefix[not_mistral-gpt-4o-entry2-False]": 0.0009,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_extras_by_spec.py::TestPipelexHostedExtrasBySpec::test_non_gemini_image_spec_gets_no_image_config[gpt_image_2-gpt-image-2-entry1]": 0.001,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_extras_by_spec.py::TestPipelexHostedExtrasBySpec::test_non_gemini_image_spec_gets_no_image_config[gpt_image_legacy-gpt-image-1-entry0]": 0.0017,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_extras_by_spec.py::TestPipelexHostedExtrasBySpec::test_size_beyond_the_gemini_taxonomy_is_refused": 0.0006,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_extras_by_spec.py::TestPipelexHostedExtrasBySpec::test_undecidable_image_spec_is_refused_as_a_configuration_fault[gemini_id_without_rules-gemini-lookalike-entry1-declares no aspect_ratio rule-1k]": 0.001,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_extras_by_spec.py::TestPipelexHostedExtrasBySpec::test_undecidable_image_spec_is_refused_as_a_configuration_fault[gemini_id_without_rules-gemini-lookalike-entry1-declares no aspect_ratio rule-None]": 0.001,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_extras_by_spec.py::TestPipelexHostedExtrasBySpec::test_undecidable_image_spec_is_refused_as_a_configuration_fault[rules_without_aspect_ratio-nano-banana-bare-entry2-declares no aspect_ratio rule-1k]": 0.0007,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_extras_by_spec.py::TestPipelexHostedExtrasBySpec::test_undecidable_image_spec_is_refused_as_a_configuration_fault[rules_without_aspect_ratio-nano-banana-bare-entry2-declares no aspect_ratio rule-None]": 0.0012,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_extras_by_spec.py::TestPipelexHostedExtrasBySpec::test_undecidable_image_spec_is_refused_as_a_configuration_fault[unknown_taxonomy-nano-banana-next-entry0-unknown aspect_ratio taxonomy 'gemini_from_the_future'-1k]": 0.0028,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_extras_by_spec.py::TestPipelexHostedExtrasBySpec::test_undecidable_image_spec_is_refused_as_a_configuration_fault[unknown_taxonomy-nano-banana-next-entry0-unknown aspect_ratio taxonomy 'gemini_from_the_future'-None]": 0.0017,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_img_gen_worker.py::TestPipelexHostedImgGenWorkerFailures::test_a_malformed_success_body_is_wrapped_rather_than_escaping[image-without-data]": 0.0057,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_img_gen_worker.py::TestPipelexHostedImgGenWorkerFailures::test_a_malformed_success_body_is_wrapped_rather_than_escaping[no-images]": 3.4369,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_img_gen_worker.py::TestPipelexHostedImgGenWorkerFailures::test_a_malformed_success_body_is_wrapped_rather_than_escaping[no-size-at-all]": 0.0394,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_img_gen_worker.py::TestPipelexHostedImgGenWorkerFailures::test_a_malformed_success_body_is_wrapped_rather_than_escaping[non-numeric-size]": 0.0033,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_img_gen_worker.py::TestPipelexHostedImgGenWorkerFailures::test_a_non_json_2xx_becomes_a_categorized_error": 0.0041,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_img_gen_worker.py::TestPipelexHostedImgGenWorkerFailures::test_a_provider_status_error_is_classified_rather_than_raised_raw": 0.0886,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_img_gen_worker.py::TestPipelexHostedImgGenWorkerSuccess::test_an_azure_gpt_image_body_becomes_generated_images": 0.5982,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_img_gen_worker.py::TestPipelexHostedImgGenWorkerSuccess::test_input_images_route_to_the_edits_endpoint": 0.0061,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_img_gen_worker.py::TestPipelexHostedImgGenWorkerSuccess::test_several_input_images_travel_as_a_list_not_as_repeated_bare_parts": 0.0026,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_metadata.py::TestPipelexHostedMetadata::test_a_job_with_extras_yields_the_exact_wire_value": 0.0009,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_metadata.py::TestPipelexHostedMetadata::test_a_none_id_is_omitted_and_a_colliding_extras_key_does_not_stand_in_for_it": 0.0003,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_metadata.py::TestPipelexHostedMetadata::test_empty_extras_yield_the_runtime_ids_alone": 0.0006,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_metadata.py::TestPipelexHostedMetadata::test_every_runtime_key_is_a_legal_extras_key_so_a_collision_is_possible": 0.0003,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_metadata.py::TestPipelexHostedMetadata::test_the_encoding_is_compact_json": 0.001,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_metadata.py::TestPipelexHostedMetadata::test_the_header_is_named_by_the_dialect_and_never_by_the_vendor": 0.0725,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_metadata.py::TestPipelexHostedMetadata::test_the_runtime_ids_win_over_colliding_extras_keys": 0.0007,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_metadata.py::TestPipelexHostedMetadata::test_the_value_is_printable_ascii_whatever_went_in[crlf]": 0.0007,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_metadata.py::TestPipelexHostedMetadata::test_the_value_is_printable_ascii_whatever_went_in[del]": 0.0004,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_metadata.py::TestPipelexHostedMetadata::test_the_value_is_printable_ascii_whatever_went_in[lf]": 0.0005,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_metadata.py::TestPipelexHostedMetadata::test_the_value_is_printable_ascii_whatever_went_in[non-ascii]": 0.3701,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_metadata.py::TestPipelexHostedMetadata::test_the_value_is_printable_ascii_whatever_went_in[tab]": 0.0009,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_metadata_scope.py::TestPipelexHostedMetadataScope::test_a_plain_anthropic_worker_sends_no_headers_on_the_structured_call[anthropic]": 0.0602,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_metadata_scope.py::TestPipelexHostedMetadataScope::test_a_plain_anthropic_worker_sends_no_headers_on_the_structured_call[pipelex_hosted]": 0.1847,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_metadata_scope.py::TestPipelexHostedMetadataScope::test_a_plain_anthropic_worker_sends_no_headers_on_the_structured_call[pipelex_manifold]": 0.2176,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_metadata_scope.py::TestPipelexHostedMetadataScope::test_a_plain_anthropic_worker_sends_no_headers_on_the_text_call[anthropic]": 0.1798,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_metadata_scope.py::TestPipelexHostedMetadataScope::test_a_plain_anthropic_worker_sends_no_headers_on_the_text_call[bedrock]": 0.0069,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_metadata_scope.py::TestPipelexHostedMetadataScope::test_a_plain_anthropic_worker_sends_no_headers_on_the_text_call[pipelex_hosted]": 0.0079,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_metadata_scope.py::TestPipelexHostedMetadataScope::test_a_plain_anthropic_worker_sends_no_headers_on_the_text_call[pipelex_manifold]": 0.201,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_metadata_scope.py::TestPipelexHostedMetadataScope::test_direct_claude_sends_no_headers_on_the_structured_call": 0.0284,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_metadata_scope.py::TestPipelexHostedMetadataScope::test_direct_claude_sends_no_headers_on_the_text_call[anthropic]": 0.0171,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_metadata_scope.py::TestPipelexHostedMetadataScope::test_direct_claude_sends_no_headers_on_the_text_call[bedrock]": 0.0186,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_metadata_scope.py::TestPipelexHostedMetadataScope::test_direct_claude_sends_no_headers_on_the_text_call[pipelex_gateway]": 0.0137,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_metadata_scope.py::TestPipelexHostedMetadataScope::test_other_backends_extras_carry_no_metadata_header[gateway]": 0.0014,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_metadata_scope.py::TestPipelexHostedMetadataScope::test_other_backends_extras_carry_no_metadata_header[openai-completions]": 0.0757,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_metadata_scope.py::TestPipelexHostedMetadataScope::test_other_backends_extras_carry_no_metadata_header[openai-responses]": 0.0018,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_metadata_scope.py::TestPipelexHostedMetadataScope::test_other_backends_extras_carry_no_metadata_header[portkey]": 0.0024,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_metadata_sdk_paths.py::TestPipelexHostedMetadataSdkPaths::test_a_catalog_header_of_the_same_name_does_not_override_the_job": 0.0019,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_metadata_sdk_paths.py::TestPipelexHostedMetadataSdkPaths::test_claude_behind_pipelex_hosted_sends_the_header_on_the_structured_call": 0.0099,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_metadata_sdk_paths.py::TestPipelexHostedMetadataSdkPaths::test_claude_behind_pipelex_hosted_sends_the_header_on_the_text_call": 0.0067,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_metadata_sdk_paths.py::TestPipelexHostedMetadataSdkPaths::test_the_completions_worker_sends_the_header_on_the_sdk_call": 0.0019,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_metadata_sdk_paths.py::TestPipelexHostedMetadataSdkPaths::test_the_extract_route_sends_the_header_on_the_wire": 0.0096,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_metadata_sdk_paths.py::TestPipelexHostedMetadataSdkPaths::test_the_image_worker_sends_the_header_on_both_images_routes[edit]": 0.0017,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_metadata_sdk_paths.py::TestPipelexHostedMetadataSdkPaths::test_the_image_worker_sends_the_header_on_both_images_routes[generate]": 0.0037,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_metadata_sdk_paths.py::TestPipelexHostedMetadataSdkPaths::test_the_openai_substrate_extras_carry_the_header[completions]": 0.0774,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_metadata_sdk_paths.py::TestPipelexHostedMetadataSdkPaths::test_the_openai_substrate_extras_carry_the_header[responses]": 0.0014,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_metadata_sdk_paths.py::TestPipelexHostedMetadataSdkPaths::test_the_search_route_sends_the_header_on_the_wire": 0.0059,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_native_client.py::TestPipelexHostedNativeClientFailures::test_a_2xx_carrying_a_json_scalar_is_refused_with_what_it_was": 0.0057,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_native_client.py::TestPipelexHostedNativeClientFailures::test_a_non_json_2xx_becomes_a_pipelex_error_naming_the_model": 0.0068,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_native_client.py::TestPipelexHostedNativeClientFailures::test_a_status_error_is_classified_rather_than_raised_raw": 0.0951,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_native_client.py::TestPipelexHostedNativeClientRequest::test_a_json_object_body_comes_back_as_a_dict": 0.0069,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_native_client.py::TestPipelexHostedNativeClientRequest::test_the_wire_carries_one_token_header_and_a_body_with_no_routing": 0.428,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_plugin_registrations.py::TestPipelexHostedPluginRegistrations::test_claude_is_built_with_the_metadata_extras_factory": 0.2137,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_plugin_registrations.py::TestPipelexHostedPluginRegistrations::test_no_anthropic_sdk_is_claimed_under_a_pipelex_hosted_name": 0.0016,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_plugin_registrations.py::TestPipelexHostedPluginRegistrations::test_the_plain_anthropic_sdk_is_not_claimed": 0.1266,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_plugin_registrations.py::TestPipelexHostedPluginRegistrations::test_the_plugin_claims_exactly_the_pipelex_hosted_sdk_set": 0.5408,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_plugin_registrations.py::TestPipelexHostedPluginRegistrations::test_the_plugin_is_a_kernel_builtin": 0.0412,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_request_limits.py::TestClassification::test_a_413_without_the_code_is_left_to_the_status_ladder": 0.001,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_request_limits.py::TestClassification::test_each_limit_classifies_as_a_caller_error[pig-07-413-body_too_large-content-change_input]": 0.0007,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_request_limits.py::TestClassification::test_each_limit_classifies_as_a_caller_error[pig-08-411-body_length_required-configuration-contact_support]": 0.0007,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_request_limits.py::TestClassification::test_each_limit_classifies_as_a_caller_error[pig-10-413-object_too_large-content-change_input]": 0.0014,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_request_limits.py::TestClassification::test_each_limit_classifies_as_a_caller_error[pig-11-400-body_too_deep-content-change_input]": 0.0016,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_request_limits.py::TestClassification::test_the_411_would_otherwise_read_as_a_configuration_error_with_input_advice": 0.0012,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_request_limits.py::TestClassification::test_without_the_pipelex_hosted_vocabulary_the_code_is_left_to_the_status_ladder": 0.0016,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_request_limits.py::TestRenderedAdvice::test_the_detail_names_the_limit[pig-07-413-too large]": 0.0016,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_request_limits.py::TestRenderedAdvice::test_the_detail_names_the_limit[pig-08-411-Content-Length]": 0.0008,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_request_limits.py::TestRenderedAdvice::test_the_detail_names_the_limit[pig-10-413-per-file size limit]": 0.0008,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_request_limits.py::TestRenderedAdvice::test_the_detail_names_the_limit[pig-11-400-deeply]": 0.0009,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_request_limits.py::TestRenderedAdvice::test_the_two_size_limits_are_told_apart": 0.1751,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_request_limits.py::TestTheCodeIsRecognized::test_any_other_code_is_not_a_request_limit[None]": 0.0007,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_request_limits.py::TestTheCodeIsRecognized::test_any_other_code_is_not_a_request_limit[PIG-07]": 0.0006,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_request_limits.py::TestTheCodeIsRecognized::test_any_other_code_is_not_a_request_limit[]": 0.0013,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_request_limits.py::TestTheCodeIsRecognized::test_any_other_code_is_not_a_request_limit[invalid_request_error]": 0.0012,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_request_limits.py::TestTheCodeIsRecognized::test_any_other_code_is_not_a_request_limit[pig-01]": 0.0006,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_request_limits.py::TestTheCodeIsRecognized::test_any_other_code_is_not_a_request_limit[pig-09]": 0.0014,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_request_limits.py::TestTheCodeIsRecognized::test_each_limit_code_maps_to_its_kind[pig-07-body_too_large]": 0.0789,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_request_limits.py::TestTheCodeIsRecognized::test_each_limit_code_maps_to_its_kind[pig-08-body_length_required]": 0.0007,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_request_limits.py::TestTheCodeIsRecognized::test_each_limit_code_maps_to_its_kind[pig-10-object_too_large]": 0.0006,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_request_limits.py::TestTheCodeIsRecognized::test_each_limit_code_maps_to_its_kind[pig-11-body_too_deep]": 0.0006,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_request_limits.py::TestTheCodeIsRecognized::test_the_code_is_read_whichever_provider_reported_it[anthropic]": 0.0007,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_request_limits.py::TestTheCodeIsRecognized::test_the_code_is_read_whichever_provider_reported_it[azure]": 0.0008,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_request_limits.py::TestTheCodeIsRecognized::test_the_code_is_read_whichever_provider_reported_it[bedrock]": 0.0007,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_request_limits.py::TestTheCodeIsRecognized::test_the_code_is_read_whichever_provider_reported_it[docling]": 0.0015,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_request_limits.py::TestTheCodeIsRecognized::test_the_code_is_read_whichever_provider_reported_it[fal]": 0.0012,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_request_limits.py::TestTheCodeIsRecognized::test_the_code_is_read_whichever_provider_reported_it[gateway]": 0.0016,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_request_limits.py::TestTheCodeIsRecognized::test_the_code_is_read_whichever_provider_reported_it[google]": 0.0007,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_request_limits.py::TestTheCodeIsRecognized::test_the_code_is_read_whichever_provider_reported_it[huggingface]": 0.0029,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_request_limits.py::TestTheCodeIsRecognized::test_the_code_is_read_whichever_provider_reported_it[linkup]": 0.0012,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_request_limits.py::TestTheCodeIsRecognized::test_the_code_is_read_whichever_provider_reported_it[mistral]": 0.001,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_request_limits.py::TestTheCodeIsRecognized::test_the_code_is_read_whichever_provider_reported_it[openai]": 0.1171,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_request_limits.py::TestTheCodeIsRecognized::test_the_code_is_read_whichever_provider_reported_it[pypdfium2]": 0.0006,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_request_limits.py::TestTheCodeIsRecognized::test_the_code_is_read_whichever_provider_reported_it[typesafe]": 0.1728,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_request_limits.py::TestTheCodeSurvivesEveryExtractHop::test_the_length_rule_arrives_on_the_substrate_too": 0.0105,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_request_limits.py::TestTheCodeSurvivesEveryExtractHop::test_the_portkey_substrate_discards_the_payload_and_the_code_survives_anyway": 0.0106,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_request_limits.py::TestTheCodeSurvivesEveryExtractHop::test_through_plain_httpx_on_the_native_routes": 0.0007,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_request_limits.py::TestTheCodeSurvivesEveryExtractHop::test_through_the_openai_substrate_that_carries_every_chat_call[body0-body_too_large]": 0.0064,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_request_limits.py::TestTheCodeSurvivesEveryExtractHop::test_through_the_openai_substrate_that_carries_every_chat_call[body1-body_too_deep]": 0.005,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_request_limits.py::TestTheCodeSurvivesEveryExtractHop::test_through_the_portkey_substrate": 0.019,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_request_limits.py::TestTheCodeSurvivesEveryExtractHop::test_through_the_shared_anthropic_driver": 0.0007,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_request_limits.py::TestTheSameLimitOnTheNativeRoutes::test_a_file_over_its_cap_classifies_as_too_large[pipelex_document_too_large]": 0.0008,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_request_limits.py::TestTheSameLimitOnTheNativeRoutes::test_a_file_over_its_cap_classifies_as_too_large[pipelex_storage_object_too_large]": 0.0021,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_request_limits.py::TestTheSameLimitOnTheNativeRoutes::test_both_routes_give_the_caller_the_same_advice": 0.001,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_request_limits.py::TestTheSameLimitOnTheNativeRoutes::test_the_generic_type_does_not_shadow_the_contract_code": 0.0027,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_request_limits.py::TestTheSameLimitOnTheNativeRoutes::test_the_native_envelope_survives_the_portkey_substrate_too": 0.0276,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_routing_refusals.py::TestClassification::test_a_disabled_integration_is_an_operators_problem": 0.0005,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_routing_refusals.py::TestClassification::test_a_plain_400_without_a_recognized_code_still_takes_the_status_ladder": 0.0014,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_routing_refusals.py::TestClassification::test_a_refusal_the_caller_can_route_around_asks_them_to_change_the_model[pig-01]": 0.0006,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_routing_refusals.py::TestClassification::test_a_refusal_the_caller_can_route_around_asks_them_to_change_the_model[pig-05]": 0.0006,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_routing_refusals.py::TestClassification::test_a_refusal_the_caller_can_route_around_asks_them_to_change_the_model[pig-06]": 0.0009,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_routing_refusals.py::TestClassification::test_each_code_classifies_as_its_member_and_is_never_retried[pig-01-unknown_model]": 0.0005,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_routing_refusals.py::TestClassification::test_each_code_classifies_as_its_member_and_is_never_retried[pig-02-disabled_integration]": 0.0005,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_routing_refusals.py::TestClassification::test_each_code_classifies_as_its_member_and_is_never_retried[pig-05-wrong_protocol]": 0.0013,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_routing_refusals.py::TestClassification::test_each_code_classifies_as_its_member_and_is_never_retried[pig-06-unserved_capability]": 0.0007,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_routing_refusals.py::TestClassification::test_only_the_unknown_model_is_a_missing_model[pig-01]": 0.0009,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_routing_refusals.py::TestClassification::test_only_the_unknown_model_is_a_missing_model[pig-02]": 0.0012,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_routing_refusals.py::TestClassification::test_only_the_unknown_model_is_a_missing_model[pig-05]": 0.0011,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_routing_refusals.py::TestClassification::test_only_the_unknown_model_is_a_missing_model[pig-06]": 0.0012,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_routing_refusals.py::TestClassification::test_without_the_pipelex_hosted_vocabulary_an_unserved_model_is_a_plain_400": 0.0007,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_routing_refusals.py::TestEndToEnd::test_a_wrong_protocol_refusal_does_not_claim_the_model_was_not_found": 0.2237,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_routing_refusals.py::TestEndToEnd::test_an_unserved_model_reaches_the_caller_as_a_model_not_found_carrying_the_handle": 0.0246,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_routing_refusals.py::TestRenderedAdvice::test_an_unserved_capability_reaching_an_extract_reads_the_same": 0.0006,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_routing_refusals.py::TestRenderedAdvice::test_every_member_leaves_the_handle_to_the_message[pig-01]": 0.0008,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_routing_refusals.py::TestRenderedAdvice::test_every_member_leaves_the_handle_to_the_message[pig-02]": 0.0006,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_routing_refusals.py::TestRenderedAdvice::test_every_member_leaves_the_handle_to_the_message[pig-05]": 0.0006,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_routing_refusals.py::TestRenderedAdvice::test_every_member_leaves_the_handle_to_the_message[pig-06]": 0.0006,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_routing_refusals.py::TestRenderedAdvice::test_no_member_renders_the_generic_action_kind_advice_either[pig-01]": 0.0019,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_routing_refusals.py::TestRenderedAdvice::test_no_member_renders_the_generic_action_kind_advice_either[pig-02]": 0.0006,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_routing_refusals.py::TestRenderedAdvice::test_no_member_renders_the_generic_action_kind_advice_either[pig-05]": 0.001,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_routing_refusals.py::TestRenderedAdvice::test_no_member_renders_the_generic_action_kind_advice_either[pig-06]": 0.0011,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_routing_refusals.py::TestRenderedAdvice::test_no_member_renders_the_generic_rejection_line[pig-01]": 0.0007,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_routing_refusals.py::TestRenderedAdvice::test_no_member_renders_the_generic_rejection_line[pig-02]": 0.0006,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_routing_refusals.py::TestRenderedAdvice::test_no_member_renders_the_generic_rejection_line[pig-05]": 0.0009,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_routing_refusals.py::TestRenderedAdvice::test_no_member_renders_the_generic_rejection_line[pig-06]": 0.0008,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_routing_refusals.py::TestRenderedAdvice::test_the_deck_disagreement_refusals_name_the_deck": 0.0006,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_routing_refusals.py::TestRenderedAdvice::test_the_detail_names_the_remedy[pig-01-does not serve that model]": 0.0011,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_routing_refusals.py::TestRenderedAdvice::test_the_detail_names_the_remedy[pig-02-has not enabled]": 0.0014,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_routing_refusals.py::TestRenderedAdvice::test_the_detail_names_the_remedy[pig-05-not over the protocol]": 0.0013,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_routing_refusals.py::TestRenderedAdvice::test_the_detail_names_the_remedy[pig-06-does not serve that capability]": 0.0007,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_routing_refusals.py::TestRenderedAdvice::test_the_disabled_integration_blames_neither_the_prompt_nor_the_callers_key": 0.0006,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_routing_refusals.py::TestRenderedAdvice::test_the_unserved_model_and_the_wrong_protocol_are_told_apart": 0.0006,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_routing_refusals.py::TestTheAdviceSurvivesThePipeBoundary::test_the_unknown_model_advice_reaches_the_caller_through_the_pipe_error": 0.0012,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_routing_refusals.py::TestTheCodeIsRecognized::test_any_other_code_is_not_a_routing_refusal[MODEL_NOT_ALLOWED_ERROR]": 0.0005,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_routing_refusals.py::TestTheCodeIsRecognized::test_any_other_code_is_not_a_routing_refusal[None]": 0.0007,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_routing_refusals.py::TestTheCodeIsRecognized::test_any_other_code_is_not_a_routing_refusal[PIG-01]": 0.0009,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_routing_refusals.py::TestTheCodeIsRecognized::test_any_other_code_is_not_a_routing_refusal[]": 0.0006,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_routing_refusals.py::TestTheCodeIsRecognized::test_any_other_code_is_not_a_routing_refusal[invalid_request_error]": 0.0013,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_routing_refusals.py::TestTheCodeIsRecognized::test_any_other_code_is_not_a_routing_refusal[model_not_allowed]": 0.0015,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_routing_refusals.py::TestTheCodeIsRecognized::test_any_other_code_is_not_a_routing_refusal[model_not_allowed_error]": 0.0009,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_routing_refusals.py::TestTheCodeIsRecognized::test_any_other_code_is_not_a_routing_refusal[model_not_found]": 0.0007,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_routing_refusals.py::TestTheCodeIsRecognized::test_any_other_code_is_not_a_routing_refusal[pig-07]": 0.0008,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_routing_refusals.py::TestTheCodeIsRecognized::test_any_other_code_is_not_a_routing_refusal[pig-09]": 0.0921,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_routing_refusals.py::TestTheCodeIsRecognized::test_any_other_code_is_not_a_routing_refusal[pig-11]": 0.0019,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_routing_refusals.py::TestTheCodeIsRecognized::test_any_other_code_is_not_a_routing_refusal[pipelex_storage_unreadable]": 0.1715,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_routing_refusals.py::TestTheCodeIsRecognized::test_each_code_maps_to_its_member[pig-01-unknown_model]": 0.1217,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_routing_refusals.py::TestTheCodeIsRecognized::test_each_code_maps_to_its_member[pig-02-disabled_integration]": 0.0014,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_routing_refusals.py::TestTheCodeIsRecognized::test_each_code_maps_to_its_member[pig-05-wrong_protocol]": 0.0017,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_routing_refusals.py::TestTheCodeIsRecognized::test_each_code_maps_to_its_member[pig-06-unserved_capability]": 0.0022,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_routing_refusals.py::TestTheCodeIsRecognized::test_every_member_is_reachable_from_a_wire_code[disabled_integration]": 0.0007,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_routing_refusals.py::TestTheCodeIsRecognized::test_every_member_is_reachable_from_a_wire_code[unknown_model]": 0.0015,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_routing_refusals.py::TestTheCodeIsRecognized::test_every_member_is_reachable_from_a_wire_code[unserved_capability]": 0.0013,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_routing_refusals.py::TestTheCodeIsRecognized::test_every_member_is_reachable_from_a_wire_code[wrong_protocol]": 0.0017,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_routing_refusals.py::TestTheCodeIsRecognized::test_the_code_is_read_whichever_provider_reported_it[anthropic]": 0.0006,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_routing_refusals.py::TestTheCodeIsRecognized::test_the_code_is_read_whichever_provider_reported_it[azure]": 0.0008,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_routing_refusals.py::TestTheCodeIsRecognized::test_the_code_is_read_whichever_provider_reported_it[bedrock]": 0.0009,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_routing_refusals.py::TestTheCodeIsRecognized::test_the_code_is_read_whichever_provider_reported_it[docling]": 0.0006,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_routing_refusals.py::TestTheCodeIsRecognized::test_the_code_is_read_whichever_provider_reported_it[fal]": 0.0011,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_routing_refusals.py::TestTheCodeIsRecognized::test_the_code_is_read_whichever_provider_reported_it[gateway]": 0.001,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_routing_refusals.py::TestTheCodeIsRecognized::test_the_code_is_read_whichever_provider_reported_it[google]": 0.0008,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_routing_refusals.py::TestTheCodeIsRecognized::test_the_code_is_read_whichever_provider_reported_it[huggingface]": 0.0006,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_routing_refusals.py::TestTheCodeIsRecognized::test_the_code_is_read_whichever_provider_reported_it[linkup]": 0.0017,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_routing_refusals.py::TestTheCodeIsRecognized::test_the_code_is_read_whichever_provider_reported_it[mistral]": 0.0012,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_routing_refusals.py::TestTheCodeIsRecognized::test_the_code_is_read_whichever_provider_reported_it[openai]": 0.0006,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_routing_refusals.py::TestTheCodeIsRecognized::test_the_code_is_read_whichever_provider_reported_it[pypdfium2]": 0.0012,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_routing_refusals.py::TestTheCodeIsRecognized::test_the_code_is_read_whichever_provider_reported_it[typesafe]": 0.001,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_routing_refusals.py::TestTheCodeIsRecognized::test_the_substrates_model_not_allowed_refusal_is_not_the_services_to_contribute": 0.001,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_routing_refusals.py::TestTheCodeIsRecognized::test_the_table_covers_the_whole_production_map": 0.1042,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_routing_refusals.py::TestTheCodeSurvivesEveryExtractHop::test_the_google_hop_would_not_carry_a_gateway_code_and_nothing_reaches_it_today": 0.0011,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_routing_refusals.py::TestTheCodeSurvivesEveryExtractHop::test_the_portkey_substrate_discards_the_payload_and_the_code_survives_anyway": 0.0092,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_routing_refusals.py::TestTheCodeSurvivesEveryExtractHop::test_through_plain_httpx_on_the_native_routes": 0.0011,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_routing_refusals.py::TestTheCodeSurvivesEveryExtractHop::test_through_the_openai_substrate_that_carries_every_chat_call[pig-01-unknown_model]": 0.1956,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_routing_refusals.py::TestTheCodeSurvivesEveryExtractHop::test_through_the_openai_substrate_that_carries_every_chat_call[pig-02-disabled_integration]": 0.0054,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_routing_refusals.py::TestTheCodeSurvivesEveryExtractHop::test_through_the_openai_substrate_that_carries_every_chat_call[pig-05-wrong_protocol]": 0.0065,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_routing_refusals.py::TestTheCodeSurvivesEveryExtractHop::test_through_the_openai_substrate_that_carries_every_chat_call[pig-06-unserved_capability]": 0.0051,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_routing_refusals.py::TestTheCodeSurvivesEveryExtractHop::test_through_the_portkey_substrate": 0.0189,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_routing_refusals.py::TestTheCodeSurvivesEveryExtractHop::test_through_the_shared_anthropic_driver": 0.0006,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_routing_refusals.py::TestTheScopeDecisionIsPinned::test_the_unmapped_routing_codes_are_not_routing_refusals[pig-03-400]": 0.0009,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_routing_refusals.py::TestTheScopeDecisionIsPinned::test_the_unmapped_routing_codes_are_not_routing_refusals[pig-04-404]": 0.1763,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_routing_refusals.py::TestTheScopeDecisionIsPinned::test_the_unmapped_routing_codes_belong_to_no_gateway_family_at_all": 0.0005,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_routing_refusals.py::TestTheThreeGatewayFamiliesDoNotShadowEachOther::test_no_other_familys_code_is_a_routing_refusal[pig-07]": 0.0011,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_routing_refusals.py::TestTheThreeGatewayFamiliesDoNotShadowEachOther::test_no_other_familys_code_is_a_routing_refusal[pig-08]": 0.0005,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_routing_refusals.py::TestTheThreeGatewayFamiliesDoNotShadowEachOther::test_no_other_familys_code_is_a_routing_refusal[pig-09]": 0.0012,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_routing_refusals.py::TestTheThreeGatewayFamiliesDoNotShadowEachOther::test_no_other_familys_code_is_a_routing_refusal[pig-10]": 0.0008,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_routing_refusals.py::TestTheThreeGatewayFamiliesDoNotShadowEachOther::test_no_other_familys_code_is_a_routing_refusal[pig-11]": 0.0006,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_routing_refusals.py::TestTheThreeGatewayFamiliesDoNotShadowEachOther::test_no_other_familys_code_is_a_routing_refusal[pipelex_document_host_refused]": 0.0007,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_routing_refusals.py::TestTheThreeGatewayFamiliesDoNotShadowEachOther::test_no_other_familys_code_is_a_routing_refusal[pipelex_document_too_large]": 0.0011,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_routing_refusals.py::TestTheThreeGatewayFamiliesDoNotShadowEachOther::test_no_other_familys_code_is_a_routing_refusal[pipelex_storage_object_too_large]": 0.0005,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_routing_refusals.py::TestTheThreeGatewayFamiliesDoNotShadowEachOther::test_no_other_familys_code_is_a_routing_refusal[pipelex_storage_unreadable]": 0.0008,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_routing_refusals.py::TestTheThreeGatewayFamiliesDoNotShadowEachOther::test_no_other_familys_code_is_a_routing_refusal[pipelex_storage_uri_invalid]": 0.0007,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_routing_refusals.py::TestTheThreeGatewayFamiliesDoNotShadowEachOther::test_no_routing_code_belongs_to_another_family[pig-01]": 0.0006,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_routing_refusals.py::TestTheThreeGatewayFamiliesDoNotShadowEachOther::test_no_routing_code_belongs_to_another_family[pig-02]": 0.0006,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_routing_refusals.py::TestTheThreeGatewayFamiliesDoNotShadowEachOther::test_no_routing_code_belongs_to_another_family[pig-05]": 0.0011,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_routing_refusals.py::TestTheThreeGatewayFamiliesDoNotShadowEachOther::test_no_routing_code_belongs_to_another_family[pig-06]": 0.0012,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_routing_refusals.py::TestTheThreeGatewayFamiliesDoNotShadowEachOther::test_the_three_maps_are_disjoint_as_sets": 0.0008,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_routing_refusals.py::TestTheThreeGatewayFamiliesDoNotShadowEachOther::test_the_vocabulary_contributes_every_mapped_code_once": 0.001,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_routing_refusals.py::TestWhatTheFamilyAnswersOverHTTP::test_an_unrecognized_400_still_answers_422": 0.1898,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_routing_refusals.py::TestWhatTheFamilyAnswersOverHTTP::test_every_member_answers_500_rather_than_the_422_it_used_to[pig-01]": 0.001,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_routing_refusals.py::TestWhatTheFamilyAnswersOverHTTP::test_every_member_answers_500_rather_than_the_422_it_used_to[pig-02]": 0.0006,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_routing_refusals.py::TestWhatTheFamilyAnswersOverHTTP::test_every_member_answers_500_rather_than_the_422_it_used_to[pig-05]": 0.0007,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_routing_refusals.py::TestWhatTheFamilyAnswersOverHTTP::test_every_member_answers_500_rather_than_the_422_it_used_to[pig-06]": 0.0015,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_search_worker.py::TestPipelexHostedSearchRequestBody::test_a_structured_search_sends_the_caller_s_schema": 0.0048,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_search_worker.py::TestPipelexHostedSearchRequestBody::test_the_body_names_the_model_and_carries_no_depth": 0.6623,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_search_worker.py::TestPipelexHostedSearchRequestBody::test_unset_optional_parameters_are_omitted_rather_than_sent_as_null": 0.0034,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_search_worker.py::TestPipelexHostedSearchResponse::test_a_response_with_no_answer_is_refused_rather_than_returned_empty": 0.0014,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_search_worker.py::TestPipelexHostedSearchResponse::test_a_sourced_answer_becomes_the_runtime_s_own_content": 0.0026,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_search_worker.py::TestPipelexHostedSearchResponse::test_a_structured_search_that_found_nothing_says_so": 0.0019,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_search_worker.py::TestPipelexHostedSearchResponse::test_the_usage_key_does_not_stop_the_envelope_being_recognised": 0.0024,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_search_worker.py::TestPipelexHostedSearchUsageTranslation::test_a_usage_block_the_route_did_not_send_leaves_the_categories_untouched[empty-usage]": 0.0012,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_search_worker.py::TestPipelexHostedSearchUsageTranslation::test_a_usage_block_the_route_did_not_send_leaves_the_categories_untouched[non-numeric-searches]": 0.0789,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_search_worker.py::TestPipelexHostedSearchUsageTranslation::test_a_usage_block_the_route_did_not_send_leaves_the_categories_untouched[null-usage]": 0.0019,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_search_worker.py::TestPipelexHostedSearchUsageTranslation::test_searches_become_megatokens_in_both_categories": 0.0053,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_service_error_codes_boot.py::TestPipelexHostedServiceErrorCodesBoot::test_boot_installs_every_pipelex_hosted_code_on_the_hub": 0.0781,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_spi_imports.py::TestPipelexHostedReachesCoreOnlyThroughTheSpi::test_every_core_import_is_published": 0.0124,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_spi_imports.py::TestPipelexHostedReachesCoreOnlyThroughTheSpi::test_no_backend_name_constant_is_imported": 0.135,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_spi_imports.py::TestPipelexHostedReachesCoreOnlyThroughTheSpi::test_the_package_imports_something_from_core": 0.0206,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_spi_imports.py::TestPipelexHostedReachesCoreOnlyThroughTheSpi::test_the_spi_table_parses": 0.0962,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_unresolved_references.py::TestClassification::test_a_deployment_that_serves_no_storage_is_an_operators_problem": 0.0651,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_unresolved_references.py::TestClassification::test_a_plain_400_without_a_recognized_code_still_takes_the_status_ladder": 0.0008,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_unresolved_references.py::TestClassification::test_a_reference_the_caller_can_repair_asks_them_to_change_the_input[pig-09]": 0.0006,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_unresolved_references.py::TestClassification::test_a_reference_the_caller_can_repair_asks_them_to_change_the_input[pipelex_document_address_refused]": 0.0013,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_unresolved_references.py::TestClassification::test_a_reference_the_caller_can_repair_asks_them_to_change_the_input[pipelex_document_bad_data_url]": 0.0024,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_unresolved_references.py::TestClassification::test_a_reference_the_caller_can_repair_asks_them_to_change_the_input[pipelex_document_empty]": 0.0024,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_unresolved_references.py::TestClassification::test_a_reference_the_caller_can_repair_asks_them_to_change_the_input[pipelex_document_host_refused]": 0.1042,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_unresolved_references.py::TestClassification::test_a_reference_the_caller_can_repair_asks_them_to_change_the_input[pipelex_document_redirect_refused]": 0.0013,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_unresolved_references.py::TestClassification::test_a_reference_the_caller_can_repair_asks_them_to_change_the_input[pipelex_document_scheme_refused]": 0.0005,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_unresolved_references.py::TestClassification::test_a_reference_the_caller_can_repair_asks_them_to_change_the_input[pipelex_document_unreachable]": 0.0007,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_unresolved_references.py::TestClassification::test_a_reference_the_caller_can_repair_asks_them_to_change_the_input[pipelex_document_unsupported_type]": 0.0007,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_unresolved_references.py::TestClassification::test_a_reference_the_caller_can_repair_asks_them_to_change_the_input[pipelex_storage_unreadable]": 0.0011,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_unresolved_references.py::TestClassification::test_a_reference_the_caller_can_repair_asks_them_to_change_the_input[pipelex_storage_uri_invalid]": 0.0018,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_unresolved_references.py::TestClassification::test_a_reference_the_caller_can_repair_asks_them_to_change_the_input[pipelex_unsupported_uri_scheme]": 0.0006,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_unresolved_references.py::TestClassification::test_each_code_classifies_as_its_member_and_is_never_retried[pig-09-reference_unresolved]": 0.0015,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_unresolved_references.py::TestClassification::test_each_code_classifies_as_its_member_and_is_never_retried[pipelex_document_address_refused-document_url_refused]": 0.0007,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_unresolved_references.py::TestClassification::test_each_code_classifies_as_its_member_and_is_never_retried[pipelex_document_bad_data_url-document_content_unusable]": 0.0007,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_unresolved_references.py::TestClassification::test_each_code_classifies_as_its_member_and_is_never_retried[pipelex_document_empty-document_content_unusable]": 0.0007,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_unresolved_references.py::TestClassification::test_each_code_classifies_as_its_member_and_is_never_retried[pipelex_document_host_refused-document_host_refused]": 0.213,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_unresolved_references.py::TestClassification::test_each_code_classifies_as_its_member_and_is_never_retried[pipelex_document_redirect_refused-document_url_refused]": 0.0009,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_unresolved_references.py::TestClassification::test_each_code_classifies_as_its_member_and_is_never_retried[pipelex_document_scheme_refused-document_url_refused]": 0.1317,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_unresolved_references.py::TestClassification::test_each_code_classifies_as_its_member_and_is_never_retried[pipelex_document_unreachable-document_unreachable]": 0.0008,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_unresolved_references.py::TestClassification::test_each_code_classifies_as_its_member_and_is_never_retried[pipelex_document_unsupported_type-document_content_unusable]": 0.0007,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_unresolved_references.py::TestClassification::test_each_code_classifies_as_its_member_and_is_never_retried[pipelex_storage_unreadable-storage_object_unreadable]": 0.0009,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_unresolved_references.py::TestClassification::test_each_code_classifies_as_its_member_and_is_never_retried[pipelex_storage_uri_invalid-storage_reference_invalid]": 0.0901,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_unresolved_references.py::TestClassification::test_each_code_classifies_as_its_member_and_is_never_retried[pipelex_storage_uri_unsupported-storage_not_served]": 0.0009,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_unresolved_references.py::TestClassification::test_each_code_classifies_as_its_member_and_is_never_retried[pipelex_unsupported_uri_scheme-document_url_refused]": 0.002,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_unresolved_references.py::TestRenderedAdvice::test_a_host_refusal_reaching_an_extract_reads_the_same": 0.0007,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_unresolved_references.py::TestRenderedAdvice::test_no_member_renders_the_generic_rejection_line[pig-09]": 0.0008,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_unresolved_references.py::TestRenderedAdvice::test_no_member_renders_the_generic_rejection_line[pipelex_document_address_refused]": 0.0007,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_unresolved_references.py::TestRenderedAdvice::test_no_member_renders_the_generic_rejection_line[pipelex_document_bad_data_url]": 0.001,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_unresolved_references.py::TestRenderedAdvice::test_no_member_renders_the_generic_rejection_line[pipelex_document_empty]": 0.0011,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_unresolved_references.py::TestRenderedAdvice::test_no_member_renders_the_generic_rejection_line[pipelex_document_host_refused]": 0.0007,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_unresolved_references.py::TestRenderedAdvice::test_no_member_renders_the_generic_rejection_line[pipelex_document_redirect_refused]": 0.0008,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_unresolved_references.py::TestRenderedAdvice::test_no_member_renders_the_generic_rejection_line[pipelex_document_scheme_refused]": 0.0006,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_unresolved_references.py::TestRenderedAdvice::test_no_member_renders_the_generic_rejection_line[pipelex_document_unreachable]": 0.0012,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_unresolved_references.py::TestRenderedAdvice::test_no_member_renders_the_generic_rejection_line[pipelex_document_unsupported_type]": 0.0006,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_unresolved_references.py::TestRenderedAdvice::test_no_member_renders_the_generic_rejection_line[pipelex_storage_unreadable]": 0.0014,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_unresolved_references.py::TestRenderedAdvice::test_no_member_renders_the_generic_rejection_line[pipelex_storage_uri_invalid]": 0.0015,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_unresolved_references.py::TestRenderedAdvice::test_no_member_renders_the_generic_rejection_line[pipelex_storage_uri_unsupported]": 0.1874,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_unresolved_references.py::TestRenderedAdvice::test_no_member_renders_the_generic_rejection_line[pipelex_unsupported_uri_scheme]": 0.0022,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_unresolved_references.py::TestRenderedAdvice::test_the_detail_names_the_remedy[pig-09-could not be resolved]": 0.0006,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_unresolved_references.py::TestRenderedAdvice::test_the_detail_names_the_remedy[pipelex_document_empty-fetched but cannot be used]": 0.0006,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_unresolved_references.py::TestRenderedAdvice::test_the_detail_names_the_remedy[pipelex_document_host_refused-security policy]": 0.0007,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_unresolved_references.py::TestRenderedAdvice::test_the_detail_names_the_remedy[pipelex_document_scheme_refused-https:// URL]": 0.0009,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_unresolved_references.py::TestRenderedAdvice::test_the_detail_names_the_remedy[pipelex_document_unreachable-publicly reachable]": 0.0007,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_unresolved_references.py::TestRenderedAdvice::test_the_detail_names_the_remedy[pipelex_storage_unreadable-does not exist or cannot be read]": 0.0012,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_unresolved_references.py::TestRenderedAdvice::test_the_detail_names_the_remedy[pipelex_storage_uri_invalid-malformed]": 0.0016,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_unresolved_references.py::TestRenderedAdvice::test_the_detail_names_the_remedy[pipelex_storage_uri_unsupported-contact support]": 0.0006,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_unresolved_references.py::TestRenderedAdvice::test_the_detail_names_the_remedy[pipelex_unsupported_uri_scheme-pipelex-storage:// reference]": 0.0006,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_unresolved_references.py::TestRenderedAdvice::test_the_host_refusal_is_stated_as_a_security_policy": 0.0008,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_unresolved_references.py::TestRenderedAdvice::test_the_two_storage_reference_failures_are_told_apart": 0.0008,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_unresolved_references.py::TestRenderedAdvice::test_the_unserved_scheme_does_not_ask_the_caller_to_fix_their_input": 0.0007,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_unresolved_references.py::TestRenderedAdvice::test_the_url_shape_refusals_share_one_remedy": 0.1731,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_unresolved_references.py::TestTheCodeIsRecognized::test_any_other_code_is_not_an_unresolved_reference[None]": 0.0012,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_unresolved_references.py::TestTheCodeIsRecognized::test_any_other_code_is_not_an_unresolved_reference[PIG-09]": 0.0009,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_unresolved_references.py::TestTheCodeIsRecognized::test_any_other_code_is_not_an_unresolved_reference[]": 0.0006,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_unresolved_references.py::TestTheCodeIsRecognized::test_any_other_code_is_not_an_unresolved_reference[invalid_request_error]": 0.0006,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_unresolved_references.py::TestTheCodeIsRecognized::test_any_other_code_is_not_an_unresolved_reference[pig-01]": 0.0006,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_unresolved_references.py::TestTheCodeIsRecognized::test_any_other_code_is_not_an_unresolved_reference[pig-07]": 0.0006,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_unresolved_references.py::TestTheCodeIsRecognized::test_any_other_code_is_not_an_unresolved_reference[pig-10]": 0.001,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_unresolved_references.py::TestTheCodeIsRecognized::test_any_other_code_is_not_an_unresolved_reference[pipelex_storage_object_too_large]": 0.0006,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_unresolved_references.py::TestTheCodeIsRecognized::test_each_code_maps_to_its_member[pig-09-reference_unresolved]": 0.1186,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_unresolved_references.py::TestTheCodeIsRecognized::test_each_code_maps_to_its_member[pipelex_document_address_refused-document_url_refused]": 0.0049,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_unresolved_references.py::TestTheCodeIsRecognized::test_each_code_maps_to_its_member[pipelex_document_bad_data_url-document_content_unusable]": 0.0006,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_unresolved_references.py::TestTheCodeIsRecognized::test_each_code_maps_to_its_member[pipelex_document_empty-document_content_unusable]": 0.0015,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_unresolved_references.py::TestTheCodeIsRecognized::test_each_code_maps_to_its_member[pipelex_document_host_refused-document_host_refused]": 0.0009,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_unresolved_references.py::TestTheCodeIsRecognized::test_each_code_maps_to_its_member[pipelex_document_redirect_refused-document_url_refused]": 0.001,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_unresolved_references.py::TestTheCodeIsRecognized::test_each_code_maps_to_its_member[pipelex_document_scheme_refused-document_url_refused]": 0.1137,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_unresolved_references.py::TestTheCodeIsRecognized::test_each_code_maps_to_its_member[pipelex_document_unreachable-document_unreachable]": 0.0006,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_unresolved_references.py::TestTheCodeIsRecognized::test_each_code_maps_to_its_member[pipelex_document_unsupported_type-document_content_unusable]": 0.002,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_unresolved_references.py::TestTheCodeIsRecognized::test_each_code_maps_to_its_member[pipelex_storage_unreadable-storage_object_unreadable]": 0.0017,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_unresolved_references.py::TestTheCodeIsRecognized::test_each_code_maps_to_its_member[pipelex_storage_uri_invalid-storage_reference_invalid]": 0.0015,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_unresolved_references.py::TestTheCodeIsRecognized::test_each_code_maps_to_its_member[pipelex_storage_uri_unsupported-storage_not_served]": 0.0006,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_unresolved_references.py::TestTheCodeIsRecognized::test_each_code_maps_to_its_member[pipelex_unsupported_uri_scheme-document_url_refused]": 0.0018,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_unresolved_references.py::TestTheCodeIsRecognized::test_every_member_is_reachable_from_a_wire_code[document_content_unusable]": 0.0006,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_unresolved_references.py::TestTheCodeIsRecognized::test_every_member_is_reachable_from_a_wire_code[document_host_refused]": 0.0006,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_unresolved_references.py::TestTheCodeIsRecognized::test_every_member_is_reachable_from_a_wire_code[document_unreachable]": 0.0008,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_unresolved_references.py::TestTheCodeIsRecognized::test_every_member_is_reachable_from_a_wire_code[document_url_refused]": 0.0019,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_unresolved_references.py::TestTheCodeIsRecognized::test_every_member_is_reachable_from_a_wire_code[reference_unresolved]": 0.0009,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_unresolved_references.py::TestTheCodeIsRecognized::test_every_member_is_reachable_from_a_wire_code[storage_not_served]": 0.0007,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_unresolved_references.py::TestTheCodeIsRecognized::test_every_member_is_reachable_from_a_wire_code[storage_object_unreadable]": 0.1774,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_unresolved_references.py::TestTheCodeIsRecognized::test_every_member_is_reachable_from_a_wire_code[storage_reference_invalid]": 0.0017,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_unresolved_references.py::TestTheCodeIsRecognized::test_the_code_is_read_whichever_provider_reported_it[anthropic]": 0.001,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_unresolved_references.py::TestTheCodeIsRecognized::test_the_code_is_read_whichever_provider_reported_it[azure]": 0.0006,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_unresolved_references.py::TestTheCodeIsRecognized::test_the_code_is_read_whichever_provider_reported_it[bedrock]": 0.0005,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_unresolved_references.py::TestTheCodeIsRecognized::test_the_code_is_read_whichever_provider_reported_it[docling]": 0.0006,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_unresolved_references.py::TestTheCodeIsRecognized::test_the_code_is_read_whichever_provider_reported_it[fal]": 0.0011,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_unresolved_references.py::TestTheCodeIsRecognized::test_the_code_is_read_whichever_provider_reported_it[gateway]": 0.0006,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_unresolved_references.py::TestTheCodeIsRecognized::test_the_code_is_read_whichever_provider_reported_it[google]": 0.0007,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_unresolved_references.py::TestTheCodeIsRecognized::test_the_code_is_read_whichever_provider_reported_it[huggingface]": 0.2025,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_unresolved_references.py::TestTheCodeIsRecognized::test_the_code_is_read_whichever_provider_reported_it[linkup]": 0.0006,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_unresolved_references.py::TestTheCodeIsRecognized::test_the_code_is_read_whichever_provider_reported_it[mistral]": 0.0006,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_unresolved_references.py::TestTheCodeIsRecognized::test_the_code_is_read_whichever_provider_reported_it[openai]": 0.0007,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_unresolved_references.py::TestTheCodeIsRecognized::test_the_code_is_read_whichever_provider_reported_it[pypdfium2]": 0.0006,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_unresolved_references.py::TestTheCodeIsRecognized::test_the_code_is_read_whichever_provider_reported_it[typesafe]": 0.0032,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_unresolved_references.py::TestTheCodeIsRecognized::test_the_table_covers_the_whole_production_map": 0.0018,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_unresolved_references.py::TestTheCodeSurvivesEveryExtractHop::test_the_native_envelope_survives_the_portkey_substrate_too": 0.0212,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_unresolved_references.py::TestTheCodeSurvivesEveryExtractHop::test_the_portkey_substrate_discards_the_payload_and_the_code_survives_anyway": 0.0164,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_unresolved_references.py::TestTheCodeSurvivesEveryExtractHop::test_through_plain_httpx_on_the_native_routes[pipelex_document_unsupported_type-document_content_unusable]": 0.0007,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_unresolved_references.py::TestTheCodeSurvivesEveryExtractHop::test_through_plain_httpx_on_the_native_routes[pipelex_storage_unreadable-storage_object_unreadable]": 0.0008,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_unresolved_references.py::TestTheCodeSurvivesEveryExtractHop::test_through_plain_httpx_on_the_native_routes[pipelex_storage_uri_invalid-storage_reference_invalid]": 0.0013,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_unresolved_references.py::TestTheCodeSurvivesEveryExtractHop::test_through_the_openai_substrate_that_carries_every_chat_call": 0.009,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_unresolved_references.py::TestTheCodeSurvivesEveryExtractHop::test_through_the_portkey_substrate": 0.0283,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_unresolved_references.py::TestTheCodeSurvivesEveryExtractHop::test_through_the_shared_anthropic_driver": 0.0015,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_unresolved_references.py::TestTheTwoGatewayFamiliesDoNotShadowEachOther::test_no_request_limit_code_is_also_an_unresolved_reference[pig-07]": 0.0008,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_unresolved_references.py::TestTheTwoGatewayFamiliesDoNotShadowEachOther::test_no_request_limit_code_is_also_an_unresolved_reference[pig-08]": 0.0008,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_unresolved_references.py::TestTheTwoGatewayFamiliesDoNotShadowEachOther::test_no_request_limit_code_is_also_an_unresolved_reference[pig-10]": 0.0005,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_unresolved_references.py::TestTheTwoGatewayFamiliesDoNotShadowEachOther::test_no_request_limit_code_is_also_an_unresolved_reference[pig-11]": 0.0006,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_unresolved_references.py::TestTheTwoGatewayFamiliesDoNotShadowEachOther::test_no_request_limit_code_is_also_an_unresolved_reference[pipelex_document_too_large]": 0.0011,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_unresolved_references.py::TestTheTwoGatewayFamiliesDoNotShadowEachOther::test_no_request_limit_code_is_also_an_unresolved_reference[pipelex_storage_object_too_large]": 0.0006,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_unresolved_references.py::TestTheTwoGatewayFamiliesDoNotShadowEachOther::test_no_unresolved_reference_code_is_also_a_request_limit[pig-09]": 0.0007,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_unresolved_references.py::TestTheTwoGatewayFamiliesDoNotShadowEachOther::test_no_unresolved_reference_code_is_also_a_request_limit[pipelex_document_address_refused]": 0.0006,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_unresolved_references.py::TestTheTwoGatewayFamiliesDoNotShadowEachOther::test_no_unresolved_reference_code_is_also_a_request_limit[pipelex_document_bad_data_url]": 0.0005,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_unresolved_references.py::TestTheTwoGatewayFamiliesDoNotShadowEachOther::test_no_unresolved_reference_code_is_also_a_request_limit[pipelex_document_empty]": 0.0011,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_unresolved_references.py::TestTheTwoGatewayFamiliesDoNotShadowEachOther::test_no_unresolved_reference_code_is_also_a_request_limit[pipelex_document_host_refused]": 0.0006,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_unresolved_references.py::TestTheTwoGatewayFamiliesDoNotShadowEachOther::test_no_unresolved_reference_code_is_also_a_request_limit[pipelex_document_redirect_refused]": 0.0007,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_unresolved_references.py::TestTheTwoGatewayFamiliesDoNotShadowEachOther::test_no_unresolved_reference_code_is_also_a_request_limit[pipelex_document_scheme_refused]": 0.001,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_unresolved_references.py::TestTheTwoGatewayFamiliesDoNotShadowEachOther::test_no_unresolved_reference_code_is_also_a_request_limit[pipelex_document_unreachable]": 0.0006,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_unresolved_references.py::TestTheTwoGatewayFamiliesDoNotShadowEachOther::test_no_unresolved_reference_code_is_also_a_request_limit[pipelex_document_unsupported_type]": 0.001,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_unresolved_references.py::TestTheTwoGatewayFamiliesDoNotShadowEachOther::test_no_unresolved_reference_code_is_also_a_request_limit[pipelex_storage_unreadable]": 0.001,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_unresolved_references.py::TestTheTwoGatewayFamiliesDoNotShadowEachOther::test_no_unresolved_reference_code_is_also_a_request_limit[pipelex_storage_uri_invalid]": 0.0011,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_unresolved_references.py::TestTheTwoGatewayFamiliesDoNotShadowEachOther::test_no_unresolved_reference_code_is_also_a_request_limit[pipelex_storage_uri_unsupported]": 0.0008,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_unresolved_references.py::TestTheTwoGatewayFamiliesDoNotShadowEachOther::test_no_unresolved_reference_code_is_also_a_request_limit[pipelex_unsupported_uri_scheme]": 0.0013,
- "tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_unresolved_references.py::TestTheTwoGatewayFamiliesDoNotShadowEachOther::test_the_storage_codes_are_split_between_the_two_families_on_the_same_route": 0.0014,
"tests/unit/pipelex/providers/pypdfium2/test_pypdfium2_worker_error_handling.py::TestPypdfium2WorkerErrorHandling::test_error_report_for_file_not_found": 0.003,
"tests/unit/pipelex/providers/pypdfium2/test_pypdfium2_worker_error_handling.py::TestPypdfium2WorkerErrorHandling::test_error_report_for_os_error_is_retryable": 0.0945,
"tests/unit/pipelex/providers/pypdfium2/test_pypdfium2_worker_error_handling.py::TestPypdfium2WorkerErrorHandling::test_extraction_error_categorization[file_not_found-FileNotFoundError-No such file: /tmp/missing.pdf-content-change_input]": 0.8677,
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 39a4cb0f6..4ab140e28 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,7 +4,7 @@
### Changed
-- **The hosted backend's errors and messages no longer carry a codename (Breaking)**: its error classes are renamed from `Manifold*` to `PipelexHosted*`, such as `PipelexHostedError` and `PipelexHostedCredentialsError`, with their reference pages, while each keeps the `type` and `title` of its generic family. Its messages speak of "the Pipelex service", and the two that refuse a missing endpoint or key name the backend's `endpoint` and `api_key` settings rather than an environment variable. Its provider package moves to `pipelex.providers.pipelex_hosted`, `extract_manifold_metadata` is now `extract_pipelex_hosted_metadata`, and the enum member `PipelexBackend.MANIFOLD` is now `PipelexBackend.PIPELEX_HOSTED`, with its value `pipelex_manifold` unchanged.
+- **The hosted-only inference provider plugin is no longer shipped (Breaking)**: its built-in plugin, its sdk tokens, its error classes and their reference pages, and the `PipelexBackend` member naming its backend are removed, leaving `PipelexBackend.INTERNAL` alone. A project config that still declares the hosted backend disabled, or a routing profile that names it but is not active, keeps booting; a model spec naming one of its sdk tokens now fails when its worker is built, unless a plugin of your own registers that token.
### Added
diff --git a/docs/errors/inference-and-providers.md b/docs/errors/inference-and-providers.md
index f5a17c10d..9058c1c0d 100644
--- a/docs/errors/inference-and-providers.md
+++ b/docs/errors/inference-and-providers.md
@@ -105,13 +105,6 @@ own page. Classes are grouped by subsystem.
- [`MistralPluginError`](mistral-plugin-error.md) — Mistral plugin
- [`MistralWorkerConfigurationError`](mistral-worker-configuration-error.md) — Mistral worker configuration
- [`OpenAIClientFactoryError`](open-ai-client-factory-error.md) — OpenAI client factory error
-- [`PipelexHostedCredentialsError`](pipelex-hosted-credentials-error.md) — Inference backend credentials missing
-- [`PipelexHostedEndpointError`](pipelex-hosted-endpoint-error.md) — Inference backend endpoint missing
-- [`PipelexHostedError`](pipelex-hosted-error.md) — Inference backend error
-- [`PipelexHostedExtractResponseError`](pipelex-hosted-extract-response-error.md) — Extract response unreadable
-- [`PipelexHostedFactoryError`](pipelex-hosted-factory-error.md) — Inference client setup error
-- [`PipelexHostedSearchEmptyResultError`](pipelex-hosted-search-empty-result-error.md) — Search returned no result
-- [`PipelexHostedSearchResponseError`](pipelex-hosted-search-response-error.md) — Search response unreadable
- [`PortkeyCredentialsError`](portkey-credentials-error.md) — Portkey credentials
- [`PortkeyError`](portkey-error.md) — Portkey
- [`PortkeyFactoryError`](portkey-factory-error.md) — Portkey factory
diff --git a/docs/errors/pipelex-hosted-credentials-error.md b/docs/errors/pipelex-hosted-credentials-error.md
deleted file mode 100644
index 389e31a67..000000000
--- a/docs/errors/pipelex-hosted-credentials-error.md
+++ /dev/null
@@ -1,19 +0,0 @@
----
-title: "Inference backend credentials missing"
-description: "Reference for the `PipelexHostedCredentialsError` Pipelex error class."
----
-
-<!-- pipelex:generated -->
-
-# Inference backend credentials missing
-
-| Field | Value |
-|---|---|
-| `error_type` | `PipelexHostedCredentialsError` |
-| `title` | Inference backend credentials missing |
-| `type_uri` | `https://docs.pipelex.com/latest/errors/inference-backend-credentials-error/` |
-| `error_domain` | _(inherited from parent)_ |
-| Defined in | `pipelex.providers.pipelex_hosted.pipelex_hosted_exceptions` |
-| Parent class | [`PipelexHostedError`](pipelex-hosted-error.md) |
-
-[Back to Error Reference](index.md)
diff --git a/docs/errors/pipelex-hosted-endpoint-error.md b/docs/errors/pipelex-hosted-endpoint-error.md
deleted file mode 100644
index dd1b924ce..000000000
--- a/docs/errors/pipelex-hosted-endpoint-error.md
+++ /dev/null
@@ -1,21 +0,0 @@
----
-title: "Inference backend endpoint missing"
-description: "Reference for the `PipelexHostedEndpointError` Pipelex error class."
----
-
-<!-- pipelex:generated -->
-
-# Inference backend endpoint missing
-
-The backend declares no usable endpoint for the Pipelex service.
-
-| Field | Value |
-|---|---|
-| `error_type` | `PipelexHostedEndpointError` |
-| `title` | Inference backend endpoint missing |
-| `type_uri` | `https://docs.pipelex.com/latest/errors/inference-backend-credentials-error/` |
-| `error_domain` | _(inherited from parent)_ |
-| Defined in | `pipelex.providers.pipelex_hosted.pipelex_hosted_exceptions` |
-| Parent class | [`PipelexHostedError`](pipelex-hosted-error.md) |
-
-[Back to Error Reference](index.md)
diff --git a/docs/errors/pipelex-hosted-error.md b/docs/errors/pipelex-hosted-error.md
deleted file mode 100644
index 5592032ea..000000000
--- a/docs/errors/pipelex-hosted-error.md
+++ /dev/null
@@ -1,19 +0,0 @@
----
-title: "Inference backend error"
-description: "Reference for the `PipelexHostedError` Pipelex error class."
----
-
-<!-- pipelex:generated -->
-
-# Inference backend error
-
-| Field | Value |
-|---|---|
-| `error_type` | `PipelexHostedError` |
-| `title` | Inference backend error |
-| `type_uri` | `https://docs.pipelex.com/latest/errors/cogt-error/` |
-| `error_domain` | _(inherited from parent)_ |
-| Defined in | `pipelex.providers.pipelex_hosted.pipelex_hosted_exceptions` |
-| Parent class | [`CogtError`](cogt-error.md) |
-
-[Back to Error Reference](index.md)
diff --git a/docs/errors/pipelex-hosted-extract-response-error.md b/docs/errors/pipelex-hosted-extract-response-error.md
deleted file mode 100644
index 8f10e890d..000000000
--- a/docs/errors/pipelex-hosted-extract-response-error.md
+++ /dev/null
@@ -1,19 +0,0 @@
----
-title: "Extract response unreadable"
-description: "Reference for the `PipelexHostedExtractResponseError` Pipelex error class."
----
-
-<!-- pipelex:generated -->
-
-# Extract response unreadable
-
-| Field | Value |
-|---|---|
-| `error_type` | `PipelexHostedExtractResponseError` |
-| `title` | Extract response unreadable |
-| `type_uri` | `https://docs.pipelex.com/latest/errors/extract-job-failure-error/` |
-| `error_domain` | _(inherited from parent)_ |
-| Defined in | `pipelex.providers.pipelex_hosted.pipelex_hosted_exceptions` |
-| Parent class | [`PipelexHostedError`](pipelex-hosted-error.md) |
-
-[Back to Error Reference](index.md)
diff --git a/docs/errors/pipelex-hosted-factory-error.md b/docs/errors/pipelex-hosted-factory-error.md
deleted file mode 100644
index bfb3defbc..000000000
--- a/docs/errors/pipelex-hosted-factory-error.md
+++ /dev/null
@@ -1,19 +0,0 @@
----
-title: "Inference client setup error"
-description: "Reference for the `PipelexHostedFactoryError` Pipelex error class."
----
-
-<!-- pipelex:generated -->
-
-# Inference client setup error
-
-| Field | Value |
-|---|---|
-| `error_type` | `PipelexHostedFactoryError` |
-| `title` | Inference client setup error |
-| `type_uri` | `https://docs.pipelex.com/latest/errors/cogt-error/` |
-| `error_domain` | _(inherited from parent)_ |
-| Defined in | `pipelex.providers.pipelex_hosted.pipelex_hosted_exceptions` |
-| Parent class | [`PipelexHostedError`](pipelex-hosted-error.md) |
-
-[Back to Error Reference](index.md)
diff --git a/docs/errors/pipelex-hosted-search-empty-result-error.md b/docs/errors/pipelex-hosted-search-empty-result-error.md
deleted file mode 100644
index 7def95856..000000000
--- a/docs/errors/pipelex-hosted-search-empty-result-error.md
+++ /dev/null
@@ -1,19 +0,0 @@
----
-title: "Search returned no result"
-description: "Reference for the `PipelexHostedSearchEmptyResultError` Pipelex error class."
----
-
-<!-- pipelex:generated -->
-
-# Search returned no result
-
-| Field | Value |
-|---|---|
-| `error_type` | `PipelexHostedSearchEmptyResultError` |
-| `title` | Search returned no result |
-| `type_uri` | `https://docs.pipelex.com/latest/errors/search-job-failure-error/` |
-| `error_domain` | _(inherited from parent)_ |
-| Defined in | `pipelex.providers.pipelex_hosted.pipelex_hosted_exceptions` |
-| Parent class | [`PipelexHostedError`](pipelex-hosted-error.md) |
-
-[Back to Error Reference](index.md)
diff --git a/docs/errors/pipelex-hosted-search-response-error.md b/docs/errors/pipelex-hosted-search-response-error.md
deleted file mode 100644
index 4a88a1b61..000000000
--- a/docs/errors/pipelex-hosted-search-response-error.md
+++ /dev/null
@@ -1,19 +0,0 @@
----
-title: "Search response unreadable"
-description: "Reference for the `PipelexHostedSearchResponseError` Pipelex error class."
----
-
-<!-- pipelex:generated -->
-
-# Search response unreadable
-
-| Field | Value |
-|---|---|
-| `error_type` | `PipelexHostedSearchResponseError` |
-| `title` | Search response unreadable |
-| `type_uri` | `https://docs.pipelex.com/latest/errors/search-job-failure-error/` |
-| `error_domain` | _(inherited from parent)_ |
-| Defined in | `pipelex.providers.pipelex_hosted.pipelex_hosted_exceptions` |
-| Parent class | [`PipelexHostedError`](pipelex-hosted-error.md) |
-
-[Back to Error Reference](index.md)
diff --git a/docs/setup/telemetry.md b/docs/setup/telemetry.md
index 7abd3f8a1..0eaa6d030 100644
--- a/docs/setup/telemetry.md
+++ b/docs/setup/telemetry.md
@@ -131,11 +131,7 @@ Anything that names no caller of its own keeps reporting under the `user_id` you
The extras do not depend on that. A run that leaves `user_id` at its default still carries its `extras` onto every capture, under your configured id — knowing which entities a run belongs to and naming its caller are two separate decisions, and you may take one without the other.
-The extras also travel with the run's inference calls when they go through Pipelex. Every request the hosted backend makes carries one `x-pipelex-metadata` header: a flat JSON object holding the run's extras as they are, plus the run's `user_id` and `pipeline_run_id` and the step's `pipe_run_id`, `pipe_code` and `content_generation_job_id` when it has them, so the service can attribute and log each call. If an extras key has the same name as one of those ids, the run's own value is the one sent, since the extras are yours to set and must not be able to restate whose run it is. No other backend receives this header: a provider you reach directly with your own key gets none of your labels.
-
-```text
-x-pipelex-metadata: {"org_id":"org_acme","user_id":"user_42","pipeline_run_id":"run_abc","pipe_run_id":"0123456789abcdef","pipe_code":"summarize_doc"}
-```
+The extras are also available to the inference workers, on the job metadata of every call. None of the backends Pipelex ships sends them anywhere: a provider you reach directly with your own key gets none of your labels. An inference backend plugin of your own may forward them to a service you operate, for instance so that it can attribute each call's spend, and if it does, the run's own ids should win over an extras key of the same name, since the extras are caller data and must not be able to restate whose run it is.
### Work that is not a run, and crashes
diff --git a/pipelex/cogt/model_backends/backend.py b/pipelex/cogt/model_backends/backend.py
index 2d0dcde43..d8c9e9ca7 100644
--- a/pipelex/cogt/model_backends/backend.py
+++ b/pipelex/cogt/model_backends/backend.py
@@ -12,18 +12,8 @@ from pipelex.tools.typing.pydantic_utils import empty_dict_factory_of, empty_lis
class PipelexBackend(StrEnum):
"""Special Pipelex-managed inference backends."""
- # The value is the backend name the hosted plane's config declares, so it keeps that spelling
- PIPELEX_HOSTED = "pipelex_manifold"
INTERNAL = "internal" # Software-only backend, runs locally without AI
- @property
- def display_name(self) -> str:
- match self:
- case PipelexBackend.PIPELEX_HOSTED:
- return "Pipelex"
- case PipelexBackend.INTERNAL:
- return "Internal (software-only)"
-
class InferenceBackend(ConfigModel):
name: str
diff --git a/pipelex/providers/builtins.py b/pipelex/providers/builtins.py
index 4118c784f..68731d331 100644
--- a/pipelex/providers/builtins.py
+++ b/pipelex/providers/builtins.py
@@ -13,7 +13,6 @@ from pipelex.providers.log_sinks.log_sink_plugin import LogSinkPlugin
from pipelex.providers.mistral.mistral_plugin import MistralPlugin
from pipelex.providers.openai.openai_plugin import OpenAIPlugin
from pipelex.providers.openrouter.openrouter_plugin import OpenRouterPlugin
-from pipelex.providers.pipelex_hosted.pipelex_hosted_plugin import PipelexHostedPlugin
from pipelex.providers.portkey.portkey_plugin import PortkeyPlugin
from pipelex.providers.pypdfium2.pypdfium2_plugin import Pypdfium2Plugin
from pipelex.providers.reportlab.reportlab_plugin import ReportlabDocGenPlugin
@@ -40,7 +39,6 @@ KERNEL_BUILTIN_PLUGINS: list[PipelexPlugin] = [
StoragePlugin(),
SecretsPlugin(),
OpenAIPlugin(),
- PipelexHostedPlugin(),
PortkeyPlugin(),
AnthropicPlugin(),
MistralPlugin(),
diff --git a/pipelex/providers/pipelex_hosted/__init__.py b/pipelex/providers/pipelex_hosted/__init__.py
deleted file mode 100644
index e69de29bb..000000000
diff --git a/pipelex/providers/pipelex_hosted/pipelex_hosted_anthropic_extras.py b/pipelex/providers/pipelex_hosted/pipelex_hosted_anthropic_extras.py
deleted file mode 100644
index 080c7ddb4..000000000
--- a/pipelex/providers/pipelex_hosted/pipelex_hosted_anthropic_extras.py
+++ /dev/null
@@ -1,35 +0,0 @@
-"""The per-request extras of a Claude call through the Pipelex service.
-
-Claude reaches the service over the open Anthropic worker, registered here under the package's own
-`manifold_anthropic` sdk token with this factory: the worker asks it, per request, what joins the
-call, and the answer is the `x-pipelex-metadata` header naming the run and the step (see
-`pipelex_hosted_metadata`). Every other Anthropic path builds the worker without a factory and sends
-nothing of the kind.
-"""
-
-from __future__ import annotations
-
-from typing import TYPE_CHECKING, Any
-
-from typing_extensions import override
-
-from pipelex.plugins.backend_extras_factory import BackendExtrasFactory
-from pipelex.providers.pipelex_hosted.pipelex_hosted_metadata import make_pipelex_hosted_metadata_headers
-
-if TYPE_CHECKING:
- from pipelex.cogt.inference.inference_job_abstract import InferenceJobAbstract
- from pipelex.cogt.model_backends.model_spec import InferenceModelSpec
-
-
-class PipelexHostedAnthropicExtrasFactory(BackendExtrasFactory):
- @override
- def make_extras(
- self, inference_model: InferenceModelSpec, *, inference_job: InferenceJobAbstract, output_desc: str
- ) -> tuple[dict[str, str], dict[str, Any]]:
- """The metadata header alone, and no body additions.
-
- `inference_model` and `output_desc` are part of the shared factory signature and unused here:
- the header names the job, not the model or the output.
- """
- del inference_model, output_desc
- return make_pipelex_hosted_metadata_headers(job_metadata=inference_job.job_metadata), {}
diff --git a/pipelex/providers/pipelex_hosted/pipelex_hosted_completions_factory.py b/pipelex/providers/pipelex_hosted/pipelex_hosted_completions_factory.py
deleted file mode 100644
index a9a923b97..000000000
--- a/pipelex/providers/pipelex_hosted/pipelex_hosted_completions_factory.py
+++ /dev/null
@@ -1,136 +0,0 @@
-"""The Chat Completions factory for the Pipelex service.
-
-**It subclasses `OpenAICompletionsFactory` and carries its own copy of the document override.**
-Documents travel to a Pipelex-operated gateway as a `ChatCompletionContentPartImageParam` holding a
-data URL, not as an OpenAI file part: the gateway translates that part into whatever document format
-the provider it picked actually wants, and the base class's file part is not something it can
-translate. The Portkey-path factory makes exactly the same move for exactly the same reason —
-because it is the same gateway codebase on the other end.
-
-Subclassing *that* factory instead of copying its override was considered and rejected: it also
-carries the Portkey extract-response parsing for four providers and a Portkey header build, none of
-which this path wants, and inheriting from it would make the eventual retirement of the Portkey
-package an untangling rather than a deletion. The duplication is the price the two-gateways design
-already agreed to pay, and it dies whole with the path it belongs to.
-"""
-
-from __future__ import annotations
-
-from typing import TYPE_CHECKING, Any
-
-from typing_extensions import override
-
-from pipelex.cogt.document.prompt_document_utils import prep_prompt_documents
-from pipelex.cogt.image.prompt_image import PromptImageDetail
-from pipelex.cogt.image.prompt_image_utils import prep_prompt_images
-from pipelex.config import get_config
-from pipelex.providers.openai.openai_completions_factory import OpenAICompletionsFactory
-from pipelex.providers.pipelex_hosted.pipelex_hosted_constants import PipelexHostedOpenAISdkVariant
-from pipelex.providers.pipelex_hosted.pipelex_hosted_exceptions import PipelexHostedFactoryError
-from pipelex.providers.pipelex_hosted.pipelex_hosted_factory import PipelexHostedFactory
-from pipelex.tools.uri.prepared_file import PreparedFileBase64, PreparedFileHttpUrl, PreparedFileLocalPath
-
-if TYPE_CHECKING:
- # Deferred imports: avoid pulling heavy SDK at module-load time
- import openai
- from openai.types.chat import ChatCompletionMessageParam
-
- from pipelex.cogt.inference.inference_job_abstract import InferenceJobAbstract
- from pipelex.cogt.llm.llm_job import LLMJob
- from pipelex.cogt.model_backends.backend import InferenceBackend
- from pipelex.cogt.model_backends.model_spec import InferenceModelSpec
- from pipelex.plugins.model_handle import ModelHandle
-
-
-class PipelexHostedCompletionsFactory(OpenAICompletionsFactory):
- @override
- async def make_simple_messages(
- self,
- llm_job: LLMJob,
- ) -> list[ChatCompletionMessageParam]:
- """Documents travel as an `image_url` data URL, which the gateway translates per provider."""
- # Deferred imports: avoid pulling heavy SDK at module-load time
- from openai.types.chat import ( # ruff: ignore[import-outside-top-level]
- ChatCompletionContentPartImageParam,
- ChatCompletionContentPartParam,
- ChatCompletionContentPartTextParam,
- ChatCompletionSystemMessageParam,
- ChatCompletionUserMessageParam,
- )
- from openai.types.chat.chat_completion_content_part_image_param import ImageURL as OpenAIImageURL # ruff: ignore[import-outside-top-level]
-
- llm_prompt = llm_job.llm_prompt
- messages: list[ChatCompletionMessageParam] = []
- user_contents: list[ChatCompletionContentPartParam] = []
- if system_content := llm_prompt.system_text:
- messages.append(ChatCompletionSystemMessageParam(role="system", content=system_content))
- if user_prompt_text := llm_prompt.user_text:
- user_part_text = ChatCompletionContentPartTextParam(text=user_prompt_text, type="text")
- user_contents.append(user_part_text)
- if llm_prompt.user_images:
- detail = llm_job.job_params.image_detail or PromptImageDetail.AUTO
- prepped_images = await prep_prompt_images(prompt_images=llm_prompt.user_images, is_http_url_enabled=self.is_http_url_enabled)
- for prepped_image in prepped_images:
- url: str
- match prepped_image:
- case PreparedFileHttpUrl():
- url = prepped_image.url
- case PreparedFileBase64():
- url = prepped_image.as_data_url()
- case PreparedFileLocalPath():
- msg = "PreparedFileLocalPath is not supported for images - should be converted to base64"
- raise TypeError(msg)
-
- image_url_obj = OpenAIImageURL(url=url, detail=detail.as_openai_detail)
- image_param = ChatCompletionContentPartImageParam(image_url=image_url_obj, type="image_url")
- user_contents.append(image_param)
-
- # Documents must always be base64 encoded for the image_url form, whatever the images
- # setting allows: an http URL here would reach the gateway as a link it does not fetch.
- if llm_prompt.user_documents:
- prepped_documents = await prep_prompt_documents(prompt_documents=llm_prompt.user_documents, is_http_url_enabled=False)
- for prepped_document in prepped_documents:
- match prepped_document:
- case PreparedFileBase64():
- doc_url = prepped_document.as_data_url()
- image_url_obj = OpenAIImageURL(url=doc_url, detail="auto")
- doc_param = ChatCompletionContentPartImageParam(image_url=image_url_obj, type="image_url")
- user_contents.append(doc_param)
- case PreparedFileHttpUrl() | PreparedFileLocalPath():
- msg = f"{type(prepped_document).__name__} is not supported for documents - should be converted to base64"
- raise TypeError(msg)
-
- messages.append(ChatCompletionUserMessageParam(role="user", content=user_contents))
- return messages
-
- @classmethod
- def make_openai_client_for_completions(
- cls,
- model_handle: ModelHandle,
- *,
- backend: InferenceBackend,
- ) -> openai.AsyncOpenAI:
- # Deferred import: avoid pulling heavy SDK at module-load time
- import openai # ruff: ignore[import-outside-top-level]
-
- if not PipelexHostedOpenAISdkVariant.is_completions(model_handle.sdk):
- msg = f"ModelHandle '{model_handle}' is not supported by '{cls.__name__}'"
- raise PipelexHostedFactoryError(msg)
-
- return openai.AsyncOpenAI(
- base_url=PipelexHostedFactory.get_base_url(backend=backend),
- # Auth travels in the service's own header, not in the OpenAI Authorization one. The SDK
- # has rejected an empty api_key since 2.34.0, so the slot holds a placeholder the
- # gateway never reads.
- api_key="unused-auth-via-hosted-header",
- # Tier 1 transport retry: set explicitly from config rather than inheriting the SDK
- # default, so a transport_max_retries override applies to this path too.
- max_retries=get_config().inference.transport_max_retries,
- default_headers=PipelexHostedFactory.make_auth_headers(backend=backend),
- )
-
- @override
- def make_extras(
- self, inference_model: InferenceModelSpec, *, inference_job: InferenceJobAbstract, output_desc: str
- ) -> tuple[dict[str, str], dict[str, Any]]:
- return PipelexHostedFactory.make_extras(inference_model=inference_model, inference_job=inference_job, output_desc=output_desc)
diff --git a/pipelex/providers/pipelex_hosted/pipelex_hosted_constants.py b/pipelex/providers/pipelex_hosted/pipelex_hosted_constants.py
deleted file mode 100644
index 88080a844..000000000
--- a/pipelex/providers/pipelex_hosted/pipelex_hosted_constants.py
+++ /dev/null
@@ -1,103 +0,0 @@
-"""The hosted dialect's names: its sdk set, its two wire headers, and its route paths.
-
-Everything the hosted plugin needs to name is named here rather than imported from
-``providers/portkey/``. The duplication is deliberate — it is the
-no-intertwining rule from the two-gateways design, and it is what keeps the eventual retirement of
-the Portkey path a module deletion rather than an untangling.
-"""
-
-from enum import StrEnum
-
-# The header the Pipelex service reads the caller's token from.
-#
-# The gateway is a continuation of the Portkey AI Gateway, and the name its inherited auth layer
-# answers to is `x-portkey-api-key`. Until 2026-09-03 that was the single word of the vendor's
-# vocabulary still on the hosted wire; the gateway now translates this spelling to that one before
-# its auth runs (`src/pig/serviceTokenHeader.ts` there), which is what let the rename happen — it
-# had no runtime-only half. This is the one header the dialect sends about itself, on every
-# protocol: the OpenAI-substrate factories and the native client put it there directly, and the
-# Anthropic client reads it from the backend's `auth_header` field, so the value in
-# `backends.toml` must spell it exactly as this constant does.
-PIPELEX_HOSTED_AUTH_HEADER = "x-pipelex-api-key"
-
-# The header that says whose call this is, sent on every request beside the token.
-#
-# Its value is a flat JSON object of string to string: the run's opaque `extras` and the runtime's
-# own ids for the run and the step (see `pipelex_hosted_metadata`). It differs per job, so unlike the token
-# it is never a client default: every path adds it per request. The vendor spelling of the same idea,
-# `x-portkey-metadata`, is never sent — the gateway reads this name, and the dialect speaks none of
-# the vendor's vocabulary it does not have to.
-PIPELEX_HOSTED_METADATA_HEADER = "x-pipelex-metadata"
-
-# The gateway's response headers, the two spellings of its trace id, are named in
-# `pipelex_hosted_error_metadata`, beside the distiller that reads them. This file names what the dialect
-# *sends*.
-
-# The OpenAI and Portkey SDKs both expect their `base_url` to already carry the API version segment
-# (`AsyncOpenAI`'s default is `https://api.openai.com/v1`, `AsyncPortkey`'s is
-# `https://api.portkey.ai/v1`), and both then append their own route beneath it. The Anthropic SDK
-# is the opposite: its default is `https://api.anthropic.com` and it appends `/v1/messages` itself.
-#
-# So the backend declares the **origin**, with no version segment, and each client appends what it
-# needs. Verified against the installed SDKs rather than assumed — spike 5 lost a day to a
-# `/v1`-suffixed endpoint under the Anthropic SDK producing `POST /v1/v1/messages`, which the proxy
-# forwarded and answered 200-shaped.
-PIPELEX_HOSTED_API_VERSION_SEGMENT = "/v1"
-
-# pig's own routes, beneath the version segment. They serve extraction and web search as themselves
-# rather than dressed as chat completions; their wire contract is frozen gateway-side in
-# `src/pig/pipelex/schemas.ts`.
-PIPELEX_HOSTED_EXTRACT_ROUTE = "/pipelex/extract"
-PIPELEX_HOSTED_SEARCH_ROUTE = "/pipelex/search"
-
-
-class PipelexHostedSdk(StrEnum):
- """The sdk values the hosted model catalog section may name.
-
- The values are the spellings the hosted plane's catalog uses, so they keep them although the
- member names do not. `manifold_anthropic` is the open Anthropic worker with this package's extras factory, which adds
- the metadata header to every Claude call.
- """
-
- ANTHROPIC = "manifold_anthropic"
- COMPLETIONS = "manifold_completions"
- RESPONSES = "manifold_responses"
- IMG_GEN = "manifold_img_gen"
- EXTRACT = "manifold_extract"
- SEARCH = "manifold_search"
-
-
-class PipelexHostedOpenAISdkVariant(StrEnum):
- """The two OpenAI-substrate sdks, and which of the two shapes each factory serves.
-
- A factory checks its own variant so that a catalog entry naming `manifold_responses` cannot be
- served by the completions factory (or the reverse) through a mis-registration — the failure
- would otherwise be a wrong request shape at the provider rather than a refusal at build time.
- """
-
- PIPELEX_HOSTED_COMPLETIONS = "manifold_completions"
- PIPELEX_HOSTED_RESPONSES = "manifold_responses"
-
- @classmethod
- def is_completions(cls, sdk: str) -> bool:
- try:
- variant = cls(sdk)
- except ValueError:
- return False
- match variant:
- case cls.PIPELEX_HOSTED_COMPLETIONS:
- return True
- case cls.PIPELEX_HOSTED_RESPONSES:
- return False
-
- @classmethod
- def is_responses(cls, sdk: str) -> bool:
- try:
- variant = cls(sdk)
- except ValueError:
- return False
- match variant:
- case cls.PIPELEX_HOSTED_COMPLETIONS:
- return False
- case cls.PIPELEX_HOSTED_RESPONSES:
- return True
diff --git a/pipelex/providers/pipelex_hosted/pipelex_hosted_error_codes.py b/pipelex/providers/pipelex_hosted/pipelex_hosted_error_codes.py
deleted file mode 100644
index f4da9e272..000000000
--- a/pipelex/providers/pipelex_hosted/pipelex_hosted_error_codes.py
+++ /dev/null
@@ -1,521 +0,0 @@
-"""The Pipelex service's own error codes, contributed to the runtime's service error vocabulary.
-
-The service refuses some requests itself, before any provider sees them, under codes of its own:
-the ``pig-0N`` family on the LLM routes and the frozen ``pipelex_*`` contract codes on the native
-``/v1/pipelex/*`` routes. They group into three families by what the caller has to do — a
-request-shape limit, a reference that cannot be resolved, a request that cannot be routed — and each
-code becomes one ``ServiceErrorCode`` entry: its category, its action and its advice.
-``PipelexHostedPlugin.register`` contributes ``PIPELEX_HOSTED_SERVICE_ERROR_CODES``, which the classifier then
-consults ahead of the status ladder.
-
-None of these is retryable: the service refused before a provider saw the request, and the identical
-request earns the identical refusal.
-"""
-
-from enum import StrEnum
-
-from pipelex.cogt.exceptions import InferenceErrorCategory
-from pipelex.cogt.inference.error_classification import UserActionKind
-from pipelex.cogt.inference.service_error_vocabulary import ServiceErrorCode
-
-
-class GatewayRequestLimit(StrEnum):
- """A request-shape refusal raised by the Pipelex inference gateway itself.
-
- The gateway bounds what a request may weigh and how deeply it may nest, and
- refuses anything over those bounds *before* the request reaches a provider —
- the body cap and the length rule run ahead of authentication, on the headers
- alone. Those refusals are not inference failures and must not read as one: a
- caller who sent something too large has a limit to respect, not a prompt to
- revise, and nothing about a retry can help.
-
- Each member corresponds to one of the gateway's own error codes, which is the
- contract between the two repositories — the wording of a refusal is free to
- change, the code is not.
- """
-
- #: ``pig-07`` at HTTP 413 — the declared body size is over the gateway's cap
- #: for its media type (JSON or multipart).
- BODY_TOO_LARGE = "body_too_large"
- #: ``pig-08`` at HTTP 411 — the body's size cannot be read at all: a chunked
- #: body, or a ``Content-Length`` that is not a byte count. No HTTP client the
- #: runtime uses produces this; it exists so that an unusual one fails closed
- #: and legibly rather than being buffered to find out how big it is.
- BODY_LENGTH_REQUIRED = "body_length_required"
- #: HTTP 413 — a file the request only *refers* to is over its cap: a
- #: ``pipelex-storage://`` object the gateway resolved, or a document it
- #: fetched by URL. The same "too large" family as ``BODY_TOO_LARGE``, one
- #: indirection further out. It arrives under three codes because the gateway
- #: renders the same failure twice — ``pig-10`` on the LLM routes, where its
- #: own ``pig-0N`` family is the only vocabulary available, and
- #: ``pipelex_storage_object_too_large`` / ``pipelex_document_too_large`` on
- #: the native ``/v1/pipelex/*`` routes, whose wire contract is its own.
- OBJECT_TOO_LARGE = "object_too_large"
- #: ``pig-11`` at HTTP 400 — the parsed body nests deeper than the gateway's
- #: depth limit. Not a byte question: nesting costs two bytes a level, so a
- #: body well under any size cap can still overflow a walker.
- BODY_TOO_DEEP = "body_too_deep"
-
-
-# The gateway's error codes, mapped to what the runtime does about them.
-#
-# **Matched on the code alone, with no check on ``provider``**, and that is the
-# design rather than an omission. A request reaches the gateway through whichever
-# SDK its dialect calls for — the Portkey substrate (reported as ``GATEWAY``),
-# plain ``httpx`` on the native extract/search routes (``GATEWAY`` as well), and
-# the Anthropic worker that Claude travels on (reported as ``ANTHROPIC``) —
-# so the reporting provider does not identify the gateway. ``pig-`` and
-# ``pipelex_`` are both the gateway's own code namespaces and no vendor emits into
-# either, so the code alone is both necessary and sufficient.
-#
-# **One failure can appear under two codes**, and leaving out the second one is
-# how a caller reads "the provider rejected the request" for a file they can
-# simply make smaller. The gateway renders a refusal in the vocabulary of the
-# route it arrived on: its own ``pig-0N`` family on the LLM routes, where the
-# client is speaking a provider's protocol, and its frozen ``pipelex_*`` contract
-# codes on the native ``/v1/pipelex/*`` extract and search routes. A new limit has
-# to be looked for in both.
-_GATEWAY_REQUEST_LIMIT_BY_CODE: dict[str, GatewayRequestLimit] = {
- "pig-07": GatewayRequestLimit.BODY_TOO_LARGE,
- "pig-08": GatewayRequestLimit.BODY_LENGTH_REQUIRED,
- "pig-10": GatewayRequestLimit.OBJECT_TOO_LARGE,
- "pig-11": GatewayRequestLimit.BODY_TOO_DEEP,
- # The native routes' rendering of the same "over its cap" refusal: a storage
- # object the gateway resolved, and a document it fetched by URL.
- "pipelex_storage_object_too_large": GatewayRequestLimit.OBJECT_TOO_LARGE,
- "pipelex_document_too_large": GatewayRequestLimit.OBJECT_TOO_LARGE,
-}
-
-
-class GatewayUnresolvedReference(StrEnum):
- """A "cannot resolve this reference" refusal raised by the Pipelex inference gateway itself.
-
- A request may name a file rather than carry it — a ``pipelex-storage://`` key
- the gateway resolves for the caller, or a document URL it fetches on their
- behalf. When it cannot turn that reference into bytes it refuses the request
- itself, before a provider sees it. Like the request-shape limits these are not
- inference failures and must not read as one: a caller who mistyped a storage
- key, pointed at an object this deployment cannot read, or aimed a URL at a host
- the gateway will not fetch from has a *reference* to fix, not a prompt to
- revise, and nothing about a retry can help.
-
- The members group by remedy rather than by wire code: two codes share a member
- only when the caller's next move is the same. Every member defers the specifics
- — the key, the host, the status, the media type — to the gateway's own refusal
- message, which already names them.
-
- Each member corresponds to one or more of the gateway's own error codes, which
- is the contract between the two repositories — the wording of a refusal is free
- to change, the code is not.
- """
-
- #: ``pig-09`` at HTTP 400 — the LLM routes' single fail-closed slot for "this
- #: reference cannot be resolved". Every storage failure but "over its cap"
- #: arrives under it (no bucket configured, not a storage reference, no such
- #: object, an object that cannot be read, a type no provider takes, no way to
- #: hand a file to the provider this model resolves to) because there the client
- #: speaks a provider's protocol and the gateway's own ``pig-0N`` family is the
- #: only vocabulary available. The message carries the difference; the code does
- #: not, so the advice defers to it.
- REFERENCE_UNRESOLVED = "reference_unresolved"
- #: ``pipelex_storage_uri_invalid`` at HTTP 400 — the reference does not obey the
- #: key grammar (the path-traversal guard refuses under the same code).
- STORAGE_REFERENCE_INVALID = "storage_reference_invalid"
- #: ``pipelex_storage_unreadable`` at HTTP 400 — the object is not there, or the
- #: gateway's role may not read it. Deliberately one member: the gateway does not
- #: tell a caller which of the two it was, and neither may we.
- STORAGE_OBJECT_UNREADABLE = "storage_object_unreadable"
- #: ``pipelex_storage_uri_unsupported`` at HTTP 400 — no bucket is configured, so
- #: this deployment does not serve ``pipelex-storage://`` references at all.
- #: Nothing about the inputs causes it: it is an operator's problem.
- STORAGE_NOT_SERVED = "storage_not_served"
- #: HTTP 400 — the document URL was refused before or during the fetch, on its
- #: form rather than on what it served: ``pipelex_unsupported_uri_scheme`` (a
- #: scheme the route does not read) and ``pipelex_document_scheme_refused`` (the
- #: fetch's own check, reachable only for an unparseable URL now that the route
- #: admits ``https:`` alone), ``pipelex_document_address_refused`` (the resolved
- #: address is not publicly routable) and ``pipelex_document_redirect_refused``
- #: (the origin answered a redirect, which the gateway will not follow).
- DOCUMENT_URL_REFUSED = "document_url_refused"
- #: ``pipelex_document_host_refused`` at HTTP 400 — the gateway's SSRF guard
- #: refuses to fetch documents from this host. Its own member rather than a share
- #: of ``DOCUMENT_URL_REFUSED`` because the advice has to state a deliberate
- #: security policy: the caller can act, but nothing about their document is at
- #: fault and no amount of reshaping it will help.
- DOCUMENT_HOST_REFUSED = "document_host_refused"
- #: ``pipelex_document_unreachable`` at HTTP 400 — the origin answered a
- #: non-success status. Not retried: the gateway renders it 400, a retry would
- #: re-run a whole inference call to re-fetch the document, and the common case
- #: is a URL that is simply wrong.
- DOCUMENT_UNREACHABLE = "document_unreachable"
- #: HTTP 400 — the document was fetched, and what came back cannot be used:
- #: ``pipelex_document_empty`` (served empty), ``pipelex_document_unsupported_type``
- #: (a media type the pipeline does not accept) and ``pipelex_document_bad_data_url``
- #: (a ``data:`` URL that cannot be decoded).
- DOCUMENT_CONTENT_UNUSABLE = "document_content_unusable"
-
-
-# The gateway's unresolvable-reference codes, mapped to what the runtime does
-# about them.
-#
-# **Matched on the code alone, with no check on ``provider``**, for exactly the
-# reason ``_GATEWAY_REQUEST_LIMIT_BY_CODE`` is: the reporting provider does not
-# identify the gateway (more than one SDK hop reaches it, under more than one provider name), while ``pig-``
-# and ``pipelex_`` are the gateway's own code namespaces and no vendor emits into
-# either.
-#
-# **Disjoint from the request-limit map by construction.** The two families answer
-# different questions — one bounds the request's shape, the other says a reference
-# could not be resolved — and a code belongs to exactly one of them. ``pig-09`` and
-# ``pig-10`` are the clearest illustration: the same middleware raises both, one
-# when the object is over its cap and one when it cannot be resolved at all.
-_GATEWAY_UNRESOLVED_REFERENCE_BY_CODE: dict[str, GatewayUnresolvedReference] = {
- "pig-09": GatewayUnresolvedReference.REFERENCE_UNRESOLVED,
- # The native ``/v1/pipelex/*`` routes' own contract codes, where the gateway
- # names each cause instead of folding them into one fail-closed slot.
- "pipelex_storage_uri_invalid": GatewayUnresolvedReference.STORAGE_REFERENCE_INVALID,
- "pipelex_storage_unreadable": GatewayUnresolvedReference.STORAGE_OBJECT_UNREADABLE,
- "pipelex_storage_uri_unsupported": GatewayUnresolvedReference.STORAGE_NOT_SERVED,
- "pipelex_document_scheme_refused": GatewayUnresolvedReference.DOCUMENT_URL_REFUSED,
- # The scheme refusal a caller actually reaches. ``classifyExtractInput`` runs
- # before any fetch and admits only ``https:``, ``data:`` and
- # ``pipelex-storage://``, so an ``http://`` URL is refused here rather than by
- # the fetch above — which by then can only see URLs that already start with
- # ``https://``.
- "pipelex_unsupported_uri_scheme": GatewayUnresolvedReference.DOCUMENT_URL_REFUSED,
- "pipelex_document_address_refused": GatewayUnresolvedReference.DOCUMENT_URL_REFUSED,
- "pipelex_document_redirect_refused": GatewayUnresolvedReference.DOCUMENT_URL_REFUSED,
- "pipelex_document_host_refused": GatewayUnresolvedReference.DOCUMENT_HOST_REFUSED,
- "pipelex_document_unreachable": GatewayUnresolvedReference.DOCUMENT_UNREACHABLE,
- "pipelex_document_empty": GatewayUnresolvedReference.DOCUMENT_CONTENT_UNUSABLE,
- "pipelex_document_unsupported_type": GatewayUnresolvedReference.DOCUMENT_CONTENT_UNUSABLE,
- "pipelex_document_bad_data_url": GatewayUnresolvedReference.DOCUMENT_CONTENT_UNUSABLE,
-}
-
-
-class GatewayRoutingRefusal(StrEnum):
- """A "cannot route this request" refusal raised by the Pipelex inference gateway itself.
-
- Before a request can reach a provider the gateway has to decide *which*
- provider — it reads the model out of the request, looks it up in its own
- routing table, and hands the call to the integration that serves it. When
- that resolution fails it refuses the request itself, with codes of its own.
- These are not inference failures and must not read as one: a caller who named
- a model this deployment does not serve has a *model* to change or a
- deployment to fix, not a prompt to revise, and nothing about a retry can help.
-
- Every member is its own wire code here, unlike the two families beside it —
- not by accident but because each names a different thing that has to change.
- The one they nearly share is the flag: ``UNKNOWN_MODEL`` is the only member
- that means "this deployment does not know that model", so it is the only one
- the Classify step renders as a ``*ModelNotFoundError``.
-
- Each member corresponds to one of the gateway's own ``pig-`` codes, at HTTP
- 400, which is the contract between the two repositories — the wording of a
- refusal is free to change, the code is not. The substrate's
- ``model_not_allowed_error`` is a routing refusal too, but the runtime
- classifies it itself, because Portkey's cloud answers it for a caller's own
- workspace as well (see ``MODEL_NOT_ALLOWED_ERROR_CODE`` in core).
- """
-
- #: ``pig-01`` at HTTP 400 — the request body names one that no integration
- #: this deployment carries lists. Reached from the runtime by a model deck
- #: whose handle the gateway does not serve: a stale deck, a typo in a
- #: ``.mthds`` file's model, or a model the deployment deliberately does not
- #: carry.
- #:
- #: **The code covers two other facts and does not distinguish them**: a body
- #: that names no model, and a body the gateway could not parse at all — its
- #: model reader returns "no model" from a bare ``catch`` around the JSON and
- #: multipart reads alike, so a truncated or non-conforming payload lands here
- #: too. Only the gateway's message says which, which is why the rendered
- #: advice defers to it rather than asserting a deck disagreement (see
- #: ``_routing_refusal_entry``). Splitting the code is a
- #: gateway-side change, filed for the hosted plane as L-260902-701614.
- UNKNOWN_MODEL = "unknown_model"
- #: ``pig-02`` at HTTP 400 — the model resolves, but to an integration the
- #: deployment has switched off because a credential variable is unset. Nothing
- #: about the request causes it and no request avoids it: the gateway's own
- #: message names the integration and the variables whoever operates it must
- #: set.
- DISABLED_INTEGRATION = "disabled_integration"
- #: ``pig-05`` at HTTP 400 — a native-protocol path names a model that another
- #: provider serves. Today that is only Google's generative shape —
- #: ``/v1/<v1|v1alpha|v1beta>/models/<model>:generateContent`` or its
- #: ``streamGenerateContent`` twin, under the gateway's own ``/v1`` prefix —
- #: the one ``nativeProtocolPaths.ts`` admits. Reaching it means the model deck and the
- #: gateway disagree about which backend serves a model: the model exists and
- #: is served, just not over the protocol the runtime spoke to ask for it.
- WRONG_PROTOCOL = "wrong_protocol"
- #: ``pig-06`` at HTTP 400 — a model reached one of the native
- #: ``/v1/pipelex/*`` routes (extract, search) whose integration's provider does
- #: not serve that capability. Again a deck-versus-gateway disagreement, or a
- #: model named on a pipe it cannot serve: the message names the integration,
- #: the provider and the capability.
- UNSERVED_CAPABILITY = "unserved_capability"
-
-
-# The gateway's routing-refusal codes, mapped to what the runtime does about them.
-#
-# **Matched on the code alone, with no check on ``provider``**, for exactly the
-# reason the two maps above are: the reporting provider does not identify the
-# gateway. These arrive under more than one ``ProviderName`` — the Portkey
-# substrate and the OpenAI substrate that carries every chat call both report
-# ``GATEWAY``, plain ``httpx`` on the native routes reports ``GATEWAY`` too, and
-# Claude travels on the Anthropic worker — while ``pig-`` is the gateway's
-# own code namespace and no vendor emits into it.
-#
-# **Two of the gateway's routing codes are deliberately absent**, and the omission
-# is the scope decision rather than an oversight:
-#
-# - ``pig-03`` ("the client tried to route") refuses a ``x-portkey-*`` steering
-# header, the ``?model=`` query form, a ``@<slug>/<model>`` virtual-key model, or
-# a path and body naming different models. No client that talks to a
-# Pipelex-operated gateway today produces any of those, so reaching it means a
-# client bug rather than a caller's or an operator's mistake, and the status
-# ladder's reading is as good as any.
-#
-# Two limits on that sentence, because it is the whole reason the code stays
-# out. ``tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_clients.py`` pins
-# the hosted clients against the four steering headers by name, while the
-# gateway refuses on an *allow*-list — so a ``portkey_ai`` release that starts
-# sending some other ``x-portkey-*`` header turns every request into a
-# ``pig-03`` with that test still green. The hosted image path still travels
-# on ``portkey_ai``, which is the one client that could start doing so.
-# - ``pig-04`` ("this gateway does not serve ``<method> <path>``") is the proxy
-# policy refusing a path only the catch-all could answer, and it is a 404, so the
-# ladder already reads it as model-not-found — wrong in kind, but unreachable
-# while the runtime calls only the routes the gateway mounts, and a served-path
-# drift is a deployment bug to surface loudly rather than a verdict to soften.
-#
-# ``pig-09`` is not a routing refusal either: it belongs to the
-# unresolvable-reference family, which ``_GATEWAY_UNRESOLVED_REFERENCE_BY_CODE``
-# reads.
-_GATEWAY_ROUTING_REFUSAL_BY_CODE: dict[str, GatewayRoutingRefusal] = {
- "pig-01": GatewayRoutingRefusal.UNKNOWN_MODEL,
- "pig-02": GatewayRoutingRefusal.DISABLED_INTEGRATION,
- "pig-05": GatewayRoutingRefusal.WRONG_PROTOCOL,
- "pig-06": GatewayRoutingRefusal.UNSERVED_CAPABILITY,
-}
-
-
-def _request_limit_entry(*, code: str, limit: GatewayRequestLimit) -> ServiceErrorCode:
- """The entry for a request-shape refusal.
-
- The advice deliberately says nothing about a number. The caps are the deployment's, they differ
- between deployments, and the gateway already names its own figures in the message this advice
- sits beside — repeating a compiled-in guess here is how advice starts contradicting the refusal it
- explains.
- """
- match limit:
- case GatewayRequestLimit.BODY_TOO_LARGE:
- # The caller sent more than the deployment serves — a smaller input is the whole remedy,
- # and it is theirs to make. The same holds for the two members below.
- return ServiceErrorCode(
- code=code,
- category=InferenceErrorCategory.CONTENT,
- user_action_kind=UserActionKind.CHANGE_INPUT,
- detail="The request was too large for the inference gateway — send less in one call, or use smaller inputs.",
- )
- case GatewayRequestLimit.OBJECT_TOO_LARGE:
- return ServiceErrorCode(
- code=code,
- category=InferenceErrorCategory.CONTENT,
- user_action_kind=UserActionKind.CHANGE_INPUT,
- detail="A file the request refers to is over the inference gateway's per-file size limit — use a smaller file.",
- )
- case GatewayRequestLimit.BODY_TOO_DEEP:
- return ServiceErrorCode(
- code=code,
- category=InferenceErrorCategory.CONTENT,
- user_action_kind=UserActionKind.CHANGE_INPUT,
- detail="The request nests too deeply for the inference gateway — flatten the inputs or the output structure.",
- )
- case GatewayRequestLimit.BODY_LENGTH_REQUIRED:
- # Nothing about the *content* is wrong here: an HTTP client framed the request in a way the
- # gateway will not bound. No client the runtime ships produces it, so reaching this means
- # something in the transport stack changed — which is an operator's problem, not the caller's.
- return ServiceErrorCode(
- code=code,
- category=InferenceErrorCategory.CONFIGURATION,
- user_action_kind=UserActionKind.CONTACT_SUPPORT,
- detail=(
- "The inference gateway could not read the request's declared size and refused it: it requires a "
- "Content-Length and does not accept a chunked body. Nothing about the inputs causes this — contact support."
- ),
- )
-
-
-def _unresolved_reference_entry(*, code: str, reference: GatewayUnresolvedReference) -> ServiceErrorCode:
- """The entry for a reference the gateway could not resolve.
-
- The advice names no key, host, status or media type, for the same reason the request-limit advice
- names no number: the gateway's own refusal message sits beside it and already states the
- specifics. What the advice adds is what the caller should *do*, which the message does not say.
-
- Not retryable even for ``DOCUMENT_UNREACHABLE``, where the origin *could* have been transiently
- down: the gateway renders it a 400, a retry would re-run a whole inference call just to re-fetch a
- document, and the common case is a URL that is simply wrong.
- """
- match reference:
- case GatewayUnresolvedReference.STORAGE_NOT_SERVED:
- # This deployment serves no ``pipelex-storage://`` references at all, because no bucket is
- # configured for it. Nothing about the inputs causes it and no input can avoid it — it is an
- # operator's problem, like ``BODY_LENGTH_REQUIRED``.
- return ServiceErrorCode(
- code=code,
- category=InferenceErrorCategory.CONFIGURATION,
- user_action_kind=UserActionKind.CONTACT_SUPPORT,
- detail=_unresolved_reference_detail(reference=reference),
- )
- case (
- GatewayUnresolvedReference.REFERENCE_UNRESOLVED
- | GatewayUnresolvedReference.STORAGE_REFERENCE_INVALID
- | GatewayUnresolvedReference.STORAGE_OBJECT_UNREADABLE
- | GatewayUnresolvedReference.DOCUMENT_URL_REFUSED
- | GatewayUnresolvedReference.DOCUMENT_HOST_REFUSED
- | GatewayUnresolvedReference.DOCUMENT_UNREACHABLE
- | GatewayUnresolvedReference.DOCUMENT_CONTENT_UNUSABLE
- ):
- # The reference is the caller's to fix — a different key, a different URL, or the file
- # uploaded where the gateway can reach it. ``DOCUMENT_HOST_REFUSED`` belongs here too: the
- # refusal is a security policy rather than a fault, but the caller is still the one who can
- # act on it, and its advice is where that distinction is stated.
- return ServiceErrorCode(
- code=code,
- category=InferenceErrorCategory.CONTENT,
- user_action_kind=UserActionKind.CHANGE_INPUT,
- detail=_unresolved_reference_detail(reference=reference),
- )
-
-
-def _unresolved_reference_detail(*, reference: GatewayUnresolvedReference) -> str:
- match reference:
- case GatewayUnresolvedReference.REFERENCE_UNRESOLVED:
- return (
- "A file reference in the request could not be resolved by the inference gateway — "
- "the error message names the cause; fix the reference it names."
- )
- case GatewayUnresolvedReference.STORAGE_REFERENCE_INVALID:
- return "The pipelex-storage:// reference in the request is malformed — check it against the key the upload returned."
- case GatewayUnresolvedReference.STORAGE_OBJECT_UNREADABLE:
- return (
- "The referenced storage object does not exist or cannot be read — check that the reference points at a file "
- "uploaded to this deployment."
- )
- case GatewayUnresolvedReference.STORAGE_NOT_SERVED:
- return (
- "This inference gateway does not serve pipelex-storage:// references at all — no storage is configured for it. "
- "Nothing about the inputs causes this — contact support."
- )
- case GatewayUnresolvedReference.DOCUMENT_URL_REFUSED:
- return (
- "The inference gateway refused the document URL — send a plain public https:// URL, a data: URL, or a "
- "pipelex-storage:// reference, and give the final address rather than one that redirects."
- )
- case GatewayUnresolvedReference.DOCUMENT_HOST_REFUSED:
- return (
- "The inference gateway does not fetch documents from that host, as a matter of security policy: private and "
- "internal addresses are never fetched. Host the document at a publicly reachable address, or upload it to "
- "Pipelex storage and reference it from there."
- )
- case GatewayUnresolvedReference.DOCUMENT_UNREACHABLE:
- return (
- "The document could not be fetched from its URL — check that it is live and publicly reachable, and try again "
- "if its host was temporarily down."
- )
- case GatewayUnresolvedReference.DOCUMENT_CONTENT_UNUSABLE:
- return (
- "The document was fetched but cannot be used — the error message says whether it was served empty, in a media "
- "type the pipeline does not accept, or as a data: URL that could not be decoded."
- )
-
-
-def _routing_refusal_entry(*, code: str, refusal: GatewayRoutingRefusal) -> ServiceErrorCode:
- """The entry for a request the gateway refused to route.
-
- Every member is ``CONFIGURATION``: nothing in the prompt, the parameters or the inputs causes any
- of these, and no edit to them avoids one. Without the family they take the status ladder's 400
- arm and read as a provider rejecting the caller's content.
-
- The advice names no integration, protocol or capability: the gateway's own message sits beside it
- and already states every specific. Every member whose remedy could be a deck edit says "the model
- deck" out loud: the runtime picks the model, the protocol and the route from its own deck, so those
- refusals usually mean the deck and the gateway disagree about a model rather than that the caller
- chose badly.
- """
- match refusal:
- case GatewayRoutingRefusal.UNKNOWN_MODEL:
- # The deployment does not know that model at all — which is exactly what
- # ``is_model_not_found`` means, so this is the one member that sets it. It selects the
- # family's ``*ModelNotFoundError`` class, which ``pipe_operator.py`` re-raises as a
- # ``PipeOperatorModelAvailabilityError`` carrying the model handle.
- #
- # The advice's second sentence is hedged deliberately. ``pig-01`` is the gateway's answer
- # to three different facts — it serves no such model, the body named none, and the body
- # could not be parsed at all — and the wire code does not tell them apart. Only the
- # gateway's own message does, so the advice sends the reader there before it sends them to
- # the deck. Splitting the code is the real fix, filed for the hosted plane as
- # L-260902-701614.
- return ServiceErrorCode(
- code=code,
- category=InferenceErrorCategory.CONFIGURATION,
- user_action_kind=UserActionKind.CHANGE_MODEL,
- is_model_not_found=True,
- detail=(
- "The inference gateway does not serve that model — pick a model this deployment serves. Its own message is "
- "the authority on which: the same code also answers a request it could not read a model out of at all. "
- "If it names a model your model deck lists, the deck and the gateway disagree about what is available."
- ),
- )
- case GatewayRoutingRefusal.DISABLED_INTEGRATION:
- # The integration is switched off because whoever operates the gateway never set its
- # credential. The deployment is what has to change, not the request — so this is the
- # family's ``CONTACT_SUPPORT`` arm. ``CHECK_CREDENTIALS`` would send a hosted caller to
- # rotate their own perfectly valid key; ``CHANGE_MODEL`` would send them shopping for a
- # model over an operator's unset variable. The handle resolved, so this is not a model the
- # deployment does not know.
- return ServiceErrorCode(
- code=code,
- category=InferenceErrorCategory.CONFIGURATION,
- user_action_kind=UserActionKind.CONTACT_SUPPORT,
- detail=(
- "The model is served by an integration this inference gateway has not enabled — its credentials are unset. "
- "Nothing about the request causes this, and none of your own credentials are at fault: the error message "
- "names the integration and the variables whoever operates the gateway has to set. Contact support."
- ),
- )
- case GatewayRoutingRefusal.WRONG_PROTOCOL:
- # The model exists and is served, just not over the protocol that was spoken — so it is not
- # a model-not-found, and ``CHANGE_MODEL`` is still what an end caller can do about it.
- return ServiceErrorCode(
- code=code,
- category=InferenceErrorCategory.CONFIGURATION,
- user_action_kind=UserActionKind.CHANGE_MODEL,
- detail=(
- "The inference gateway serves that model, but not over the protocol the request used for it — your model "
- "deck names a different backend for it than the gateway routes it to. Correct the deck, or pick another model."
- ),
- )
- case GatewayRoutingRefusal.UNSERVED_CAPABILITY:
- # Same reading: the model exists and is served, it just cannot do what was asked.
- return ServiceErrorCode(
- code=code,
- category=InferenceErrorCategory.CONFIGURATION,
- user_action_kind=UserActionKind.CHANGE_MODEL,
- detail=(
- "The model's integration does not serve that capability on the inference gateway — the error message names "
- "the provider and what was asked of it. Pick a model whose provider serves it, or correct the model deck."
- ),
- )
-
-
-# Every code the service emits on its own that the runtime reads, one entry each. The three families
-# are disjoint by construction — a code names a bound the request exceeded, a reference that could not
-# be resolved, or a request that could not be routed, never two of them — and the registrar refuses a
-# code claimed twice, so a code added to two maps fails the boot rather than picking one silently.
-PIPELEX_HOSTED_SERVICE_ERROR_CODES: tuple[ServiceErrorCode, ...] = (
- *(_request_limit_entry(code=code, limit=limit) for code, limit in _GATEWAY_REQUEST_LIMIT_BY_CODE.items()),
- *(_unresolved_reference_entry(code=code, reference=reference) for code, reference in _GATEWAY_UNRESOLVED_REFERENCE_BY_CODE.items()),
- *(_routing_refusal_entry(code=code, refusal=refusal) for code, refusal in _GATEWAY_ROUTING_REFUSAL_BY_CODE.items()),
-)
diff --git a/pipelex/providers/pipelex_hosted/pipelex_hosted_error_metadata.py b/pipelex/providers/pipelex_hosted/pipelex_hosted_error_metadata.py
deleted file mode 100644
index 90a35b7d2..000000000
--- a/pipelex/providers/pipelex_hosted/pipelex_hosted_error_metadata.py
+++ /dev/null
@@ -1,121 +0,0 @@
-"""How a failure on the Pipelex service's native routes is distilled into error metadata.
-
-The native routes (``/v1/pipelex/extract``, ``/v1/pipelex/search``) are not OpenAI-shaped, so they
-are called with plain ``httpx`` rather than through a vendor SDK, and their failures are distilled
-here, beside the client that raises them.
-"""
-
-from __future__ import annotations
-
-import json
-from typing import Any, cast
-
-from pipelex.cogt.inference.error_classification import ProviderErrorMetadata, error_code_from_body_code_first, parse_retry_after_seconds
-from pipelex.cogt.inference.provider_name import ProviderName
-
-# The headers the service stamps its trace id on, in the order the distiller below reads them.
-#
-# Every answer a provider gave carries that id twice, with the same value under each spelling: the
-# pipelex one the dialect owns, and the inherited vendor one the gateway still emits because
-# `portkey_ai` reads it on the image path — a refusal the gateway raised before trying a provider
-# carries neither. Reading the pipelex spelling first is what makes the gateway's eventual dropping
-# of the vendor one a no-op for the native routes, at which point the second name and its lookup go
-# away. It is not a no-op for the image path: `extract_gateway_metadata` carries the vendor spelling
-# as a literal of its own, and the image worker distils its failures through it, so it can only move
-# once the image path is off `portkey_ai`.
-PIPELEX_HOSTED_TRACE_ID_HEADER = "x-pipelex-trace-id"
-PIPELEX_HOSTED_VENDOR_TRACE_ID_HEADER = "x-portkey-trace-id"
-
-
-def extract_pipelex_hosted_metadata(exc: BaseException) -> ProviderErrorMetadata:
- """Distill a raw-httpx failure against the Pipelex service into metadata.
-
- Two exception shapes reach here:
-
- - ``httpx.HTTPStatusError``, which carries the whole ``response`` — status, headers, and a body
- this reads as JSON on a best-effort basis;
- - ``httpx.RequestError`` (connect, timeout, read), which carries only a request; every
- status-related field comes back as ``None``, and the class name is what the classify step
- matches on to call it a network failure.
-
- **The error code is read ``code`` first**, via ``error_code_from_body_code_first``, and the
- ordinary vendor-facing precedence would lose it here. A refusal these routes raise themselves is
- rendered as ``{"error": {"message": …, "type": "invalid_request_error", "code":
- "pipelex_document_too_large"}}`` — the generic bucket in ``type``, the frozen contract code the
- classifier actually needs in ``code`` — so reading ``type`` first replaces every ``pipelex_*``
- code with ``invalid_request_error``. The gateway's fail-closed ``pig-0N`` shape carries no
- ``type`` at all, so it reads the same either way.
-
- **The request id is read in the hosted dialect's own spelling.** The provider's ``x-request-id``
- comes first when a provider named its call, and the gateway's trace id is the fallback for the
- answers that carried none — under ``PIPELEX_HOSTED_TRACE_ID_HEADER`` before the inherited vendor
- spelling, which holds the same value and is only still read because the gateway still emits it.
-
- **The message is the service's own when its body carries one.** ``str(exc)`` on an
- ``httpx.HTTPStatusError`` is httpx's generic sentence (``Client error '401 Unauthorized' for url
- …``), which says nothing about why the service refused, so the body's ``error.message`` is read
- first, then its top-level ``message``; ``str(exc)`` stays the fallback for a body without
- either, for a body that is not JSON and for an ``httpx.RequestError``, which has no body at all.
-
- **It reports ``ProviderName.GATEWAY``**, and that is a decision rather than an oversight: the
- service is a gateway, it phrases quota exhaustion and rate limiting the way the gateway
- substrate does, and every ``match`` on ``ProviderName`` would need a second arm with the same
- body to say otherwise. Which service answered is already carried by the error's model handle
- and backend name.
- """
- response = getattr(exc, "response", None)
- status_code = getattr(response, "status_code", None)
- if not isinstance(status_code, int):
- status_code = None
- headers = getattr(response, "headers", None)
- request_id: str | None = None
- retry_after_seconds: float | None = None
- if headers is not None:
- request_id_value = (
- headers.get("x-request-id") or headers.get(PIPELEX_HOSTED_TRACE_ID_HEADER) or headers.get(PIPELEX_HOSTED_VENDOR_TRACE_ID_HEADER)
- )
- if isinstance(request_id_value, str):
- request_id = request_id_value
- retry_after_seconds = parse_retry_after_seconds(headers.get("retry-after"))
- body: Any | None = None
- if response is not None:
- try:
- body = response.json()
- except (json.JSONDecodeError, UnicodeDecodeError, ValueError):
- # A refusal the service did not render as JSON is still a refusal; the status code and
- # the message carry it, and insisting on a body here would trade a classified error for
- # a decode error raised while classifying one.
- body = None
- provider_error_code = error_code_from_body_code_first(body)
- return ProviderErrorMetadata(
- provider=ProviderName.GATEWAY,
- sdk_exception_type=type(exc).__name__,
- message=_message_from_body(body=body) or str(exc),
- status_code=status_code,
- request_id=request_id,
- retry_after_seconds=retry_after_seconds,
- provider_error_code=provider_error_code,
- body=body,
- )
-
-
-def _message_from_body(*, body: Any) -> str | None:
- """The service's own explanation of a failure, read from its JSON body, if it gave one.
-
- The nested ``error.message`` comes first, since it is the shape both the gateway and the native
- routes' own refusals render; the top-level ``message`` the gateway also stamps is the fallback.
- Only a non-empty string counts, so a ``null`` or a blank message falls through to the next.
- """
- if not isinstance(body, dict):
- return None
- body_dict = cast("dict[str, Any]", body)
- sections: list[dict[str, Any]] = []
- error_section = body_dict.get("error")
- if isinstance(error_section, dict):
- sections.append(cast("dict[str, Any]", error_section))
- sections.append(body_dict)
- for section in sections:
- candidate = section.get("message")
- if isinstance(candidate, str) and candidate.strip():
- return candidate
- return None
diff --git a/pipelex/providers/pipelex_hosted/pipelex_hosted_exceptions.py b/pipelex/providers/pipelex_hosted/pipelex_hosted_exceptions.py
deleted file mode 100644
index 98c8a3819..000000000
--- a/pipelex/providers/pipelex_hosted/pipelex_hosted_exceptions.py
+++ /dev/null
@@ -1,58 +0,0 @@
-"""The package's errors, each published under the page and title of its nearest generic family.
-
-A client that receives one of these in an error report reads its RFC 7807 `type` and `title`, so each
-class declares both rather than deriving them from its name: the page is the existing public one of
-the family the failure belongs to, and the title names the failure, not the component that raised it.
-Faults in the operator's configuration, a missing endpoint or credential, keep messages as precise as
-the operator needs, since they fail a boot or a worker build and never reach a client.
-"""
-
-from pipelex.cogt.exceptions import CogtError
-from pipelex.urls import URLs
-
-_COGT_ERROR_PAGE = f"{URLs.error_docs_base}/cogt-error/"
-_CREDENTIALS_ERROR_PAGE = f"{URLs.error_docs_base}/inference-backend-credentials-error/"
-_EXTRACT_FAILURE_PAGE = f"{URLs.error_docs_base}/extract-job-failure-error/"
-_SEARCH_FAILURE_PAGE = f"{URLs.error_docs_base}/search-job-failure-error/"
-
-
-class PipelexHostedError(CogtError):
- _declared_type_uri = _COGT_ERROR_PAGE
- _declared_title = "Inference backend error"
-
-
-class PipelexHostedFactoryError(PipelexHostedError):
- _declared_type_uri = _COGT_ERROR_PAGE
- _declared_title = "Inference client setup error"
-
-
-class PipelexHostedCredentialsError(PipelexHostedError):
- _declared_type_uri = _CREDENTIALS_ERROR_PAGE
- _declared_title = "Inference backend credentials missing"
-
-
-class PipelexHostedEndpointError(PipelexHostedError):
- """The backend declares no usable endpoint for the Pipelex service.
-
- Its own error rather than a credentials one, because the remedy is a different setting and
- because there is deliberately no default to fall back on: an empty-resolving endpoint that
- silently became a vendor's public URL would carry our service token to the wrong company.
- """
-
- _declared_type_uri = _CREDENTIALS_ERROR_PAGE
- _declared_title = "Inference backend endpoint missing"
-
-
-class PipelexHostedExtractResponseError(PipelexHostedError):
- _declared_type_uri = _EXTRACT_FAILURE_PAGE
- _declared_title = "Extract response unreadable"
-
-
-class PipelexHostedSearchResponseError(PipelexHostedError):
- _declared_type_uri = _SEARCH_FAILURE_PAGE
- _declared_title = "Search response unreadable"
-
-
-class PipelexHostedSearchEmptyResultError(PipelexHostedError):
- _declared_type_uri = _SEARCH_FAILURE_PAGE
- _declared_title = "Search returned no result"
diff --git a/pipelex/providers/pipelex_hosted/pipelex_hosted_extract_worker.py b/pipelex/providers/pipelex_hosted/pipelex_hosted_extract_worker.py
deleted file mode 100644
index 4d3db4247..000000000
--- a/pipelex/providers/pipelex_hosted/pipelex_hosted_extract_worker.py
+++ /dev/null
@@ -1,154 +0,0 @@
-"""Document extraction over the Pipelex service's own route.
-
-Thin on purpose. The gateway's ``POST /v1/pipelex/extract`` answers in the runtime's *own* model —
-an ``ExtractOutput`` of ``Page``s, keyed by page index — so the whole response side is one
-``model_validate``, whichever provider the gateway picked. That is the largest deletion the native
-route buys over the chat costume, where each provider's wire shape needed its own parser.
-
-Two things this worker does that a thinner one would get wrong.
-
-**It builds the request body field by field.** Several ``ExtractJobParams`` fields are deliberately
-not part of the contract, and the gateway refuses them at *any* value including their own defaults —
-so a ``model_dump()`` of the params would send ``should_caption_images=false`` and be refused. See
-``pipelex_hosted_schemas``.
-
-**It translates the service's usage units into the runtime's.** The route reports honest counts
-(``usage.pages``), and the runtime's cost model is per million tokens. Left untranslated the job
-would report a cost of zero — silently, because ``nb_tokens_by_category`` simply stays empty and
-nothing raises. The megatoken convention is inherited from the chat costume and kept deliberately:
-it is what makes an extraction's cost figure directly comparable between the two dialects, which is
-what the mixed-profile bring-up needs in order to mean anything.
-"""
-
-from __future__ import annotations
-
-from typing import TYPE_CHECKING, Any, cast
-
-from pydantic import ValidationError
-from typing_extensions import override
-
-from pipelex.cogt.exceptions import SdkTypeError
-from pipelex.cogt.extract.exceptions import ExtractInputError
-from pipelex.cogt.extract.extract_output import ExtractOutput
-from pipelex.cogt.extract.extract_worker_abstract import ExtractWorkerAbstract
-from pipelex.cogt.inference.error_render import InferenceErrorFamily
-from pipelex.cogt.usage.token_category import NbTokensByCategoryDict, TokenCategory
-from pipelex.providers.pipelex_hosted.pipelex_hosted_constants import PIPELEX_HOSTED_EXTRACT_ROUTE
-from pipelex.providers.pipelex_hosted.pipelex_hosted_exceptions import PipelexHostedExtractResponseError
-from pipelex.providers.pipelex_hosted.pipelex_hosted_native_client import PipelexHostedNativeClient
-from pipelex.providers.pipelex_hosted.pipelex_hosted_response_errors import describe_response_validation_error
-from pipelex.providers.pipelex_hosted.pipelex_hosted_schemas import PipelexHostedExtractInput, PipelexHostedExtractParams, PipelexHostedExtractRequest
-from pipelex.runtime_hub import get_storage_provider
-from pipelex.tools.uri.uri_base64 import make_base64_url_from_any_uri
-
-if TYPE_CHECKING:
- from pipelex.cogt.extract.extract_job import ExtractJob
- from pipelex.cogt.model_backends.model_spec import InferenceModelSpec
- from pipelex.reporting.reporting_protocol import ReportingProtocol
-
-# The runtime prices per million; the route counts pages. One page is one megatoken, in both
-# categories, which is exactly what the chat costume reports and what the abstract worker's own
-# fallback would produce — so a cost figure means the same thing on either dialect.
-PIPELEX_HOSTED_UNIT_TOKENS = 1_000_000
-
-
-class PipelexHostedExtractWorker(ExtractWorkerAbstract):
- def __init__(
- self,
- sdk_instance: Any,
- extra_config: dict[str, Any],
- inference_model: InferenceModelSpec,
- reporting_delegate: ReportingProtocol | None = None,
- ):
- super().__init__(
- extra_config=extra_config,
- inference_model=inference_model,
- reporting_delegate=reporting_delegate,
- )
-
- if not isinstance(sdk_instance, PipelexHostedNativeClient):
- msg = f"Provided extraction sdk_instance for {self.__class__.__name__} is not a PipelexHostedNativeClient: it's a '{type(sdk_instance)}'"
- raise SdkTypeError(msg)
-
- self.client: PipelexHostedNativeClient = sdk_instance
-
- @override
- async def _extract_pages(
- self,
- extract_job: ExtractJob,
- ) -> ExtractOutput:
- request = await self._make_request(extract_job=extract_job)
- response_body = await self.client.post_json(
- route=PIPELEX_HOSTED_EXTRACT_ROUTE,
- body=request.model_dump(exclude_none=True),
- family=InferenceErrorFamily.EXTRACT,
- inference_model=self.inference_model,
- job_metadata=extract_job.job_metadata,
- )
- self._record_usage(response_body=response_body, extract_job=extract_job)
- try:
- return ExtractOutput.model_validate(response_body)
- except ValidationError as exc:
- msg = f"Could not parse the extraction response for model '{self.inference_model.name}': {describe_response_validation_error(exc=exc)}"
- raise PipelexHostedExtractResponseError(msg) from exc
-
- async def _make_request(self, *, extract_job: ExtractJob) -> PipelexHostedExtractRequest:
- """The body, with the input in the form the picked provider can actually reach.
-
- Which form that is follows from what the *catalog* says the model takes, not from a list of
- model names kept in step by hand: a web-page extractor is handed the page's own URL, and
- everything else is handed the bytes inline. The gateway fetches ``https:`` and reads
- ``data:``, and nothing else — a local path or a ``pipelex-storage://`` URI has to become
- bytes on this side, because the gateway holds no credentials for our storage.
- """
- extract_input = extract_job.extract_input
- job_params = extract_job.job_params
- params = PipelexHostedExtractParams(
- max_nb_images=job_params.max_nb_images,
- render_js=job_params.render_js,
- include_raw_html=job_params.include_raw_html,
- )
-
- if self.is_web_page_supported:
- if not extract_input.document_uri:
- msg = f"Extract model '{self.inference_model.name}' fetches web pages and needs a document_uri"
- raise ExtractInputError(msg)
- return PipelexHostedExtractRequest(
- model=self.inference_model.model_id,
- input=PipelexHostedExtractInput(document_uri=extract_input.document_uri),
- params=params,
- )
-
- storage = get_storage_provider()
- if image_uri := extract_input.image_uri:
- base64_url = await make_base64_url_from_any_uri(uri=image_uri, storage_provider=storage)
- return PipelexHostedExtractRequest(
- model=self.inference_model.model_id,
- input=PipelexHostedExtractInput(image_uri=base64_url),
- params=params,
- )
- if document_uri := extract_input.document_uri:
- base64_url = await make_base64_url_from_any_uri(uri=document_uri, storage_provider=storage)
- return PipelexHostedExtractRequest(
- model=self.inference_model.model_id,
- input=PipelexHostedExtractInput(document_uri=base64_url),
- params=params,
- )
- msg = "No image nor document URI provided in ExtractJob"
- raise ExtractInputError(msg)
-
- def _record_usage(self, *, response_body: dict[str, Any], extract_job: ExtractJob) -> None:
- extract_tokens_usage = extract_job.job_report.extract_tokens_usage
- if not extract_tokens_usage:
- return
- usage: object = response_body.get("usage")
- if not isinstance(usage, dict):
- return
- nb_pages: object = cast("dict[str, Any]", usage).get("pages")
- if not isinstance(nb_pages, int):
- return
- nb_tokens: NbTokensByCategoryDict = {
- TokenCategory.INPUT: nb_pages * PIPELEX_HOSTED_UNIT_TOKENS,
- TokenCategory.OUTPUT: nb_pages * PIPELEX_HOSTED_UNIT_TOKENS,
- }
- extract_tokens_usage.nb_tokens_by_category = nb_tokens
diff --git a/pipelex/providers/pipelex_hosted/pipelex_hosted_factory.py b/pipelex/providers/pipelex_hosted/pipelex_hosted_factory.py
deleted file mode 100644
index 9ae29b8ad..000000000
--- a/pipelex/providers/pipelex_hosted/pipelex_hosted_factory.py
+++ /dev/null
@@ -1,170 +0,0 @@
-"""How every hosted client is built: the endpoint rule, the token, and the per-request extras.
-
-**The endpoint rule is normative and it is why this class exists at all.** The backend declares the
-Pipelex service's *origin* — scheme, host and port, with no version segment — and each
-client appends what its own SDK expects beneath it. See `pipelex_hosted_constants` for the probe that
-established which SDK appends what.
-
-**There is no fallback endpoint, deliberately.** The Portkey-path sibling reads
-``backend.endpoint or PORTKEY_GATEWAY_URL``, which is right there: an unset endpoint means "use the
-vendor's cloud". Copied here it would mean that an endpoint that resolves empty
-silently builds a client aimed at ``api.portkey.ai`` carrying the *Pipelex* service token — a live
-billable request to the wrong vendor, with nothing anywhere reporting it. So an absent endpoint is a
-refusal, and the backend loader's own missing-variable path disables the backend with a named
-warning long before this is reached.
-"""
-
-from __future__ import annotations
-
-import random
-from typing import TYPE_CHECKING, Any
-
-from pipelex.cogt.img_gen.img_gen_gemini_mapping import ImgGenGeminiMapping
-from pipelex.cogt.img_gen.img_gen_job import ImgGenJob
-from pipelex.cogt.llm.llm_job import LLMJob
-from pipelex.providers.pipelex_hosted.pipelex_hosted_constants import PIPELEX_HOSTED_API_VERSION_SEGMENT, PIPELEX_HOSTED_AUTH_HEADER
-from pipelex.providers.pipelex_hosted.pipelex_hosted_exceptions import PipelexHostedCredentialsError, PipelexHostedEndpointError
-from pipelex.providers.pipelex_hosted.pipelex_hosted_metadata import make_pipelex_hosted_metadata_headers
-
-if TYPE_CHECKING:
- from portkey_ai import AsyncPortkey
-
- from pipelex.cogt.img_gen.img_gen_job_components import ImgGenJobParams
- from pipelex.cogt.img_gen.img_gen_model_rules import AspectRatioTaxonomy
- from pipelex.cogt.inference.inference_job_abstract import InferenceJobAbstract
- from pipelex.cogt.model_backends.backend import InferenceBackend
- from pipelex.cogt.model_backends.model_spec import InferenceModelSpec
-
-
-class PipelexHostedFactory:
- @classmethod
- def get_origin(cls, backend: InferenceBackend) -> str:
- """The service origin the backend declares, with any trailing slash removed.
-
- A trailing slash is stripped rather than refused because it is the one shape of a correct
- answer a human types by accident, and it would otherwise produce a doubled separator in
- every path this class builds.
- """
- endpoint = (backend.endpoint or "").strip().rstrip("/")
- if not endpoint:
- msg = (
- f"Backend '{backend.name}' declares no endpoint for the Pipelex service. "
- f"Set the backend's `endpoint` to the service origin (scheme, host and port, with no '/v1'). "
- f"There is no default: a request built without one would reach a vendor this token is not for."
- )
- raise PipelexHostedEndpointError(msg)
- return endpoint
-
- @classmethod
- def get_base_url(cls, backend: InferenceBackend) -> str:
- """The origin plus the version segment, for the SDKs that expect one in their `base_url`."""
- return f"{cls.get_origin(backend=backend)}{PIPELEX_HOSTED_API_VERSION_SEGMENT}"
-
- @classmethod
- def get_api_key(cls, backend: InferenceBackend) -> str:
- if not backend.api_key:
- msg = f"Backend '{backend.name}' carries no api_key for the Pipelex service; set the backend's `api_key`"
- raise PipelexHostedCredentialsError(msg)
- return backend.api_key
-
- @classmethod
- def make_auth_headers(cls, backend: InferenceBackend) -> dict[str, str]:
- """The whole of what the hosted dialect puts on the wire about itself: one token header.
-
- No config id, no provider name, no routing of any kind — the service decides which provider
- serves a model from the model id in the request body, and refuses a client that tries to say
- otherwise. Building this dict by hand rather than through the vendor's header helper is what
- makes that property readable here instead of dependent on a library's constructor defaults.
- """
- return {PIPELEX_HOSTED_AUTH_HEADER: cls.get_api_key(backend=backend)}
-
- @classmethod
- def make_portkey_client(cls, backend: InferenceBackend) -> AsyncPortkey:
- """The image path's client.
-
- `portkey_ai` is a beta-only dependency of this package: the image worker reuses the vendor
- SDK's `images.generate` / `images.edit` methods for their multipart serialization, which is
- the part that was expensive to get right. Everything else in this package is built on the
- OpenAI SDK or on plain HTTP. See the deletion trigger in `pipelex_hosted_img_gen_worker`.
- """
- from portkey_ai import AsyncPortkey # ruff: ignore[import-outside-top-level]
-
- return AsyncPortkey(
- base_url=cls.get_base_url(backend=backend),
- api_key=cls.get_api_key(backend=backend),
- debug=cls.is_debug_enabled(backend=backend),
- )
-
- @classmethod
- def is_debug_enabled(cls, backend: InferenceBackend) -> bool:
- """Read from the backend's own configuration and from nothing else.
-
- The Portkey-path sibling routes this through the telemetry manager's
- Portkey-path telemetry knobs. Reusing those here would put one configuration block in
- charge of two services, which is the seam the two-gateways design exists to avoid.
- """
- return bool(backend.extra_config.get("debug", False))
-
- @classmethod
- def _make_gemini_image_config(cls, taxonomy: AspectRatioTaxonomy, *, job_params: ImgGenJobParams, model_name: str) -> dict[str, str]:
- """The gemini `image_config` block, honouring the portable size.
-
- Same resolution as the native Google worker: the requested ratio and size (tier or exact)
- are checked against the model's Gemini taxonomy, and an unset size omits `image_size` so the
- provider applies its own default.
- """
- resolved = ImgGenGeminiMapping.resolve_image_config(
- taxonomy,
- aspect_ratio=job_params.aspect_ratio,
- size=job_params.size,
- model_name=model_name,
- )
- image_config: dict[str, str] = {"aspect_ratio": resolved.aspect_ratio}
- if resolved.image_size is not None:
- image_config["image_size"] = resolved.image_size
- return image_config
-
- @classmethod
- def make_extras(
- cls, inference_model: InferenceModelSpec, *, inference_job: InferenceJobAbstract, output_desc: str
- ) -> tuple[dict[str, str], dict[str, Any]]:
- """The per-request headers and body additions.
-
- The headers always include `x-pipelex-metadata`, naming the run and the step this call
- serves (see `pipelex_hosted_metadata`). It is built here, per request, because it differs per job:
- the token is a client default, this is not.
-
- `output_desc` is part of the shared factory signature and is unused on this path: it exists
- for the Portkey-path tracing header that names the job, and the hosted dialect sends no
- tracing headers in the beta.
- """
- del output_desc
- extra_headers: dict[str, str] = {}
- extra_body: dict[str, Any] = {}
- if inference_model.extra_headers:
- # Per-model outbound headers the catalog sets — `anthropic-beta` is the live example.
- # None of these is routing: the service refuses any client header that tries to choose a
- # provider, and passes the rest through to whichever one it picked.
- extra_headers.update(inference_model.extra_headers)
- # After the catalog's headers, so a catalog entry cannot restate whose call this is.
- extra_headers.update(make_pipelex_hosted_metadata_headers(job_metadata=inference_job.job_metadata))
-
- if isinstance(inference_job, LLMJob):
- # Mistral models really want a non-null seed. The spec carries no Mistral-specific field
- # to key this on, so the model id's prefix decides, and it holds whether the catalog
- # gives the provider's id or leaves the id to default to a `mistral-` handle.
- if inference_model.model_id.lower().startswith("mistral-") and inference_job.job_params.seed is None:
- extra_body["seed"] = random.randint(0, 1000000)
- elif isinstance(inference_job, ImgGenJob):
- # Decided by the spec, not the name: the catalog may serve a Gemini image model under a
- # handle such as `nano-banana`, and the model id defaults to the handle when the catalog
- # gives none. A Gemini taxonomy in the image rules is what makes it one, and a spec whose
- # rules cannot say is refused rather than read as non-Gemini.
- if (gemini_taxonomy := ImgGenGeminiMapping.optional_gemini_taxonomy(inference_model)) is not None:
- extra_body["image_config"] = cls._make_gemini_image_config(
- gemini_taxonomy,
- job_params=inference_job.job_params,
- model_name=inference_model.name,
- )
-
- return extra_headers, extra_body
diff --git a/pipelex/providers/pipelex_hosted/pipelex_hosted_img_gen_worker.py b/pipelex/providers/pipelex_hosted/pipelex_hosted_img_gen_worker.py
deleted file mode 100644
index a5088cbee..000000000
--- a/pipelex/providers/pipelex_hosted/pipelex_hosted_img_gen_worker.py
+++ /dev/null
@@ -1,263 +0,0 @@
-"""Image generation and editing through the Pipelex service.
-
-**This module is the one place the hosted plugin depends on `portkey_ai`, and the dependency has a
-deletion trigger.** The two-gateways design ruled that the hosted plugin must not depend on the
-vendor's library — "when Portkey retires as a vendor, the library retires with it" — and the
-engineering review of 2026-08-25 lifted that rule *for the beta only*, so the image path could reuse
-work that was already proven live rather than being ported first. Reusing `AsyncPortkey` buys one
-specific thing: its `images.generate` / `images.edit` methods carry the multipart serialization for
-image edits, which is the part that was expensive to get right.
-
-**Delete this dependency when** the hosted image path is ported to the OpenAI SDK — the mapping
-can be read out of the Portkey SDK's own source. What changes then is this module's client and its
-exception arms; nothing else in the package imports the vendor library. Until that happens, the
-design page's claim that the hosted plugin does not depend on `portkey_ai` is false, which is why
-the lift is written into the design rather than only into a plan.
-
-**The response shapes this worker parses are only the ones the hosted model catalog names.** Every
-`manifold_img_gen` entry is an Azure GPT Image model, and the gateway's own configuration serves
-them from one integration. The Portkey path's worker also carries a Black Forest Labs Flux 2 Pro
-branch and a FAL queue-polling branch; neither has a model on this path, so neither is carried here.
-A response that matches nothing is refused with what it actually contained, and restoring a branch
-is a `git show` away.
-"""
-
-from __future__ import annotations
-
-import json
-from typing import TYPE_CHECKING, Any, cast
-
-from portkey_ai import AsyncPortkey
-
-# The vendored openai package is the one AsyncPortkey is built from, so the exceptions it raises are
-# the vendored classes (not the real `openai` package's) — there is no public re-export in portkey_ai.
-from portkey_ai._vendor import openai as portkey_vendored_openai # ruff: ignore[import-private-name]
-from portkey_ai.api_resources import exceptions as portkey_exceptions
-from pydantic import ValidationError
-from typing_extensions import override
-
-from pipelex.cogt.exceptions import ImgGenGenerationError, ImgGenParameterError, InferenceErrorCategory, SdkTypeError
-from pipelex.cogt.image.generated_image import GeneratedImageRawDetails
-from pipelex.cogt.image.image_size import ImageSize
-from pipelex.cogt.img_gen.img_gen_args_factory import ImageFileTuple, ImgGenArgsFactory
-from pipelex.cogt.img_gen.img_gen_worker_abstract import ImgGenWorkerAbstract
-from pipelex.cogt.inference.error_classification import UserAction, UserActionKind, extract_gateway_metadata
-from pipelex.cogt.inference.error_classify import classify_inference_error
-from pipelex.cogt.inference.error_render import InferenceErrorFamily, render_inference_error
-from pipelex.cogt.usage.token_category import NbTokensByCategoryDict, TokenCategory
-from pipelex.providers.pipelex_hosted.pipelex_hosted_metadata import make_pipelex_hosted_metadata_headers
-from pipelex.providers.pipelex_hosted.pipelex_hosted_response_errors import describe_response_validation_error
-from pipelex.providers.pipelex_hosted.pipelex_hosted_schemas import PipelexHostedImgGenAzureGptImage
-
-if TYPE_CHECKING:
- from pipelex.cogt.img_gen.img_gen_job import ImgGenJob
- from pipelex.cogt.model_backends.model_spec import InferenceModelSpec
- from pipelex.reporting.reporting_protocol import ReportingProtocol
-
-
-class PipelexHostedImgGenWorker(ImgGenWorkerAbstract):
- def __init__(
- self,
- sdk_instance: Any,
- inference_model: InferenceModelSpec,
- reporting_delegate: ReportingProtocol | None = None,
- ):
- super().__init__(inference_model=inference_model, reporting_delegate=reporting_delegate)
-
- if not isinstance(sdk_instance, AsyncPortkey):
- msg = f"Provided ImgGen sdk_instance for {self.__class__.__name__} is not of type portkey_ai.AsyncPortkey: it's a '{type(sdk_instance)}'"
- raise SdkTypeError(msg)
-
- self.portkey_client: AsyncPortkey = sdk_instance
-
- @override
- async def _gen_image(
- self,
- img_gen_job: ImgGenJob,
- ) -> GeneratedImageRawDetails:
- one_image_list = await self._gen_image_list(img_gen_job=img_gen_job, nb_images=1)
- return one_image_list[0]
-
- @override
- async def _gen_image_list(
- self,
- img_gen_job: ImgGenJob,
- *,
- nb_images: int,
- ) -> list[GeneratedImageRawDetails]:
- if self.inference_model.rules is None:
- msg = f"Model '{self.inference_model.name}' does not have rules configured"
- raise ImgGenParameterError(msg, error_category=InferenceErrorCategory.CONFIGURATION)
- args_dict = await ImgGenArgsFactory.make_args_for_model(
- model_rules=self.inference_model.rules,
- img_gen_job=img_gen_job,
- nb_images=nb_images,
- model_id=self.inference_model.model_id,
- model_name=self.inference_model.name,
- )
-
- image_files: list[ImageFileTuple] | None = args_dict.pop("image", None)
- extra_headers = make_pipelex_hosted_metadata_headers(job_metadata=img_gen_job.job_metadata)
- response_dict = await self._call_images_api(image_files=image_files, args_dict=args_dict, extra_headers=extra_headers)
- self._record_usage(response_dict=response_dict, img_gen_job=img_gen_job)
- return self._make_generated_images(response_dict=response_dict)
-
- async def _call_images_api(
- self, *, image_files: list[ImageFileTuple] | None, args_dict: dict[str, Any], extra_headers: dict[str, str]
- ) -> dict[str, Any]:
- """One call, one dict back — whichever of the two Images routes the job needs.
-
- `extra_headers` is the per-request `x-pipelex-metadata` header. It goes through the SDK's
- own `extra_headers` rather than the client's defaults because it differs per job, and the
- vendor client's `metadata` constructor argument is left alone: it would be sent as
- `x-portkey-metadata`, a name the gateway does not read.
-
- There is no `endpoint_path` here and no config id: the hosted dialect puts the model in the
- body and lets the gateway decide who serves it, so which *route* is called is the SDK
- method's business and which *provider* answers is the gateway's.
- """
- # Declared rather than inferred: the SDK's image methods are typed with `**kwargs: Unknown`,
- # so calling them with a spread argument dict leaves pyright unable to name the result.
- response: Any
- try:
- if image_files is not None:
- # OpenAI's Images API splits generation and editing across two routes, and only
- # /images/edits accepts input images (/images/generations rejects them with a 400
- # "Unknown parameter"). The shape of the multipart body is the SDK's business too: a
- # list under `image` is serialized as `image[]` parts, a single file as the bare
- # `image` field. That distinction is not cosmetic — a server handed repeated bare
- # `image` parts keeps one and silently drops the rest, so an edit of several images
- # would come back as a plausible edit of the first.
- images_arg: Any = image_files[0] if len(image_files) == 1 else list(image_files)
- response = await self.portkey_client.images.edit(image=images_arg, extra_headers=extra_headers, **args_dict) # pyright: ignore[reportUnknownMemberType, reportUnknownVariableType]
- else:
- response = await self.portkey_client.images.generate(extra_headers=extra_headers, **args_dict) # pyright: ignore[reportUnknownMemberType, reportUnknownVariableType]
- except (portkey_exceptions.APIError, portkey_vendored_openai.APIError) as exc:
- metadata = extract_gateway_metadata(exc)
- classification = classify_inference_error(metadata)
- raise render_inference_error(
- metadata=metadata,
- classification=classification,
- family=InferenceErrorFamily.IMG_GEN,
- model_desc=self.inference_model.desc,
- model_handle=self.inference_model.name,
- ) from exc
- except json.JSONDecodeError as exc:
- # A 2xx carrying a body that is not JSON — an intermediary's HTML error page is the way
- # this happens — makes the SDK's own decode raise. `JSONDecodeError` is not an `APIError`
- # and so falls through the arm above; left raw it is neither a `PipelexError` nor
- # annotated with the model, which means it escapes the Temporal error bridge and gets
- # retried, billing a second generation for the same job.
- msg = f"The Pipelex service returned a non-JSON body for model '{self.inference_model.name}'"
- raise ImgGenGenerationError(
- msg,
- error_category=InferenceErrorCategory.UNKNOWN,
- user_action=UserAction(
- kind=UserActionKind.CONTACT_SUPPORT,
- detail="The gateway returned a malformed response — retry, and report this if it persists",
- ),
- provider_metadata=None,
- ) from exc
-
- raw_response = cast("object", response.model_dump(serialize_as_any=True)) # pyright: ignore[reportUnknownMemberType]
- if not isinstance(raw_response, dict):
- msg = f"Response from model '{self.inference_model.name}' did not serialize to an object: it is a '{type(raw_response).__name__}'"
- raise ImgGenGenerationError(
- msg,
- error_category=InferenceErrorCategory.UNKNOWN,
- user_action=UserAction(
- kind=UserActionKind.CHANGE_MODEL,
- detail="The gateway returned an unexpected response shape — try a different model",
- ),
- provider_metadata=None,
- )
- return cast("dict[str, Any]", raw_response)
-
- def _record_usage(self, *, response_dict: dict[str, Any], img_gen_job: ImgGenJob) -> None:
- if (usage_dict := response_dict.get("usage")) and (img_gen_tokens_usage := img_gen_job.job_report.img_gen_tokens_usage):
- nb_tokens: NbTokensByCategoryDict = {}
- if input_tokens := usage_dict.get("prompt_tokens") or usage_dict.get("input_tokens"):
- nb_tokens[TokenCategory.INPUT] = input_tokens
- if output_tokens := usage_dict.get("completion_tokens") or usage_dict.get("output_tokens"):
- nb_tokens[TokenCategory.OUTPUT] = output_tokens
- img_gen_tokens_usage.nb_tokens_by_category = nb_tokens
-
- def _make_generated_images(self, *, response_dict: dict[str, Any]) -> list[GeneratedImageRawDetails]:
- try:
- azure_gpt_image = PipelexHostedImgGenAzureGptImage.model_validate(response_dict)
- except ValidationError as exc:
- problems = describe_response_validation_error(exc=exc)
- msg = f"Could not parse the image generation response for model '{self.inference_model.name}': {problems}"
- raise ImgGenGenerationError(
- msg,
- error_category=InferenceErrorCategory.UNKNOWN,
- user_action=UserAction(
- kind=UserActionKind.CHANGE_MODEL,
- detail="The gateway returned an unexpected response shape — try a different model",
- ),
- provider_metadata=None,
- ) from exc
-
- if not azure_gpt_image.data:
- msg = f"Response from model '{self.inference_model.name}' carries no 'data' images"
- raise ImgGenGenerationError(
- msg,
- error_category=InferenceErrorCategory.UNKNOWN,
- user_action=UserAction(
- kind=UserActionKind.CHANGE_MODEL,
- detail="The gateway returned an unexpected response shape — try a different model",
- ),
- provider_metadata=None,
- )
-
- width, height = self._parse_size(size=azure_gpt_image.size)
-
- generated_images: list[GeneratedImageRawDetails] = []
- for image in azure_gpt_image.data:
- if not image.b64_json:
- msg = f"No base64 image data received from model '{self.inference_model.name}'"
- raise ImgGenGenerationError(
- msg,
- error_category=InferenceErrorCategory.CONTENT,
- user_action=UserAction(
- kind=UserActionKind.CHANGE_INPUT,
- detail="The gateway returned no image data — try rephrasing the prompt or using a different model",
- ),
- provider_metadata=None,
- )
- generated_images.append(
- GeneratedImageRawDetails(
- base64_str=image.b64_json,
- size=ImageSize(width=width, height=height),
- image_format=azure_gpt_image.output_format,
- ),
- )
- return generated_images
-
- def _parse_size(self, *, size: str) -> tuple[int, int]:
- size_split = size.split("x")
- if len(size_split) != 2:
- msg = f"Size from img gen response is not a valid size: '{size}'"
- raise ImgGenGenerationError(
- msg,
- error_category=InferenceErrorCategory.UNKNOWN,
- user_action=UserAction(
- kind=UserActionKind.CHANGE_MODEL,
- detail="The gateway returned a malformed image size — try a different model",
- ),
- provider_metadata=None,
- )
- width_str, height_str = size_split
- try:
- return int(width_str), int(height_str)
- except ValueError as exc:
- msg = f"Size from img gen response has non-numeric dimensions: '{size}'"
- raise ImgGenGenerationError(
- msg,
- error_category=InferenceErrorCategory.UNKNOWN,
- user_action=UserAction(
- kind=UserActionKind.CHANGE_MODEL,
- detail="The gateway returned a malformed image size — try a different model",
- ),
- provider_metadata=None,
- ) from exc
diff --git a/pipelex/providers/pipelex_hosted/pipelex_hosted_metadata.py b/pipelex/providers/pipelex_hosted/pipelex_hosted_metadata.py
deleted file mode 100644
index 3d2303f67..000000000
--- a/pipelex/providers/pipelex_hosted/pipelex_hosted_metadata.py
+++ /dev/null
@@ -1,73 +0,0 @@
-"""The one header that says whose call this is: `x-pipelex-metadata`, a flat JSON object.
-
-**Why the hosted dialect sends it.** The Pipelex service attributes the spend of every
-inference call it serves and logs the call, and neither is possible from the service token alone —
-one token serves every run a deployment executes, for every caller and every tenant. So each request
-the dialect makes carries, beside the token, a small JSON object naming the run and the step it
-belongs to, and the host's own labels for it.
-
-**What goes in it.** The run's `extras` entries, verbatim and unread, then the runtime's own ids:
-`user_id` and `pipeline_run_id` from the run half of the job metadata, `pipe_run_id`, `pipe_code`
-and `content_generation_job_id` from the step half. An id the job does not carry (`None`) is left
-out rather than sent as `null`, so every value on the wire is a string.
-
-**The runtime's keys win on a collision, deliberately.** `extras` is caller data: the host fills it,
-and its key charset (`RUN_EXTRAS_KEY_PATTERN`, lowercase snake_case up to 32 characters) admits every
-one of the runtime's key names. Letting an extras entry named `user_id` or `pipeline_run_id` stand
-would let whoever supplies the labels restate the run's identity to the service that bills for it.
-Writing the runtime's keys after the extras makes the run's own facts the last word.
-
-**The runtime still never reads a key of `extras` by name** — the rule `pipelex.system.run_extras`
-states. The mapping is copied across whole; nothing here knows that the hosted platform puts an
-organization id in it, and a deployment that sends other labels is served identically.
-
-**Why the value cannot forge a header line.** Every value reaching this module is already bounded —
-the extras charset, the request-id check, the hex run ids — but the encoding does not rely on that.
-`json.dumps` with ASCII output escapes every control character (CR and LF included) and every
-non-ASCII code point, and the one printable-range character JSON leaves raw that an HTTP field value
-refuses, DEL, is escaped here too. What reaches the wire is printable ASCII, whatever went in.
-"""
-
-from __future__ import annotations
-
-import json
-from typing import TYPE_CHECKING
-
-from pipelex.providers.pipelex_hosted.pipelex_hosted_constants import PIPELEX_HOSTED_METADATA_HEADER
-
-if TYPE_CHECKING:
- from pipelex.system.job_metadata import JobMetadata
-
-
-def make_pipelex_hosted_metadata(*, job_metadata: JobMetadata) -> dict[str, str]:
- """The flat mapping the header carries: the run's extras, then the runtime's own ids over them."""
- run_metadata = job_metadata.run_metadata
- runtime_ids: dict[str, str | None] = {
- "user_id": run_metadata.user_id,
- "pipeline_run_id": run_metadata.pipeline_run_id,
- "pipe_run_id": job_metadata.pipe_run_id,
- "pipe_code": job_metadata.pipe_code,
- "content_generation_job_id": job_metadata.content_generation_job_id,
- }
- metadata: dict[str, str] = dict(run_metadata.extras)
- for key, value in runtime_ids.items():
- if value is None:
- # An absent id is not a colliding one: an extras entry of the same name is dropped
- # rather than left standing in for a fact the runtime does not have.
- metadata.pop(key, None)
- continue
- metadata[key] = value
- return metadata
-
-
-def encode_pipelex_hosted_metadata(*, metadata: dict[str, str]) -> str:
- """The header value: compact JSON in printable ASCII only."""
- encoded = json.dumps(metadata, ensure_ascii=True, separators=(",", ":"))
- # JSON escapes control characters below 0x20 and, with `ensure_ascii`, everything above 0x7E
- # except DEL itself, which an HTTP field value refuses. `\u007f` is the same JSON string.
- return encoded.replace("\x7f", "\\u007f")
-
-
-def make_pipelex_hosted_metadata_headers(*, job_metadata: JobMetadata) -> dict[str, str]:
- """The one-entry header mapping a hosted request adds for the job it serves."""
- return {PIPELEX_HOSTED_METADATA_HEADER: encode_pipelex_hosted_metadata(metadata=make_pipelex_hosted_metadata(job_metadata=job_metadata))}
diff --git a/pipelex/providers/pipelex_hosted/pipelex_hosted_native_client.py b/pipelex/providers/pipelex_hosted/pipelex_hosted_native_client.py
deleted file mode 100644
index eac962b34..000000000
--- a/pipelex/providers/pipelex_hosted/pipelex_hosted_native_client.py
+++ /dev/null
@@ -1,107 +0,0 @@
-"""The HTTP client for the Pipelex service's own routes.
-
-``POST /v1/pipelex/extract`` and ``POST /v1/pipelex/search`` are not OpenAI-shaped — they serve
-document extraction and web search as themselves rather than dressed as chat completions — so they
-are called with plain ``httpx`` rather than through a vendor SDK wrapped around a chat body.
-
-**Building the request by hand is what makes the wire readable.** Two properties of the hosted dialect
-dialect live in this one method and can be asserted in a test that reads the request it built: the
-only header about us is the service token, and the body carries the model with nothing about
-routing. A client whose constructor defaults decide the headers cannot say that. The one other
-header is `x-pipelex-metadata`, which says whose call it is rather than anything about us; it
-differs per job, so the caller hands the job's metadata to each call rather than to the client.
-"""
-
-from __future__ import annotations
-
-from typing import TYPE_CHECKING, Any
-
-import httpx
-
-from pipelex.cogt.inference.error_classify import classify_inference_error
-from pipelex.cogt.inference.error_render import render_inference_error
-from pipelex.cogt.inference.transport_retry import request_with_transport_retry
-from pipelex.config import get_config
-from pipelex.providers.pipelex_hosted.pipelex_hosted_error_metadata import extract_pipelex_hosted_metadata
-from pipelex.providers.pipelex_hosted.pipelex_hosted_exceptions import PipelexHostedError
-from pipelex.providers.pipelex_hosted.pipelex_hosted_factory import PipelexHostedFactory
-from pipelex.providers.pipelex_hosted.pipelex_hosted_metadata import make_pipelex_hosted_metadata_headers
-
-if TYPE_CHECKING:
- from pipelex.cogt.inference.error_render import InferenceErrorFamily
- from pipelex.cogt.model_backends.backend import InferenceBackend
- from pipelex.cogt.model_backends.model_spec import InferenceModelSpec
- from pipelex.system.job_metadata import JobMetadata
-
-# Generous, and deliberately so: a deep web search or a many-page extraction is a slow call, and the
-# runtime's own job-level timeouts are the ones that should bound it. Matches the SDK-less image
-# path's floor rather than inventing a second number.
-PIPELEX_HOSTED_NATIVE_TIMEOUT_SECONDS = 600.0
-
-
-class PipelexHostedNativeClient:
- """One route call, one dict back — or a categorized inference error."""
-
- def __init__(self, *, backend: InferenceBackend) -> None:
- self.base_url = PipelexHostedFactory.get_base_url(backend=backend)
- self.auth_headers = PipelexHostedFactory.make_auth_headers(backend=backend)
-
- async def post_json(
- self,
- *,
- route: str,
- body: dict[str, Any],
- family: InferenceErrorFamily,
- inference_model: InferenceModelSpec,
- job_metadata: JobMetadata,
- ) -> dict[str, Any]:
- url = f"{self.base_url}{route}"
- headers = {
- **self.auth_headers,
- **make_pipelex_hosted_metadata_headers(job_metadata=job_metadata),
- "Content-Type": "application/json",
- }
-
- async def _send() -> httpx.Response:
- async with httpx.AsyncClient() as client:
- response = await client.post(
- url,
- headers=headers,
- json=body,
- timeout=PIPELEX_HOSTED_NATIVE_TIMEOUT_SECONDS,
- )
- response.raise_for_status()
- return response
-
- try:
- # These are billable, non-idempotent POSTs — a search that reached the provider has been
- # paid for — so an ambiguous 5xx is not retried. The retry stays on the failures that
- # prove no work was done.
- http_response = await request_with_transport_retry(
- send_request=_send,
- max_retries=get_config().inference.transport_max_retries,
- retry_on_ambiguous_failure=False,
- )
- except httpx.HTTPError as exc:
- metadata = extract_pipelex_hosted_metadata(exc)
- classification = classify_inference_error(metadata)
- raise render_inference_error(
- metadata=metadata,
- classification=classification,
- family=family,
- model_desc=inference_model.desc,
- model_handle=inference_model.name,
- ) from exc
-
- try:
- payload: Any = http_response.json()
- except ValueError as exc:
- # A 2xx whose body is not JSON — an intermediary's error page is how this happens. Left
- # raw it is neither a `PipelexError` nor annotated with the model, so it would escape
- # the Temporal error bridge and be retried against a call that was already paid for.
- msg = f"The Pipelex service returned a non-JSON body for model '{inference_model.name}'"
- raise PipelexHostedError(msg) from exc
- if not isinstance(payload, dict):
- msg = f"The Pipelex service returned a '{type(payload).__name__}' rather than an object for model '{inference_model.name}'"
- raise PipelexHostedError(msg)
- return payload # pyright: ignore[reportUnknownVariableType]
diff --git a/pipelex/providers/pipelex_hosted/pipelex_hosted_plugin.py b/pipelex/providers/pipelex_hosted/pipelex_hosted_plugin.py
deleted file mode 100644
index 20950b0a0..000000000
--- a/pipelex/providers/pipelex_hosted/pipelex_hosted_plugin.py
+++ /dev/null
@@ -1,220 +0,0 @@
-"""The hosted sdk set, registered.
-
-One registration per ``(family, sdk)`` the Pipelex service serves. The pairing worth
-noticing is ``(IMG_GEN, manifold_completions)``: some image models answer on the Chat Completions
-shape rather than on the Images API, and the catalog says which by giving them ``model_type =
-"img_gen"`` while leaving them on the default completions sdk — so the same sdk name is registered
-under two families, served by two different workers.
-
-Claude reaches the Pipelex service on ``manifold_anthropic``: the open Anthropic worker, built with
-the package's extras factory so that every call carries the metadata header, and a client that
-authenticates on whichever header the backend names. A catalog entry left on the plain ``anthropic``
-sdk would still answer, without the header.
-"""
-
-from __future__ import annotations
-
-from typing import TYPE_CHECKING
-
-from pipelex.plugins.contract import PLUGIN_API_VERSION
-from pipelex.plugins.inference_backend_registry import InferenceFamily, require_sdk
-from pipelex.plugins.model_handle import ModelHandle
-from pipelex.providers.pipelex_hosted.pipelex_hosted_constants import PipelexHostedSdk
-from pipelex.providers.pipelex_hosted.pipelex_hosted_error_codes import PIPELEX_HOSTED_SERVICE_ERROR_CODES
-
-if TYPE_CHECKING:
- from pipelex.cogt.inference.inference_worker_abstract import InferenceWorkerAbstract
- from pipelex.cogt.model_backends.backend import InferenceBackend
- from pipelex.cogt.model_backends.model_spec import InferenceModelSpec
- from pipelex.plugins.registrar import PluginRegistrar
- from pipelex.plugins.sdk_client_registry import SdkClientRegistry
- from pipelex.reporting.reporting_protocol import ReportingProtocol
-
-
-def _make_pipelex_hosted_anthropic_worker(
- *,
- inference_model: InferenceModelSpec,
- backend: InferenceBackend,
- sdk_clients: SdkClientRegistry,
- reporting_delegate: ReportingProtocol | None,
-) -> InferenceWorkerAbstract:
- require_sdk(spec="anthropic", extra="anthropic", msg="The anthropic SDK is required to reach Claude through this backend.")
-
- from pipelex.providers.anthropic.anthropic_factory import AnthropicFactory, AnthropicSdkVariant # ruff: ignore[import-outside-top-level]
- from pipelex.providers.anthropic.anthropic_llm_worker import AnthropicLLMWorker # ruff: ignore[import-outside-top-level]
- from pipelex.providers.pipelex_hosted.pipelex_hosted_anthropic_extras import ( # ruff: ignore[import-outside-top-level]
- PipelexHostedAnthropicExtrasFactory,
- )
-
- model_handle = ModelHandle.make_for_inference_model(inference_model=inference_model)
- sdk_instance = sdk_clients.get_or_create(
- handle=model_handle,
- build=lambda: AnthropicFactory.make_anthropic_client(model_handle=model_handle, backend=backend, sdk_variant=AnthropicSdkVariant.ANTHROPIC),
- )
- return AnthropicLLMWorker(
- sdk_instance=sdk_instance,
- extra_config=backend.extra_config,
- inference_model=inference_model,
- reporting_delegate=reporting_delegate,
- extras_factory=PipelexHostedAnthropicExtrasFactory(),
- )
-
-
-def _make_pipelex_hosted_completions_worker(
- *,
- inference_model: InferenceModelSpec,
- backend: InferenceBackend,
- sdk_clients: SdkClientRegistry,
- reporting_delegate: ReportingProtocol | None,
-) -> InferenceWorkerAbstract:
- from pipelex.providers.openai.openai_completions_llm_worker import OpenAICompletionsLLMWorker # ruff: ignore[import-outside-top-level]
- from pipelex.providers.pipelex_hosted.pipelex_hosted_completions_factory import ( # ruff: ignore[import-outside-top-level]
- PipelexHostedCompletionsFactory,
- )
-
- model_handle = ModelHandle.make_for_inference_model(inference_model=inference_model)
- sdk_instance = sdk_clients.get_or_create(
- handle=model_handle,
- build=lambda: PipelexHostedCompletionsFactory.make_openai_client_for_completions(model_handle=model_handle, backend=backend),
- )
- return OpenAICompletionsLLMWorker(
- openai_completions_factory=PipelexHostedCompletionsFactory(is_http_url_enabled=False),
- sdk_instance=sdk_instance,
- inference_model=inference_model,
- reporting_delegate=reporting_delegate,
- )
-
-
-def _make_pipelex_hosted_responses_worker(
- *,
- inference_model: InferenceModelSpec,
- backend: InferenceBackend,
- sdk_clients: SdkClientRegistry,
- reporting_delegate: ReportingProtocol | None,
-) -> InferenceWorkerAbstract:
- from pipelex.providers.openai.openai_responses_llm_worker import OpenAIResponsesLLMWorker # ruff: ignore[import-outside-top-level]
- from pipelex.providers.pipelex_hosted.pipelex_hosted_responses_factory import ( # ruff: ignore[import-outside-top-level]
- PipelexHostedResponsesFactory,
- )
-
- model_handle = ModelHandle.make_for_inference_model(inference_model=inference_model)
- sdk_instance = sdk_clients.get_or_create(
- handle=model_handle,
- build=lambda: PipelexHostedResponsesFactory.make_openai_client_for_responses(model_handle=model_handle, backend=backend),
- )
- return OpenAIResponsesLLMWorker(
- openai_responses_factory=PipelexHostedResponsesFactory(is_http_url_enabled=False),
- sdk_instance=sdk_instance,
- inference_model=inference_model,
- reporting_delegate=reporting_delegate,
- )
-
-
-def _make_pipelex_hosted_completions_img_gen_worker(
- *,
- inference_model: InferenceModelSpec,
- backend: InferenceBackend,
- sdk_clients: SdkClientRegistry,
- reporting_delegate: ReportingProtocol | None,
-) -> InferenceWorkerAbstract:
- from pipelex.providers.openai.openai_completions_img_gen_worker import OpenAICompletionsImgGenWorker # ruff: ignore[import-outside-top-level]
- from pipelex.providers.pipelex_hosted.pipelex_hosted_completions_factory import ( # ruff: ignore[import-outside-top-level]
- PipelexHostedCompletionsFactory,
- )
- from pipelex.tools.misc.image_utils import ImageFormat # ruff: ignore[import-outside-top-level]
-
- model_handle = ModelHandle.make_for_inference_model(inference_model=inference_model)
- sdk_instance = sdk_clients.get_or_create(
- handle=model_handle,
- build=lambda: PipelexHostedCompletionsFactory.make_openai_client_for_completions(model_handle=model_handle, backend=backend),
- )
- return OpenAICompletionsImgGenWorker(
- openai_completions_factory=PipelexHostedCompletionsFactory(is_http_url_enabled=False),
- sdk_instance=sdk_instance,
- inference_model=inference_model,
- reporting_delegate=reporting_delegate,
- fixed_output_format=ImageFormat.PNG,
- )
-
-
-def _make_pipelex_hosted_img_gen_worker(
- *,
- inference_model: InferenceModelSpec,
- backend: InferenceBackend,
- sdk_clients: SdkClientRegistry,
- reporting_delegate: ReportingProtocol | None,
-) -> InferenceWorkerAbstract:
- from pipelex.providers.pipelex_hosted.pipelex_hosted_factory import PipelexHostedFactory # ruff: ignore[import-outside-top-level]
- from pipelex.providers.pipelex_hosted.pipelex_hosted_img_gen_worker import PipelexHostedImgGenWorker # ruff: ignore[import-outside-top-level]
-
- model_handle = ModelHandle.make_for_inference_model(inference_model=inference_model)
- sdk_instance = sdk_clients.get_or_create(
- handle=model_handle,
- build=lambda: PipelexHostedFactory.make_portkey_client(backend=backend),
- )
- return PipelexHostedImgGenWorker(
- sdk_instance=sdk_instance,
- inference_model=inference_model,
- reporting_delegate=reporting_delegate,
- )
-
-
-def _make_pipelex_hosted_extract_worker(
- *,
- inference_model: InferenceModelSpec,
- backend: InferenceBackend,
- sdk_clients: SdkClientRegistry,
- reporting_delegate: ReportingProtocol | None,
-) -> InferenceWorkerAbstract:
- from pipelex.providers.pipelex_hosted.pipelex_hosted_extract_worker import PipelexHostedExtractWorker # ruff: ignore[import-outside-top-level]
- from pipelex.providers.pipelex_hosted.pipelex_hosted_native_client import PipelexHostedNativeClient # ruff: ignore[import-outside-top-level]
-
- model_handle = ModelHandle.make_for_inference_model(inference_model=inference_model)
- sdk_instance = sdk_clients.get_or_create(handle=model_handle, build=lambda: PipelexHostedNativeClient(backend=backend))
- return PipelexHostedExtractWorker(
- sdk_instance=sdk_instance,
- extra_config=backend.extra_config,
- inference_model=inference_model,
- reporting_delegate=reporting_delegate,
- )
-
-
-def _make_pipelex_hosted_search_worker(
- *,
- inference_model: InferenceModelSpec,
- backend: InferenceBackend,
- sdk_clients: SdkClientRegistry,
- reporting_delegate: ReportingProtocol | None,
-) -> InferenceWorkerAbstract:
- from pipelex.providers.pipelex_hosted.pipelex_hosted_native_client import PipelexHostedNativeClient # ruff: ignore[import-outside-top-level]
- from pipelex.providers.pipelex_hosted.pipelex_hosted_search_worker import PipelexHostedSearchWorker # ruff: ignore[import-outside-top-level]
-
- model_handle = ModelHandle.make_for_inference_model(inference_model=inference_model)
- sdk_instance = sdk_clients.get_or_create(handle=model_handle, build=lambda: PipelexHostedNativeClient(backend=backend))
- return PipelexHostedSearchWorker(
- sdk_instance=sdk_instance,
- inference_model=inference_model,
- reporting_delegate=reporting_delegate,
- )
-
-
-class PipelexHostedPlugin:
- """Built-in driver for the Pipelex service, serving all inference families."""
-
- # The plugin name the hosted plane's config selects, so it keeps that spelling
- name = "manifold"
- targets_api = PLUGIN_API_VERSION
-
- def register(self, registrar: PluginRegistrar) -> None:
- registrar.add_service_error_codes(codes=PIPELEX_HOSTED_SERVICE_ERROR_CODES)
- registrar.add_inference_backend(family=InferenceFamily.LLM, sdk=PipelexHostedSdk.ANTHROPIC, make_worker=_make_pipelex_hosted_anthropic_worker)
- registrar.add_inference_backend(
- family=InferenceFamily.LLM, sdk=PipelexHostedSdk.COMPLETIONS, make_worker=_make_pipelex_hosted_completions_worker
- )
- registrar.add_inference_backend(family=InferenceFamily.LLM, sdk=PipelexHostedSdk.RESPONSES, make_worker=_make_pipelex_hosted_responses_worker)
- registrar.add_inference_backend(family=InferenceFamily.IMG_GEN, sdk=PipelexHostedSdk.IMG_GEN, make_worker=_make_pipelex_hosted_img_gen_worker)
- registrar.add_inference_backend(
- family=InferenceFamily.IMG_GEN, sdk=PipelexHostedSdk.COMPLETIONS, make_worker=_make_pipelex_hosted_completions_img_gen_worker
- )
- registrar.add_inference_backend(family=InferenceFamily.EXTRACT, sdk=PipelexHostedSdk.EXTRACT, make_worker=_make_pipelex_hosted_extract_worker)
- registrar.add_inference_backend(family=InferenceFamily.SEARCH, sdk=PipelexHostedSdk.SEARCH, make_worker=_make_pipelex_hosted_search_worker)
diff --git a/pipelex/providers/pipelex_hosted/pipelex_hosted_response_errors.py b/pipelex/providers/pipelex_hosted/pipelex_hosted_response_errors.py
deleted file mode 100644
index 6b7d2bf7f..000000000
--- a/pipelex/providers/pipelex_hosted/pipelex_hosted_response_errors.py
+++ /dev/null
@@ -1,14 +0,0 @@
-"""How a response body the service sent in an unexpected shape is described in an error message.
-
-A local formatter rather than core's richer validation-error analysis, which is a general-purpose
-helper rather than an extension point: a service response that fails its schema needs only which
-fields were wrong and why.
-"""
-
-from pydantic import ValidationError
-
-
-def describe_response_validation_error(*, exc: ValidationError) -> str:
- """One `location: message` clause per error, in the order pydantic reports them."""
- clauses = [f"{'.'.join(str(part) for part in error['loc']) or '<root>'}: {error['msg']}" for error in exc.errors()]
- return "; ".join(clauses)
diff --git a/pipelex/providers/pipelex_hosted/pipelex_hosted_responses_factory.py b/pipelex/providers/pipelex_hosted/pipelex_hosted_responses_factory.py
deleted file mode 100644
index 140b8a05f..000000000
--- a/pipelex/providers/pipelex_hosted/pipelex_hosted_responses_factory.py
+++ /dev/null
@@ -1,57 +0,0 @@
-"""The Responses-API factory for the Pipelex service.
-
-Thin, unlike its Chat Completions sibling: the Responses shape carries documents as its own input
-parts, so there is no gateway-specific message override to copy. All this class supplies is the
-client — built under the endpoint rule, authenticated on the service's header — and the per-request
-extras.
-"""
-
-from __future__ import annotations
-
-from typing import TYPE_CHECKING, Any
-
-import openai
-from typing_extensions import override
-
-from pipelex.config import get_config
-from pipelex.providers.openai.openai_responses_factory import OpenAIResponsesFactory
-from pipelex.providers.pipelex_hosted.pipelex_hosted_constants import PipelexHostedOpenAISdkVariant
-from pipelex.providers.pipelex_hosted.pipelex_hosted_exceptions import PipelexHostedFactoryError
-from pipelex.providers.pipelex_hosted.pipelex_hosted_factory import PipelexHostedFactory
-
-if TYPE_CHECKING:
- from pipelex.cogt.inference.inference_job_abstract import InferenceJobAbstract
- from pipelex.cogt.model_backends.backend import InferenceBackend
- from pipelex.cogt.model_backends.model_spec import InferenceModelSpec
- from pipelex.plugins.model_handle import ModelHandle
-
-
-class PipelexHostedResponsesFactory(OpenAIResponsesFactory):
- @classmethod
- def make_openai_client_for_responses(
- cls,
- model_handle: ModelHandle,
- *,
- backend: InferenceBackend,
- ) -> openai.AsyncOpenAI:
- if not PipelexHostedOpenAISdkVariant.is_responses(model_handle.sdk):
- msg = f"ModelHandle '{model_handle}' is not supported by '{cls.__name__}'"
- raise PipelexHostedFactoryError(msg)
-
- return openai.AsyncOpenAI(
- base_url=PipelexHostedFactory.get_base_url(backend=backend),
- # Auth travels in the service's own header, not in the OpenAI Authorization one. The SDK
- # has rejected an empty api_key since 2.34.0, so the slot holds a placeholder the
- # gateway never reads.
- api_key="unused-auth-via-hosted-header",
- # Tier 1 transport retry: set explicitly from config rather than inheriting the SDK
- # default, so a transport_max_retries override applies to this path too.
- max_retries=get_config().inference.transport_max_retries,
- default_headers=PipelexHostedFactory.make_auth_headers(backend=backend),
- )
-
- @override
- def make_extras(
- self, inference_model: InferenceModelSpec, *, inference_job: InferenceJobAbstract, output_desc: str
- ) -> tuple[dict[str, str], dict[str, Any]]:
- return PipelexHostedFactory.make_extras(inference_model=inference_model, inference_job=inference_job, output_desc=output_desc)
diff --git a/pipelex/providers/pipelex_hosted/pipelex_hosted_schemas.py b/pipelex/providers/pipelex_hosted/pipelex_hosted_schemas.py
deleted file mode 100644
index bd2002b1a..000000000
--- a/pipelex/providers/pipelex_hosted/pipelex_hosted_schemas.py
+++ /dev/null
@@ -1,89 +0,0 @@
-"""The wire shapes the hosted plugin sends and reads.
-
-Two groups, and they are owned by different sides.
-
-**The native-route requests** (`PipelexHostedExtractRequest`, `PipelexHostedSearchRequest`) are this plugin's
-half of a contract the *gateway* owns and freezes, in `src/pig/pipelex/schemas.ts`. They are written
-out field by field rather than derived from the runtime's job-params models, and that is the point:
-several fields of `ExtractJobParams` are deliberately absent from the contract and the gateway
-**refuses** them at any value, including their own defaults. A worker that reached for
-`model_dump()` would send `should_caption_images=false` and be refused; one that sent them and had
-them ignored would be told a parameter was honoured when it was dropped. Building the body
-explicitly is what makes the absence visible in this file rather than surprising at request time.
-
-**The image response** is Azure's, as the gateway forwards it.
-"""
-
-from __future__ import annotations
-
-from typing import Any
-
-from pydantic import BaseModel, ConfigDict, Field
-
-
-class PipelexHostedExtractInput(BaseModel):
- """Exactly one of the two is set; the gateway refuses neither-or-both."""
-
- document_uri: str | None = None
- image_uri: str | None = None
-
-
-class PipelexHostedExtractParams(BaseModel):
- """The extract parameters the contract *does* carry.
-
- `max_nb_images` keeps the runtime's own semantics — `None` unlimited, `0` none, `N` a per-page
- cap. `render_js` and `include_raw_html` are honoured by the web-fetch provider alone, and the
- gateway refuses a non-null value on a provider that cannot honour them.
- """
-
- max_nb_images: int | None = None
- render_js: bool | None = None
- include_raw_html: bool | None = None
-
-
-class PipelexHostedExtractRequest(BaseModel):
- model: str
- input: PipelexHostedExtractInput
- params: PipelexHostedExtractParams | None = None
-
-
-class PipelexHostedSearchRequest(BaseModel):
- """Flat, and with no `depth`: the model id carries it — `linkup/standard` versus `linkup/deep`."""
-
- model: str
- query: str
- include_images: bool | None = None
- include_inline_citations: bool | None = None
- max_results: int | None = None
- include_domains: list[str] | None = None
- exclude_domains: list[str] | None = None
- from_date: str | None = None
- to_date: str | None = None
- output_schema: dict[str, Any] | None = None
-
-
-class PipelexHostedImgGenAzureGptImageDatum(BaseModel):
- """One generated image.
-
- `b64_json` is optional here although Azure always sends it on a successful generation, so that a
- datum arriving without one gets the error it deserves — the image was filtered, which is the
- caller's prompt to change — rather than a parse failure blamed on the model.
- """
-
- model_config = ConfigDict(extra="ignore")
-
- b64_json: str | None = None
-
-
-class PipelexHostedImgGenAzureGptImage(BaseModel):
- """The Azure GPT Image response, as the gateway forwards it unchanged.
-
- `size` and `output_format` arrive as Azure wrote them and are what the runtime needs to build a
- `GeneratedImageRawDetails`; `data` carries the images themselves.
- """
-
- model_config = ConfigDict(extra="ignore")
-
- size: str = Field(description="Size of the image, as WIDTHxHEIGHT")
- output_format: str = Field(description="Output format of the image")
- data: list[PipelexHostedImgGenAzureGptImageDatum] = []
diff --git a/pipelex/providers/pipelex_hosted/pipelex_hosted_search_worker.py b/pipelex/providers/pipelex_hosted/pipelex_hosted_search_worker.py
deleted file mode 100644
index a0f666de1..000000000
--- a/pipelex/providers/pipelex_hosted/pipelex_hosted_search_worker.py
+++ /dev/null
@@ -1,168 +0,0 @@
-"""Web search over the Pipelex service's own route.
-
-Thin, like its extraction sibling, and for the same reason: ``POST /v1/pipelex/search`` answers with
-the search itself rather than with a chat completion whose message content is a JSON string that has
-to be decoded before it means anything.
-
-**No ``depth`` on the wire.** The model id carries it — ``linkup/standard`` versus ``linkup/deep`` —
-and a second source for a decision the gateway takes from one place is a source of disagreement, not
-of flexibility.
-
-**Usage arrives as searches and has to become tokens.** See ``pipelex_hosted_extract_worker`` for the
-whole of that reasoning; the failure it prevents is a cost of zero reported with no error at all.
-"""
-
-from __future__ import annotations
-
-from typing import TYPE_CHECKING, Any, cast
-
-from typing_extensions import override
-
-from pipelex.cogt.exceptions import InferenceErrorCategory, SdkTypeError
-from pipelex.cogt.inference.error_classification import UserAction, UserActionKind
-from pipelex.cogt.inference.error_render import InferenceErrorFamily
-from pipelex.cogt.search.search_worker_abstract import SearchWorkerAbstract
-from pipelex.cogt.search.structured_search_payload import extract_structured_search_payload
-from pipelex.cogt.usage.token_category import NbTokensByCategoryDict, TokenCategory
-from pipelex.core.stuffs.document_content import DocumentContent
-from pipelex.core.stuffs.search_result_content import SearchResultContent
-from pipelex.providers.pipelex_hosted.pipelex_hosted_constants import PIPELEX_HOSTED_SEARCH_ROUTE
-from pipelex.providers.pipelex_hosted.pipelex_hosted_exceptions import PipelexHostedSearchEmptyResultError, PipelexHostedSearchResponseError
-from pipelex.providers.pipelex_hosted.pipelex_hosted_extract_worker import PIPELEX_HOSTED_UNIT_TOKENS
-from pipelex.providers.pipelex_hosted.pipelex_hosted_native_client import PipelexHostedNativeClient
-from pipelex.providers.pipelex_hosted.pipelex_hosted_schemas import PipelexHostedSearchRequest
-
-if TYPE_CHECKING:
- from pipelex.cogt.model_backends.model_spec import InferenceModelSpec
- from pipelex.cogt.search.search_job import SearchJob
- from pipelex.reporting.reporting_protocol import ReportingProtocol
- from pipelex.tools.typing.pydantic_utils import BaseModelTypeVar
-
-
-class PipelexHostedSearchWorker(SearchWorkerAbstract):
- def __init__(
- self,
- sdk_instance: Any,
- inference_model: InferenceModelSpec,
- reporting_delegate: ReportingProtocol | None = None,
- ):
- super().__init__(inference_model=inference_model, reporting_delegate=reporting_delegate)
-
- if not isinstance(sdk_instance, PipelexHostedNativeClient):
- msg = f"Provided search sdk_instance for {self.__class__.__name__} is not a PipelexHostedNativeClient: it's a '{type(sdk_instance)}'"
- raise SdkTypeError(msg)
-
- self.client: PipelexHostedNativeClient = sdk_instance
-
- @override
- async def _search_sourced_answer(
- self,
- search_job: SearchJob,
- ) -> SearchResultContent:
- response_body = await self._call_search(search_job=search_job, output_schema=None)
-
- answer: Any = response_body.get("answer")
- if not isinstance(answer, str):
- msg = f"The search response for model '{self.inference_model.name}' carries no answer"
- raise PipelexHostedSearchResponseError(
- msg,
- error_category=InferenceErrorCategory.UNKNOWN,
- user_action=UserAction(
- kind=UserActionKind.CHANGE_MODEL,
- detail="The gateway returned a malformed search response — try a different model",
- ),
- provider_metadata=None,
- )
-
- raw_sources: Any = response_body.get("sources") or []
- sources = [
- DocumentContent(
- title=source["name"],
- url=source["url"],
- public_url=source["url"],
- snippet=source["snippet"],
- mime_type="text/html",
- )
- for source in cast("list[dict[str, Any]]", raw_sources)
- ]
-
- return SearchResultContent(answer=answer, sources=sources)
-
- @override
- async def _search_structured(
- self,
- search_job: SearchJob,
- *,
- schema: type[BaseModelTypeVar],
- ) -> dict[str, Any]:
- response_body = await self._call_search(search_job=search_job, output_schema=schema.model_json_schema())
-
- # The route answers with a `{data, sources}` envelope, and the contract of a structured
- # search is the payload alone — it is validated against the caller's output structure class,
- # which has nowhere to put sources. The envelope is recognised *structurally* rather than
- # demanded, so the day the gateway stops asking for sources this worker keeps working on the
- # bare payload it then returns.
- #
- # `usage` is dropped first, and that line is load-bearing. On this route usage sits *beside*
- # the envelope rather than inside a chat completion the way the costume put it, and the
- # recognition is by the key set being exactly {data, sources} — so leaving a third key there
- # makes the whole response look like the payload, which then validates against an output
- # class whose fields have defaults and returns an all-defaults object with no error
- # anywhere. Usage has already been recorded by the time this runs.
- envelope = {key: value for key, value in response_body.items() if key != "usage"}
- payload = extract_structured_search_payload(response=envelope, schema=schema)
- if payload is not None:
- return payload
- # The response was an object but carried no structured payload: the search ran and found
- # nothing to fill the output structure with. That is the query's fault, not the model's.
- msg = f"The structured search for model '{self.inference_model.name}' returned an empty structured result"
- raise PipelexHostedSearchEmptyResultError(
- msg,
- error_category=InferenceErrorCategory.UNKNOWN,
- user_action=UserAction(
- kind=UserActionKind.CHANGE_INPUT,
- detail="The search found nothing to fill your output structure — try a broader query or a wider date range",
- ),
- provider_metadata=None,
- )
-
- async def _call_search(self, *, search_job: SearchJob, output_schema: dict[str, Any] | None) -> dict[str, Any]:
- job_params = search_job.job_params
- search_setting = job_params.search_setting
- request = PipelexHostedSearchRequest(
- model=self.inference_model.model_id,
- query=search_job.query,
- include_images=search_setting.include_images,
- include_inline_citations=search_setting.include_inline_citations,
- max_results=search_setting.max_results,
- include_domains=job_params.include_domains,
- exclude_domains=job_params.exclude_domains,
- from_date=job_params.from_date,
- to_date=job_params.to_date,
- output_schema=output_schema,
- )
- response_body = await self.client.post_json(
- route=PIPELEX_HOSTED_SEARCH_ROUTE,
- body=request.model_dump(exclude_none=True),
- family=InferenceErrorFamily.SEARCH,
- inference_model=self.inference_model,
- job_metadata=search_job.job_metadata,
- )
- self._record_usage(response_body=response_body, search_job=search_job)
- return response_body
-
- def _record_usage(self, *, response_body: dict[str, Any], search_job: SearchJob) -> None:
- search_tokens_usage = search_job.job_report.search_tokens_usage
- if not search_tokens_usage:
- return
- usage: object = response_body.get("usage")
- if not isinstance(usage, dict):
- return
- nb_searches: object = cast("dict[str, Any]", usage).get("searches")
- if not isinstance(nb_searches, int):
- return
- nb_tokens: NbTokensByCategoryDict = {
- TokenCategory.INPUT: nb_searches * PIPELEX_HOSTED_UNIT_TOKENS,
- TokenCategory.OUTPUT: nb_searches * PIPELEX_HOSTED_UNIT_TOKENS,
- }
- search_tokens_usage.nb_tokens_by_category = nb_tokens
diff --git a/pipelex/system/job_metadata.py b/pipelex/system/job_metadata.py
index 4c5066827..b546526f4 100644
--- a/pipelex/system/job_metadata.py
+++ b/pipelex/system/job_metadata.py
@@ -168,7 +168,7 @@ class RunMetadata(BaseModel):
# The opaque labels the host attaches to this run. Never read by name;
# telemetry forwards the whole mapping as the groups of each capture, and
- # the hosted dialect forwards it in its `x-pipelex-metadata` header
+ # an inference backend plugin may forward it to the service it calls
# — see `pipelex.system.run_extras` for why the host's own concepts
# (organization, tenant, plan tier) deliberately do not cross this boundary,
# and for the charset and the size bound.
diff --git a/pipelex/system/run_extras.py b/pipelex/system/run_extras.py
index feb8d95f4..676fd5bae 100644
--- a/pipelex/system/run_extras.py
+++ b/pipelex/system/run_extras.py
@@ -19,15 +19,15 @@ is the backend that supports grouping. So whatever is put here is a live group
key in those projects and a span attribute on every OpenTelemetry export, and the
bounds below are shaped by that consumer.
-The Pipelex service is the other reader. Every call the hosted
-dialect makes carries the mapping, whole, in its `x-pipelex-metadata` header,
-beside the runtime's own ids for the run and the step, so the service can
-attribute the call's spend and log it (`pipelex.providers.pipelex_hosted.pipelex_hosted_metadata`).
-The runtime's ids win when an extras key collides with one of them — every one of
-their names (`user_id`, `pipeline_run_id`, `pipe_run_id`, `pipe_code`,
+An inference backend plugin may be the other reader: the mapping rides the job
+metadata of every inference call, so a plugin calling a service its operator runs
+can forward it, beside the runtime's own ids for the run and the step, for that
+service to attribute the call's spend. Such a plugin must let the runtime's ids win
+when an extras key collides with one of them — every one of their names
+(`user_id`, `pipeline_run_id`, `pipe_run_id`, `pipe_code`,
`content_generation_job_id`) fits the key charset below — because this mapping is
-caller data and must not be able to restate whose run it is. No other inference
-path sends it: a vendor reached directly has no use for a host's labels.
+caller data and must not be able to restate whose run it is. No inference path
+Pipelex ships sends it: a vendor reached directly has no use for a host's labels.
The hosted Pipelex platform fills it with `{"org_id": "<org_id>"}`, plus
`"api_key_id"` on a call made with an API key, but nothing here knows or checks
diff --git a/subject_grants.toml b/subject_grants.toml
index c7da0cfdc..708f660b3 100644
--- a/subject_grants.toml
+++ b/subject_grants.toml
@@ -5104,62 +5104,6 @@ rationale = "Factory from source: builds the result from the extra_config; singl
param = "registrar"
rationale = "Plugin protocol register: the registrar is the sole sink the plugin populates."
-["pipelex/providers/pipelex_hosted/pipelex_hosted_completions_factory.py::PipelexHostedCompletionsFactory.make_openai_client_for_completions"]
-param = "model_handle"
-rationale = "Factory from source: builds the result from the model_handle; single operand."
-
-["pipelex/providers/pipelex_hosted/pipelex_hosted_constants.py::PipelexHostedOpenAISdkVariant.is_completions"]
-param = "sdk"
-rationale = "Predicate on the sdk; single operand."
-
-["pipelex/providers/pipelex_hosted/pipelex_hosted_constants.py::PipelexHostedOpenAISdkVariant.is_responses"]
-param = "sdk"
-rationale = "Predicate on the sdk; single operand."
-
-["pipelex/providers/pipelex_hosted/pipelex_hosted_error_metadata.py::extract_pipelex_hosted_metadata"]
-param = "exc"
-rationale = "Extracts from the exc; single operand."
-
-["pipelex/providers/pipelex_hosted/pipelex_hosted_factory.py::PipelexHostedFactory._make_gemini_image_config"]
-param = "taxonomy"
-rationale = "Builds the image_config block from the Gemini aspect-ratio taxonomy; the job params and model name stay keyword-only."
-
-["pipelex/providers/pipelex_hosted/pipelex_hosted_factory.py::PipelexHostedFactory.get_api_key"]
-param = "backend"
-rationale = "Derives the value from the backend config; single operand."
-
-["pipelex/providers/pipelex_hosted/pipelex_hosted_factory.py::PipelexHostedFactory.get_base_url"]
-param = "backend"
-rationale = "Derives the value from the backend config; single operand."
-
-["pipelex/providers/pipelex_hosted/pipelex_hosted_factory.py::PipelexHostedFactory.get_origin"]
-param = "backend"
-rationale = "Derives the value from the backend config; single operand."
-
-["pipelex/providers/pipelex_hosted/pipelex_hosted_factory.py::PipelexHostedFactory.is_debug_enabled"]
-param = "backend"
-rationale = "Predicate: reports whether debug logging is enabled for the backend; single operand."
-
-["pipelex/providers/pipelex_hosted/pipelex_hosted_factory.py::PipelexHostedFactory.make_auth_headers"]
-param = "backend"
-rationale = "Factory from source: builds the result from the backend; single operand."
-
-["pipelex/providers/pipelex_hosted/pipelex_hosted_factory.py::PipelexHostedFactory.make_extras"]
-param = "inference_model"
-rationale = "Factory from source: builds the result from the inference_model; single operand."
-
-["pipelex/providers/pipelex_hosted/pipelex_hosted_factory.py::PipelexHostedFactory.make_portkey_client"]
-param = "backend"
-rationale = "Factory from source: builds the result from the backend; single operand."
-
-["pipelex/providers/pipelex_hosted/pipelex_hosted_plugin.py::PipelexHostedPlugin.register"]
-param = "registrar"
-rationale = "Plugin protocol register: the registrar is the sole sink the plugin populates."
-
-["pipelex/providers/pipelex_hosted/pipelex_hosted_responses_factory.py::PipelexHostedResponsesFactory.make_openai_client_for_responses"]
-param = "model_handle"
-rationale = "Factory from source: builds the result from the model_handle; single operand."
-
["pipelex/providers/portkey/portkey_completions_factory.py::PortkeyCompletionsFactory.make_portkey_openai_client_for_completions"]
param = "model_handle"
rationale = "Factory from source: builds the result from the model_handle; single operand."
diff --git a/tests/data/errors/error_identity.txt b/tests/data/errors/error_identity.txt
index d58f23404..14c085131 100644
--- a/tests/data/errors/error_identity.txt
+++ b/tests/data/errors/error_identity.txt
@@ -249,13 +249,6 @@ PipelexBridgeDispatchError | Pipelex bridge dispatch | https://docs.pipelex.com/
PipelexCLIError | Pipelex CLI | https://docs.pipelex.com/latest/errors/pipelex-cli-error/
PipelexConfigError | Pipelex config | https://docs.pipelex.com/latest/errors/pipelex-config-error/
PipelexError | Pipelex error | https://docs.pipelex.com/latest/errors/pipelex-error/
-PipelexHostedCredentialsError | Inference backend credentials missing | https://docs.pipelex.com/latest/errors/inference-backend-credentials-error/
-PipelexHostedEndpointError | Inference backend endpoint missing | https://docs.pipelex.com/latest/errors/inference-backend-credentials-error/
-PipelexHostedError | Inference backend error | https://docs.pipelex.com/latest/errors/cogt-error/
-PipelexHostedExtractResponseError | Extract response unreadable | https://docs.pipelex.com/latest/errors/extract-job-failure-error/
-PipelexHostedFactoryError | Inference client setup error | https://docs.pipelex.com/latest/errors/cogt-error/
-PipelexHostedSearchEmptyResultError | Search returned no result | https://docs.pipelex.com/latest/errors/search-job-failure-error/
-PipelexHostedSearchResponseError | Search response unreadable | https://docs.pipelex.com/latest/errors/search-job-failure-error/
PipelexRuntimeBridgeError | Pipelex runtime bridge | https://docs.pipelex.com/latest/errors/pipelex-runtime-bridge-error/
PipelexSetupError | Pipelex setup | https://docs.pipelex.com/latest/errors/pipelex-setup-error/
PipelexUnexpectedError | Unexpected internal error | https://docs.pipelex.com/latest/errors/pipelex-unexpected-error/
diff --git a/tests/data/inference/previous_release_kit/backends.toml b/tests/data/inference/previous_release_kit/backends.toml
index 28a5a7777..501d4cd80 100644
--- a/tests/data/inference/previous_release_kit/backends.toml
+++ b/tests/data/inference/previous_release_kit/backends.toml
@@ -15,13 +15,13 @@ display_name = "⭐ Pipelex Gateway"
enabled = true # Enable after accepting terms via `pipelex init config`
api_key = "${PIPELEX_GATEWAY_API_KEY}"
-# Pipelex Manifold is a closed private beta: leave it off unless you have been invited.
-[pipelex_manifold]
-display_name = "Pipelex Manifold (private beta)"
+# A private beta: leave it off unless you have been invited.
+[retired_preview]
+display_name = "Retired preview (private beta)"
enabled = false
-endpoint = "${PIPELEX_MANIFOLD_ENDPOINT}"
-api_key = "${PIPELEX_MANIFOLD_API_KEY}"
-model_specs_section = "manifold_model_specs"
+endpoint = "${RETIRED_PREVIEW_ENDPOINT}"
+api_key = "${RETIRED_PREVIEW_API_KEY}"
+model_specs_section = "retired_preview_model_specs"
auth_header = "x-pipelex-api-key"
[anthropic]
diff --git a/tests/data/inference/previous_release_kit/routing_profiles.toml b/tests/data/inference/previous_release_kit/routing_profiles.toml
index 25619b1ee..9450ee6a8 100644
--- a/tests/data/inference/previous_release_kit/routing_profiles.toml
+++ b/tests/data/inference/previous_release_kit/routing_profiles.toml
@@ -33,16 +33,16 @@ default = "pipelex_gateway"
[profiles.all_pipelex_gateway.optional_routes]
"jev-*" = "typesafe"
-# The same model names, served by the Pipelex-operated inference service instead. Switching between
+# The same model names, served by the preview backend instead. Switching between
# this profile and the one above needs no other edit: a model's wire id and sdk are per-backend, so
# decks, aliases and presets keep naming the same handles.
-[profiles.all_pipelex_manifold]
-description = "Use Pipelex Manifold (private beta) for all its supported models"
-default = "pipelex_manifold"
+[profiles.all_retired_preview]
+description = "Use the retired preview backend (private beta) for all its supported models"
+default = "retired_preview"
# Judgment models are brought by you rather than served by Pipelex, so they go to their own backend
# whenever it is enabled. An optional route is inert while its backend is disabled.
-[profiles.all_pipelex_manifold.optional_routes]
+[profiles.all_retired_preview.optional_routes]
"jev-*" = "typesafe"
[profiles.all_anthropic]
diff --git a/tests/e2e/pipelex/cli/test_migrate_commands.py b/tests/e2e/pipelex/cli/test_migrate_commands.py
index 71346bdea..5315953bb 100644
--- a/tests/e2e/pipelex/cli/test_migrate_commands.py
+++ b/tests/e2e/pipelex/cli/test_migrate_commands.py
@@ -1146,8 +1146,8 @@ class TestAStaleTelemetryFileIsMigratedNotReset:
# A backend file earlier kits shipped, whose name matches the main configuration's `pipelex_*.toml` glob.
-LEGACY_PREFIXED_BACKEND_FILE_NAME = "pipelex_manifold.toml"
-LEGACY_PREFIXED_BACKEND_FILE_CONTENT = "# Per-model overrides for the Pipelex Manifold backend.\n"
+LEGACY_PREFIXED_BACKEND_FILE_NAME = "pipelex_gateway.toml"
+LEGACY_PREFIXED_BACKEND_FILE_CONTENT = "# Per-model overrides for the Pipelex Gateway backend.\n"
class TestAStaleBackendDirectory:
@@ -1156,7 +1156,7 @@ class TestAStaleBackendDirectory:
Everything else in this module is planted on a file that sits *directly* in a configuration
directory. These files do not: they are the reason the walk learned to enter a subdirectory at
all, and the reason a file is claimed by `(directory, name)` rather than by name — earlier kits
- shipped a `pipelex_manifold.toml` in there, which the main configuration's `pipelex_*.toml` glob
+ shipped a `pipelex_gateway.toml` in there, which the main configuration's `pipelex_*.toml` glob
would otherwise have claimed. It is planted here for that reason, untouched, and the assertions say so.
What a boot *says* is not asserted here and cannot be: the probe is `pipelex-agent`, which cuts
@@ -1168,7 +1168,7 @@ class TestAStaleBackendDirectory:
"""Everything in and beside the directory that no migration may rewrite.
Excluded by name rather than by extension, and the difference is the whole point of this
- class: earlier kits shipped `pipelex_manifold.toml` in this directory, and machines set up with
+ class: earlier kits shipped `pipelex_gateway.toml` in this directory, and machines set up with
them still carry it, so it is planted here as they left it. The main configuration's
`pipelex_*.toml` glob would claim it by name alone, so it is the one file a walk that forgot
about directories would rewrite. An extension filter dropped it — and every other `.toml` in
diff --git a/tests/unit/pipelex/cogt/img_gen/test_img_gen_worker_config_faults.py b/tests/unit/pipelex/cogt/img_gen/test_img_gen_worker_config_faults.py
index 916f35b08..09728eeba 100644
--- a/tests/unit/pipelex/cogt/img_gen/test_img_gen_worker_config_faults.py
+++ b/tests/unit/pipelex/cogt/img_gen/test_img_gen_worker_config_faults.py
@@ -14,7 +14,6 @@ import pytest
from fal_client import AsyncClient as FalAsyncClient
from huggingface_hub import AsyncInferenceClient
from openai import AsyncOpenAI
-from portkey_ai import AsyncPortkey
from pipelex.cogt.exceptions import ImgGenParameterError, InferenceErrorCategory
from pipelex.cogt.img_gen.img_gen_model_rules import ImgGenArgTopic
@@ -26,7 +25,6 @@ from pipelex.providers.azure_rest.azure_img_gen_worker import AzureImgGenWorker
from pipelex.providers.fal.fal_img_gen_worker import FalImgGenWorker
from pipelex.providers.huggingface.huggingface_img_gen_worker import HuggingFaceImgGenWorker
from pipelex.providers.openai.openai_img_gen_worker import OpenAIImgGenWorker
-from pipelex.providers.pipelex_hosted.pipelex_hosted_img_gen_worker import PipelexHostedImgGenWorker
from tests.unit.pipelex.cogt.img_gen.conftest import make_img_gen_job
if TYPE_CHECKING:
@@ -67,11 +65,6 @@ def _make_worker(mocker: MockerFixture, *, worker_kind: str, rules: ImgGenModelR
return OpenAIImgGenWorker(
sdk_instance=mocker.MagicMock(spec=AsyncOpenAI), inference_model=_model(backend_name="openai", sdk="openai_img_gen", rules=rules)
)
- case "manifold":
- return PipelexHostedImgGenWorker(
- sdk_instance=mocker.MagicMock(spec=AsyncPortkey),
- inference_model=_model(backend_name="pipelex_manifold", sdk="manifold_img_gen", rules=rules),
- )
case "fal":
return FalImgGenWorker(
sdk_instance=mocker.MagicMock(spec=FalAsyncClient), inference_model=_model(backend_name="fal", sdk="fal", rules=rules)
@@ -101,14 +94,12 @@ class TestImgGenWorkerConfigFaults:
("worker_kind", "rules", "error_match"),
[
("openai", None, "does not have rules configured"),
- ("manifold", None, "does not have rules configured"),
("fal", None, "does not have rules configured"),
("huggingface", None, "does not have rules configured"),
("azure", None, "does not have rules configured"),
("fal", PROMPT_ONLY_RULES, "must include a 'model_choice' entry"),
("huggingface", PROMPT_ONLY_RULES, "must include a 'model_choice' entry"),
("openai", UNKNOWN_ASPECT_RATIO_RULES, "unknown aspect_ratio taxonomy 'gemini_9_turbo'"),
- ("manifold", UNKNOWN_ASPECT_RATIO_RULES, "unknown aspect_ratio taxonomy 'gemini_9_turbo'"),
("azure", UNKNOWN_ASPECT_RATIO_RULES, "unknown aspect_ratio taxonomy 'gemini_9_turbo'"),
("openai", UNKNOWN_PROMPT_RULES, "unknown prompt taxonomy 'weird'"),
("fal", UNKNOWN_PROMPT_RULES, "unknown prompt taxonomy 'weird'"),
diff --git a/tests/unit/pipelex/cogt/img_gen/test_img_gen_worker_factory.py b/tests/unit/pipelex/cogt/img_gen/test_img_gen_worker_factory.py
index 67a883924..51f037ec9 100644
--- a/tests/unit/pipelex/cogt/img_gen/test_img_gen_worker_factory.py
+++ b/tests/unit/pipelex/cogt/img_gen/test_img_gen_worker_factory.py
@@ -51,12 +51,10 @@ def build_builtin_inference_backend_registry() -> InferenceBackendRegistry:
FACTORY_MODULE = "pipelex.cogt.img_gen.img_gen_worker_factory"
-PIPELEX_HOSTED_CLIENT = "pipelex.providers.pipelex_hosted.pipelex_hosted_factory.PipelexHostedFactory.make_portkey_client"
OPENAI_CLIENT = "pipelex.providers.openai.openai_client_factory.OpenAIClientFactory.make_openai_client"
GOOGLE_CLIENT = "pipelex.providers.google.google_factory.GoogleFactory.make_google_client"
HUGGINGFACE_PROVIDER = "pipelex.providers.huggingface.huggingface_factory.HuggingFaceFactory.make_huggingface_inference_provider"
-PIPELEX_HOSTED_WORKER = "pipelex.providers.pipelex_hosted.pipelex_hosted_img_gen_worker.PipelexHostedImgGenWorker"
FAL_WORKER = "pipelex.providers.fal.fal_img_gen_worker.FalImgGenWorker"
HUGGINGFACE_WORKER = "pipelex.providers.huggingface.huggingface_img_gen_worker.HuggingFaceImgGenWorker"
OPENAI_WORKER = "pipelex.providers.openai.openai_img_gen_worker.OpenAIImgGenWorker"
@@ -110,7 +108,6 @@ class TestImgGenWorkerFactory:
@pytest.mark.parametrize(
("sdk", "client_target", "worker_target", "factory_cls", "http_flag", "passes_model_handle"),
[
- pytest.param("manifold_img_gen", PIPELEX_HOSTED_CLIENT, PIPELEX_HOSTED_WORKER, None, None, False, id="manifold_img_gen"),
pytest.param("openai_img_gen", OPENAI_CLIENT, OPENAI_WORKER, None, None, True, id="openai_img_gen"),
pytest.param("blackboxai_img_gen", OPENAI_CLIENT, COMPLETIONS_WORKER, BlackboxaiCompletionsFactory, True, True, id="blackboxai_img_gen"),
pytest.param("openrouter_img_gen", OPENAI_CLIENT, COMPLETIONS_WORKER, OpenRouterCompletionsFactory, True, True, id="openrouter_img_gen"),
@@ -229,12 +226,12 @@ class TestImgGenWorkerFactory:
"""A pre-seeded registry entry is reused: the client factory must not be called."""
backend = make_backend()
registry = patch_hub_getters(mocker, backend=backend)
- inference_model = make_img_gen_model_spec(sdk="manifold_img_gen")
+ inference_model = make_img_gen_model_spec(sdk="openai_img_gen")
model_handle = ModelHandle.make_for_inference_model(inference_model=inference_model)
cached_client = mocker.MagicMock(name="cached_client")
registry.set(model_handle=model_handle, sdk_instance=cached_client)
- client_factory_mock = mocker.patch(PIPELEX_HOSTED_CLIENT)
- worker_cls_mock = mocker.patch(PIPELEX_HOSTED_WORKER)
+ client_factory_mock = mocker.patch(OPENAI_CLIENT)
+ worker_cls_mock = mocker.patch(OPENAI_WORKER)
ImgGenWorkerFactory.make_img_gen_worker(inference_model=inference_model)
diff --git a/tests/unit/pipelex/cogt/inference/test_model_not_allowed.py b/tests/unit/pipelex/cogt/inference/test_model_not_allowed.py
index 479ef388d..635a5d004 100644
--- a/tests/unit/pipelex/cogt/inference/test_model_not_allowed.py
+++ b/tests/unit/pipelex/cogt/inference/test_model_not_allowed.py
@@ -50,7 +50,6 @@ from pipelex.cogt.inference.error_classify import classify_inference_error
from pipelex.cogt.inference.error_render import InferenceErrorFamily, render_inference_error
from pipelex.cogt.inference.provider_name import ProviderName
from pipelex.pipe_run.exceptions import PipeRouterError
-from pipelex.providers.pipelex_hosted.pipelex_hosted_error_metadata import extract_pipelex_hosted_metadata
from pipelex.system.pipe_run_mode import PipeRunMode
if TYPE_CHECKING:
@@ -120,13 +119,6 @@ def _as_the_anthropic_sdk_raises_it(*, status_code: int, body: dict[str, Any]) -
return client._make_status_error_from_response(response) # ruff: ignore[private-member-access] # pyright: ignore[reportPrivateUsage]
-def _as_plain_httpx_raises_it(*, status_code: int, body: dict[str, Any]) -> BaseException:
- """The Pipelex service's native ``/v1/pipelex/*`` routes, which the runtime calls over plain ``httpx``."""
- request = httpx.Request("POST", f"{_ORIGIN}/v1/pipelex/extract")
- response = httpx.Response(status_code=status_code, request=request, json=body)
- return httpx.HTTPStatusError(f"Client error '{status_code}'", request=request, response=response)
-
-
def _envelope(code: str | None, *, status_code: int = 412, provider: ProviderName = ProviderName.GATEWAY) -> ProviderErrorMetadata:
return ProviderErrorMetadata(
provider=provider,
@@ -167,7 +159,7 @@ class TestTheCodeIsRecognized:
@pytest.mark.parametrize(
"code",
- [None, "pig-01", "invalid_request_error", "model_not_found", "model_not_allowed", "MODEL_NOT_ALLOWED_ERROR", ""],
+ [None, "rate_limit_exceeded", "invalid_request_error", "model_not_found", "model_not_allowed", "MODEL_NOT_ALLOWED_ERROR", ""],
)
def test_any_other_code_is_not_a_model_not_allowed_refusal(self, code: str | None) -> None:
assert _envelope(code).is_model_not_allowed is False
@@ -185,7 +177,6 @@ class TestTheCodeSurvivesEveryExtractHop:
pytest.param(_as_the_openai_sdk_raises_it, extract_openai_metadata, id="openai-substrate"),
pytest.param(_as_the_anthropic_sdk_raises_it, extract_anthropic_metadata, id="anthropic-driver"),
pytest.param(_as_the_portkey_sdk_raises_it, extract_gateway_metadata, id="portkey-substrate"),
- pytest.param(_as_plain_httpx_raises_it, extract_pipelex_hosted_metadata, id="native-routes-httpx"),
],
)
def test_the_refusal_through_every_hop(
@@ -195,9 +186,7 @@ class TestTheCodeSurvivesEveryExtractHop:
) -> None:
"""The substrate's own envelope, at 412, through each SDK's own factory.
- Its code sits in ``type`` with ``code`` null. The two vendor-facing hops read
- ``type`` first; the two Pipelex-service hops read ``code`` first and fall back
- to ``type``, which is the fallback this case exercises.
+ Its code sits in ``type`` with ``code`` null, so every hop must find it there.
"""
exc = raise_it(status_code=412, body=_MODEL_NOT_ALLOWED_BODY)
diff --git a/tests/unit/pipelex/cogt/model_backends/test_backend_boot_tolerance.py b/tests/unit/pipelex/cogt/model_backends/test_backend_boot_tolerance.py
index c65d81008..19c47deed 100644
--- a/tests/unit/pipelex/cogt/model_backends/test_backend_boot_tolerance.py
+++ b/tests/unit/pipelex/cogt/model_backends/test_backend_boot_tolerance.py
@@ -64,10 +64,11 @@ api_key = "sk-not-a-real-key-either"
# the current kit no longer carries: a missing per-backend file is fatal for an enabled backend.
PREVIOUS_RELEASE_KIT_DIR = Path("tests/data/inference/previous_release_kit")
-# The disabled table in the previous kit: its variables are never set here, so a load that substituted
-# them before checking `enabled` would fail the strict case.
-PREVIOUS_RELEASE_DISABLED_BACKEND = "pipelex_manifold"
-PREVIOUS_RELEASE_DISABLED_BACKEND_VARS = ("PIPELEX_MANIFOLD_ENDPOINT", "PIPELEX_MANIFOLD_API_KEY")
+# The disabled table in the previous kit, a backend the current kit no longer carries, under a neutral
+# name: its variables are never set here, so a load that substituted them before checking `enabled`
+# would fail the strict case, and its keys the blueprint does not define must not be validated either.
+PREVIOUS_RELEASE_DISABLED_BACKEND = "retired_preview"
+PREVIOUS_RELEASE_DISABLED_BACKEND_VARS = ("RETIRED_PREVIEW_ENDPOINT", "RETIRED_PREVIEW_API_KEY")
# The enabled table in the previous kit whose per-backend file declares no model, and the line enabling it.
PREVIOUS_RELEASE_EMPTY_ENABLED_BACKEND = "pipelex_gateway"
@@ -266,7 +267,7 @@ class TestThePreviousReleaseKit:
As that release left it, its `backends.toml` enables the Pipelex Gateway over a comment-only file and
its active routing profile sends every model there: that is refused, naming the backend, rather than
booted with every model silently missing from the deck. Once the user disables that table and picks
- another profile, as the changelog says, the rest loads: the disabled table of the hosted backend, which carries a key
+ another profile, as the changelog says, the rest loads: the disabled table of a backend the current kit no longer carries, which carries a key
the backend blueprint does not define, is skipped before its variables are substituted or its file is
read, and only the active routing profile is validated against the enabled backends.
"""
diff --git a/tests/unit/pipelex/cogt/model_backends/test_backend_retired_model_specs_section.py b/tests/unit/pipelex/cogt/model_backends/test_backend_retired_model_specs_section.py
index 38ffaee4b..419e2ac99 100644
--- a/tests/unit/pipelex/cogt/model_backends/test_backend_retired_model_specs_section.py
+++ b/tests/unit/pipelex/cogt/model_backends/test_backend_retired_model_specs_section.py
@@ -9,10 +9,10 @@ from pipelex.cogt.model_backends.backend_library import InferenceBackendLibrary
from pipelex.tools.secrets.env_secrets_provider import EnvSecretsProvider
BACKENDS_TOML_TEMPLATE = """
-[pipelex_manifold]
-display_name = "Pipelex"
+[retired_preview]
+display_name = "Retired preview"
enabled = {enabled}
-model_specs_section = "manifold_model_specs"
+model_specs_section = "retired_preview_model_specs"
api_key = "sk-not-a-real-key"
"""
@@ -23,7 +23,7 @@ class TestBackendRetiredModelSpecsSection:
def _load(self, *, tmp_path: Path, enabled: bool, lenient: bool = False) -> InferenceBackendLibrary:
backends_dir = tmp_path / "backends"
backends_dir.mkdir()
- (backends_dir / "pipelex_manifold.toml").write_text(COMMENT_ONLY_BACKEND_TOML)
+ (backends_dir / "retired_preview.toml").write_text(COMMENT_ONLY_BACKEND_TOML)
base_path = tmp_path / "backends.toml"
base_path.write_text(BACKENDS_TOML_TEMPLATE.format(enabled=str(enabled).lower()))
library = InferenceBackendLibrary.make_empty()
@@ -41,9 +41,9 @@ class TestBackendRetiredModelSpecsSection:
self._load(tmp_path=tmp_path, enabled=True, lenient=lenient)
message = str(refused.value)
- assert "pipelex_manifold" in message
+ assert "retired_preview" in message
assert "model_specs_section" in message
- assert "backends/pipelex_manifold.toml" in message
+ assert "backends/retired_preview.toml" in message
def test_a_disabled_backend_naming_it_is_skipped(self, tmp_path: Path) -> None:
library = self._load(tmp_path=tmp_path, enabled=False)
diff --git a/tests/unit/pipelex/cogt/model_routing/test_routing_profile_optional_routes.py b/tests/unit/pipelex/cogt/model_routing/test_routing_profile_optional_routes.py
index e2a2497be..08c88f915 100644
--- a/tests/unit/pipelex/cogt/model_routing/test_routing_profile_optional_routes.py
+++ b/tests/unit/pipelex/cogt/model_routing/test_routing_profile_optional_routes.py
@@ -70,11 +70,11 @@ class TestRoutingProfileOptionalRoutes:
"""`jev-*` sends every versioned judgment model to its backend while that backend is enabled."""
routing_profile = RoutingProfile(
name="test_profile",
- default="pipelex_manifold",
+ default="anthropic",
optional_routes={"jev-*": "typesafe"},
)
- result = routing_profile.get_backend_match_for_model(enabled_backends=["pipelex_manifold", "typesafe"], model_name="jev-1.13.0")
+ result = routing_profile.get_backend_match_for_model(enabled_backends=["anthropic", "typesafe"], model_name="jev-1.13.0")
assert result is not None
assert result.backend_name == "typesafe"
@@ -90,12 +90,12 @@ class TestRoutingProfileOptionalRoutes:
"""
routing_profile = RoutingProfile(
name="test_profile",
- default="pipelex_manifold",
+ default="anthropic",
routes={"gpt-*": "openai"},
optional_routes={"jev-*": "typesafe"},
)
- routing_profile.get_backend_match_for_model(enabled_backends=["pipelex_manifold", "openai", "typesafe"], model_name="jev-1.13.0")
+ routing_profile.get_backend_match_for_model(enabled_backends=["anthropic", "openai", "typesafe"], model_name="jev-1.13.0")
assert routing_profile.routes == {"gpt-*": "openai"}
assert routing_profile.optional_routes == {"jev-*": "typesafe"}
diff --git a/tests/unit/pipelex/migration/test_migration_run.py b/tests/unit/pipelex/migration/test_migration_run.py
index 65bf0e4e5..f4cd6462e 100644
--- a/tests/unit/pipelex/migration/test_migration_run.py
+++ b/tests/unit/pipelex/migration/test_migration_run.py
@@ -92,17 +92,17 @@ class TestWhichDirectoriesAreWalked:
class TestTheWalkIsNotRecursive:
"""A subdirectory of a configuration directory holds a different kind of thing.
- The specimen is real and it is the reason this is pinned rather than assumed:
- `.pipelex/inference/backends/pipelex_manifold.toml` matches the `pipelex-config` tier glob
+ The specimen is a file earlier kits shipped, which machines set up with them still carry, and it is
+ the reason this is pinned rather than assumed: `.pipelex/inference/backends/pipelex_gateway.toml` matches the `pipelex-config` tier glob
`pipelex_*.toml` exactly, and is an inference backend definition rather than a main-configuration
tier file. The walk *does* reach it now, because `inference/backends/` has a surface of its own —
which makes the directory half of the claim rule load-bearing rather than academic: get it wrong
and the main configuration's ledger is replayed over a backend definition and rewrites it.
"""
- SPECIMEN = Path("inference") / "backends" / "pipelex_manifold.toml"
+ SPECIMEN = Path("inference") / "backends" / "pipelex_gateway.toml"
- def test_the_real_manifold_backend_file_is_claimed_by_its_own_directorys_surface(self, tmp_path: Path) -> None:
+ def test_a_legacy_gateway_backend_file_is_claimed_by_its_own_directorys_surface(self, tmp_path: Path) -> None:
specimen = tmp_path / self.SPECIMEN
specimen.parent.mkdir(parents=True)
specimen.write_text("", encoding="utf-8")
diff --git a/tests/unit/pipelex/migration/test_surface_directories.py b/tests/unit/pipelex/migration/test_surface_directories.py
index 3ddfbb862..cfb2a1e53 100644
--- a/tests/unit/pipelex/migration/test_surface_directories.py
+++ b/tests/unit/pipelex/migration/test_surface_directories.py
@@ -5,8 +5,9 @@ two globs over one file refused by name. This module covers the half a subdirect
name in two directories is two different files, and only the surface that owns the directory it
sits in may claim it.
-The specimen is real and it is the reason this exists at all:
-`inference/backends/pipelex_manifold.toml` matches the `pipelex-config` tier glob `pipelex_*.toml`
+The specimen is a file earlier kits shipped, which machines set up with them still carry, and it is
+the reason this exists at all:
+`inference/backends/pipelex_gateway.toml` matches the `pipelex-config` tier glob `pipelex_*.toml`
exactly. Before the walk reached subdirectories, depth alone kept it safe. Now that the walk goes
there on purpose, the *directory* is what has to keep it safe — and if it ever stops doing so, the
main configuration's ledger gets replayed over an inference backend definition and rewrites it.
@@ -37,7 +38,7 @@ class TestADirectoryIsHalfTheClaim:
(root / "pipelex.toml").write_text("", encoding="utf-8")
(root / "pipelex_override.toml").write_text("", encoding="utf-8")
(root / BACKENDS).mkdir(parents=True)
- (root / BACKENDS / "pipelex_manifold.toml").write_text("", encoding="utf-8")
+ (root / BACKENDS / "pipelex_gateway.toml").write_text("", encoding="utf-8")
(root / BACKENDS / "openai.toml").write_text("", encoding="utf-8")
(root / BACKENDS / "notes.md").write_text("", encoding="utf-8")
(root / "inference" / "deck").mkdir(parents=True)
@@ -47,7 +48,7 @@ class TestADirectoryIsHalfTheClaim:
def test_each_file_goes_to_the_surface_that_owns_the_directory_it_sits_in(self, tmp_path: Path, build_surface: SurfaceBuilder) -> None:
"""One assertion for the whole rule, because every line of it is a separate way to get this wrong.
- `pipelex_manifold.toml` is claimed by the backend surface and *not* by the root surface whose
+ `pipelex_gateway.toml` is claimed by the backend surface and *not* by the root surface whose
glob its name matches; `notes.md` falls out by extension; `deck/` is a directory no surface
owns and is never entered; `inference/backends.toml` sits one level above the directory the
backend surface owns and is nobody's.
@@ -60,19 +61,19 @@ class TestADirectoryIsHalfTheClaim:
("pipelex-config", "pipelex.toml"),
("pipelex-config", "pipelex_override.toml"),
("inference-backend", "inference/backends/openai.toml"),
- ("inference-backend", "inference/backends/pipelex_manifold.toml"),
+ ("inference-backend", "inference/backends/pipelex_gateway.toml"),
]
def test_the_same_name_resolves_to_a_different_surface_in_each_directory(self, build_surface: SurfaceBuilder) -> None:
"""The claim is the pair, so the specimen's name alone answers nothing.
- Without the directory in the question, `pipelex_manifold.toml` is a `pipelex_*.toml` match
+ Without the directory in the question, `pipelex_gateway.toml` is a `pipelex_*.toml` match
and the root surface takes it wherever it lives.
"""
registry = self._registry(build_surface)
- at_the_root = registry.surface_for_file(subdirectory=Path(), file_name="pipelex_manifold.toml")
- in_the_backends_directory = registry.surface_for_file(subdirectory=BACKENDS, file_name="pipelex_manifold.toml")
+ at_the_root = registry.surface_for_file(subdirectory=Path(), file_name="pipelex_gateway.toml")
+ in_the_backends_directory = registry.surface_for_file(subdirectory=BACKENDS, file_name="pipelex_gateway.toml")
assert at_the_root is not None
assert at_the_root.surface_id == "pipelex-config"
@@ -83,7 +84,7 @@ class TestADirectoryIsHalfTheClaim:
"""The other direction of the same rule: the backend directory is not the root surface's to claim in."""
registry = SurfaceRegistry(surfaces=[build_surface(surface_id="pipelex-config", base_file="pipelex.toml", tier_glob="pipelex_*.toml")])
- assert registry.surface_for_file(subdirectory=BACKENDS, file_name="pipelex_manifold.toml") is None
+ assert registry.surface_for_file(subdirectory=BACKENDS, file_name="pipelex_gateway.toml") is None
assert registry.surface_for_file(subdirectory=BACKENDS, file_name="pipelex.toml") is None
def test_a_subdirectory_that_does_not_exist_is_skipped_rather_than_refused(self, tmp_path: Path, build_surface: SurfaceBuilder) -> None:
diff --git a/tests/unit/pipelex/plugins/test_inference_backend_coverage.py b/tests/unit/pipelex/plugins/test_inference_backend_coverage.py
index f20819ac1..364c5af78 100644
--- a/tests/unit/pipelex/plugins/test_inference_backend_coverage.py
+++ b/tests/unit/pipelex/plugins/test_inference_backend_coverage.py
@@ -37,8 +37,6 @@ EXPECTED_BACKENDS: list[tuple[InferenceFamily, str]] = [
(InferenceFamily.LLM, "azure_openai"),
(InferenceFamily.LLM, "openai_responses"),
(InferenceFamily.LLM, "azure_openai_responses"),
- (InferenceFamily.LLM, "manifold_completions"),
- (InferenceFamily.LLM, "manifold_responses"),
(InferenceFamily.LLM, "portkey_completions"),
(InferenceFamily.LLM, "portkey_responses"),
(InferenceFamily.LLM, "anthropic"),
@@ -48,8 +46,6 @@ EXPECTED_BACKENDS: list[tuple[InferenceFamily, str]] = [
(InferenceFamily.LLM, "bedrock_aioboto"),
(InferenceFamily.LLM, "google"),
# IMG_GEN
- (InferenceFamily.IMG_GEN, "manifold_img_gen"),
- (InferenceFamily.IMG_GEN, "manifold_completions"),
(InferenceFamily.IMG_GEN, "openai_img_gen"),
(InferenceFamily.IMG_GEN, "blackboxai_img_gen"),
(InferenceFamily.IMG_GEN, "openrouter_img_gen"),
@@ -58,14 +54,12 @@ EXPECTED_BACKENDS: list[tuple[InferenceFamily, str]] = [
(InferenceFamily.IMG_GEN, "azure_rest_img_gen"),
(InferenceFamily.IMG_GEN, "google"),
# EXTRACT
- (InferenceFamily.EXTRACT, "manifold_extract"),
(InferenceFamily.EXTRACT, "mistral"),
(InferenceFamily.EXTRACT, "pypdfium2"),
(InferenceFamily.EXTRACT, "docling_sdk"),
(InferenceFamily.EXTRACT, "linkup_fetch"),
# SEARCH
(InferenceFamily.SEARCH, "linkup"),
- (InferenceFamily.SEARCH, "manifold_search"),
# JUDGMENT
(InferenceFamily.JUDGMENT, "typesafe"),
]
@@ -86,16 +80,6 @@ class TestInferenceBackendCoverage:
pytest.param([(InferenceFamily.LLM, "google"), (InferenceFamily.IMG_GEN, "google")], "google", id="google"),
pytest.param([(InferenceFamily.LLM, "openai"), (InferenceFamily.IMG_GEN, "openai_img_gen")], "openai", id="openai"),
pytest.param([(InferenceFamily.EXTRACT, "linkup_fetch"), (InferenceFamily.SEARCH, "linkup")], "linkup", id="linkup"),
- pytest.param(
- [
- (InferenceFamily.LLM, "manifold_completions"),
- (InferenceFamily.IMG_GEN, "manifold_img_gen"),
- (InferenceFamily.EXTRACT, "manifold_extract"),
- (InferenceFamily.SEARCH, "manifold_search"),
- ],
- "manifold",
- id="manifold",
- ),
],
)
def test_cross_family_vendor_registers_into_all_its_families(self, vendor_families: list[tuple[InferenceFamily, str]], vendor: str) -> None:
diff --git a/tests/unit/pipelex/providers/anthropic/test_anthropic_client_auth.py b/tests/unit/pipelex/providers/anthropic/test_anthropic_client_auth.py
index 4d7c01675..969deba96 100644
--- a/tests/unit/pipelex/providers/anthropic/test_anthropic_client_auth.py
+++ b/tests/unit/pipelex/providers/anthropic/test_anthropic_client_auth.py
@@ -2,14 +2,12 @@
The anthropic SDK carries its key in `x-api-key`. That is right for Anthropic itself and for the
Anthropic-compatible vendors, and wrong for a backend that fronts the protocol behind a gateway
-which authenticates on a header of its own — the Pipelex service reads `x-pipelex-api-key`
-(or an `Authorization` bearer) and never looks at `x-api-key`, so a key left in the SDK's own slot
-reaches it as an anonymous request. A backend says which header carries its key with the
+which authenticates on a header of its own and never looks at `x-api-key`, so a key left in the
+SDK's own slot reaches it as an anonymous request. A backend says which header carries its key with the
`auth_header` extra-config field; these tests pin both paths and the refusal.
-This lives in `providers/anthropic/` rather than in the hosted package deliberately: the driver is
-shared with the plain BYOK Anthropic backend and outlives the Portkey retirement. The gate is the
-backend's own declaration, so a BYOK backend takes the unchanged path.
+The driver is shared with the plain BYOK Anthropic backend, and the gate is the backend's own
+declaration, so a BYOK backend takes the unchanged path.
**The `base_url` here is the origin with no `/v1`, and that is the whole endpoint rule in one
assertion.** `AsyncAnthropic` defaults to `https://api.anthropic.com` and appends `/v1/messages`
@@ -32,8 +30,8 @@ from pipelex.providers.anthropic.anthropic_factory import AnthropicFactory
if TYPE_CHECKING:
from pytest_mock import MockerFixture
-_PIPELEX_HOSTED_AUTH_HEADER = "x-pipelex-api-key"
-_PIPELEX_HOSTED_ORIGIN = "https://pipelex_hosted.example.com"
+_GATEWAY_AUTH_HEADER = "x-gateway-api-key"
+_GATEWAY_ORIGIN = "https://gateway.example.com"
def _model_handle() -> ModelHandle:
@@ -62,30 +60,30 @@ class TestAnthropicClientAuth:
_patch_config(mocker)
mock_client = mocker.patch("pipelex.providers.anthropic.anthropic_factory.AsyncAnthropic")
backend = InferenceBackend(
- name="pipelex_manifold",
- endpoint=_PIPELEX_HOSTED_ORIGIN,
- api_key="hosted-service-token",
- extra_config={"auth_header": _PIPELEX_HOSTED_AUTH_HEADER},
+ name="my_gateway",
+ endpoint=_GATEWAY_ORIGIN,
+ api_key="gateway-token",
+ extra_config={"auth_header": _GATEWAY_AUTH_HEADER},
)
AnthropicFactory.make_anthropic_client(model_handle=_model_handle(), backend=backend)
kwargs = mock_client.call_args.kwargs
- assert kwargs["default_headers"] == {_PIPELEX_HOSTED_AUTH_HEADER: "hosted-service-token"}
+ assert kwargs["default_headers"] == {_GATEWAY_AUTH_HEADER: "gateway-token"}
# The SDK refuses an empty api_key, so the slot holds a placeholder rather than the token.
- assert kwargs["api_key"] != "hosted-service-token"
+ assert kwargs["api_key"] != "gateway-token"
assert kwargs["api_key"]
# The origin, not the origin plus `/v1`: this SDK appends its own `/v1/messages`.
- assert kwargs["base_url"] == _PIPELEX_HOSTED_ORIGIN
+ assert kwargs["base_url"] == _GATEWAY_ORIGIN
def test_auth_header_without_a_key_is_refused(self, mocker: MockerFixture) -> None:
_patch_config(mocker)
mocker.patch("pipelex.providers.anthropic.anthropic_factory.AsyncAnthropic")
backend = InferenceBackend(
- name="pipelex_manifold",
- endpoint=_PIPELEX_HOSTED_ORIGIN,
+ name="my_gateway",
+ endpoint=_GATEWAY_ORIGIN,
api_key=None,
- extra_config={"auth_header": _PIPELEX_HOSTED_AUTH_HEADER},
+ extra_config={"auth_header": _GATEWAY_AUTH_HEADER},
)
with pytest.raises(AnthropicFactoryError, match="auth_header"):
diff --git a/tests/unit/pipelex/providers/openai/test_openai_completions_img_gen_worker_output_format.py b/tests/unit/pipelex/providers/openai/test_openai_completions_img_gen_worker_output_format.py
index 69b51fcce..dd614a4e9 100644
--- a/tests/unit/pipelex/providers/openai/test_openai_completions_img_gen_worker_output_format.py
+++ b/tests/unit/pipelex/providers/openai/test_openai_completions_img_gen_worker_output_format.py
@@ -19,7 +19,6 @@ from pipelex.plugins.registrar import PluginRegistrar
from pipelex.providers.blackboxai.blackboxai_plugin import BlackboxaiPlugin
from pipelex.providers.openai.openai_completions_img_gen_worker import OpenAICompletionsImgGenWorker
from pipelex.providers.openrouter.openrouter_plugin import OpenRouterPlugin
-from pipelex.providers.pipelex_hosted.pipelex_hosted_plugin import PipelexHostedPlugin
from pipelex.tools.misc.image_utils import ImageFormat
if TYPE_CHECKING:
@@ -111,11 +110,10 @@ class TestEachRegistrationPassesItsFormat:
@pytest.mark.parametrize(
("plugin", "sdk", "expected"),
[
- (PipelexHostedPlugin(), "manifold_completions", ImageFormat.PNG),
(BlackboxaiPlugin(), "blackboxai_img_gen", ImageFormat.JPEG),
(OpenRouterPlugin(), "openrouter_img_gen", None),
],
- ids=["manifold", "blackboxai", "openrouter"],
+ ids=["blackboxai", "openrouter"],
)
def test_the_registration_builds_the_worker_with_its_format(
self, mocker: MockerFixture, plugin: Any, sdk: str, expected: ImageFormat | None
diff --git a/tests/unit/pipelex/providers/pipelex_hosted/conftest.py b/tests/unit/pipelex/providers/pipelex_hosted/conftest.py
deleted file mode 100644
index 8068fa96c..000000000
--- a/tests/unit/pipelex/providers/pipelex_hosted/conftest.py
+++ /dev/null
@@ -1,21 +0,0 @@
-"""Fixtures shared by the hosted provider's unit tests."""
-
-import pytest
-from pytest_mock import MockerFixture
-
-from pipelex.cogt.inference.service_error_vocabulary import ServiceErrorVocabulary
-from pipelex.providers.pipelex_hosted.pipelex_hosted_error_codes import PIPELEX_HOSTED_SERVICE_ERROR_CODES
-
-
[email protected](autouse=True)
-def pipelex_hosted_service_error_vocabulary(mocker: MockerFixture) -> ServiceErrorVocabulary:
- """Hand the classifier the vocabulary the hosted plugin contributes, as a booted runtime has it.
-
- The Pipelex service's own refusal codes are classified only because the plugin contributes them
- through the service error vocabulary, so every test here classifies against exactly that
- vocabulary, stated rather than inherited from whatever the session's boot registered. A test that
- needs the status ladder alone patches the same accessor to return ``None``.
- """
- vocabulary = ServiceErrorVocabulary({entry.code: entry for entry in PIPELEX_HOSTED_SERVICE_ERROR_CODES})
- mocker.patch("pipelex.cogt.inference.error_classify.get_optional_service_error_vocabulary", return_value=vocabulary)
- return vocabulary
diff --git a/tests/unit/pipelex/providers/pipelex_hosted/test_data.py b/tests/unit/pipelex/providers/pipelex_hosted/test_data.py
deleted file mode 100644
index c860017d6..000000000
--- a/tests/unit/pipelex/providers/pipelex_hosted/test_data.py
+++ /dev/null
@@ -1,139 +0,0 @@
-"""Job metadata the hosted tests hand to a request, the header value it must produce, and catalog entries with the extras they yield."""
-
-from typing import Any, ClassVar
-
-from pipelex.cogt.image.image_size import ImageSize
-from pipelex.cogt.img_gen.img_gen_job_components import AspectRatio, SizeTier
-from pipelex.system.job_metadata import JobMetadata, RunMetadata
-
-
-class PipelexHostedMetadataTestData:
- """A job whose run carries host labels, and the exact `x-pipelex-metadata` value it yields.
-
- The expected value is written out as the wire string rather than rebuilt from the job, so a
- change to the encoding (key order, separators, escaping) turns a test red instead of moving with it.
- """
-
- EXTRAS: ClassVar[dict[str, str]] = {"org_id": "org_acme", "api_key_id": "key_123"}
-
- JOB_METADATA: ClassVar[JobMetadata] = JobMetadata(
- run_metadata=RunMetadata(
- storage_scope="test/scope",
- read_scope=None,
- user_id="user_42",
- pipeline_run_id="run_abc",
- extras={"org_id": "org_acme", "api_key_id": "key_123"},
- ),
- pipe_code="summarize_doc",
- pipe_run_id="0123456789abcdef",
- content_generation_job_id="cgj_1",
- )
-
- EXPECTED_HEADER_VALUE: ClassVar[str] = (
- '{"org_id":"org_acme","api_key_id":"key_123","user_id":"user_42","pipeline_run_id":"run_abc",'
- '"pipe_run_id":"0123456789abcdef","pipe_code":"summarize_doc","content_generation_job_id":"cgj_1"}'
- )
-
-
-class PipelexHostedExtrasBySpecTestData:
- """Hosted catalog entries, written as the tables a catalog holds, and the body extras each must produce.
-
- The Gemini image entries carry no `model_id`, as the hosted catalog serves them: the spec's
- model id then defaults to the handle, which does not start with `gemini`, so only the spec's
- image rules can say that `image_config` is due. Each case is (handle, catalog entry, aspect
- ratio, size, expected `image_config`).
- """
-
- GEMINI_IMAGE_CASES: ClassVar[list[tuple[str, dict[str, Any], AspectRatio, SizeTier | ImageSize | None, dict[str, str]]]] = [
- (
- "nano-banana",
- {"model_type": "img_gen", "sdk": "manifold_completions", "rules": {"aspect_ratio": "gemini_2_5"}},
- AspectRatio.LANDSCAPE_16_9,
- None,
- {"aspect_ratio": "16:9"},
- ),
- (
- "nano-banana-pro",
- {"model_type": "img_gen", "sdk": "manifold_completions", "rules": {"aspect_ratio": "gemini_3_pro"}},
- AspectRatio.PORTRAIT_9_16,
- SizeTier.TWO_K,
- {"aspect_ratio": "9:16", "image_size": "2K"},
- ),
- (
- "nano-banana-2",
- {"model_type": "img_gen", "sdk": "manifold_completions", "rules": {"aspect_ratio": "gemini_3_flash"}},
- AspectRatio.LANDSCAPE_4_1,
- SizeTier.FOUR_K,
- {"aspect_ratio": "4:1", "image_size": "4K"},
- ),
- (
- "nano-banana-2-lite",
- {"model_type": "img_gen", "sdk": "manifold_completions", "rules": {"aspect_ratio": "gemini_3_flash_lite"}},
- AspectRatio.SQUARE,
- SizeTier.ONE_K,
- {"aspect_ratio": "1:1", "image_size": "1K"},
- ),
- (
- "nano-banana",
- {
- "model_type": "img_gen",
- "sdk": "manifold_completions",
- "model_id": "gemini-2.5-flash-image",
- "rules": {"aspect_ratio": "gemini_2_5"},
- },
- AspectRatio.PORTRAIT_3_4,
- None,
- {"aspect_ratio": "3:4"},
- ),
- ]
-
- # (topic, handle, catalog entry): image models whose rules name a non-Gemini taxonomy get no `image_config`.
- NON_GEMINI_IMAGE_CASES: ClassVar[list[tuple[str, str, dict[str, Any]]]] = [
- (
- "gpt_image_legacy",
- "gpt-image-1",
- {"model_type": "img_gen", "sdk": "manifold_img_gen", "rules": {"model_choice": "model_name", "aspect_ratio": "gpt_image_legacy"}},
- ),
- (
- "gpt_image_2",
- "gpt-image-2",
- {"model_type": "img_gen", "sdk": "manifold_img_gen", "rules": {"model_choice": "model_name", "aspect_ratio": "gpt_image_2"}},
- ),
- ]
-
- # (topic, handle, catalog entry, error match): an image spec that cannot say whether it is a Gemini one is refused rather
- # than read as non-Gemini, since that would drop the requested ratio and size without a word. An `aspect_ratio` value
- # this release does not know may name a newer Gemini taxonomy, and a spec declaring no `aspect_ratio` says nothing.
- UNDECIDABLE_IMAGE_CASES: ClassVar[list[tuple[str, str, dict[str, Any], str]]] = [
- (
- "unknown_taxonomy",
- "nano-banana-next",
- {"model_type": "img_gen", "sdk": "manifold_completions", "rules": {"aspect_ratio": "gemini_from_the_future"}},
- "unknown aspect_ratio taxonomy 'gemini_from_the_future'",
- ),
- (
- "gemini_id_without_rules",
- "gemini-lookalike",
- {"model_type": "img_gen", "sdk": "manifold_completions", "model_id": "gemini-2.5-flash-image"},
- "declares no aspect_ratio rule",
- ),
- (
- "rules_without_aspect_ratio",
- "nano-banana-bare",
- {"model_type": "img_gen", "sdk": "manifold_completions", "rules": {"prompt": "positive_only"}},
- "declares no aspect_ratio rule",
- ),
- ]
-
- # (topic, handle, catalog entry, whether the job gets a seed): the Mistral seed still keys on the model id's prefix,
- # which the one hosted Mistral handle carries whether or not the entry names the provider's id.
- MISTRAL_SEED_CASES: ClassVar[list[tuple[str, str, dict[str, Any], bool]]] = [
- ("mistral_handle_only", "mistral-large", {"sdk": "manifold_completions", "structure_method": "instructor/mistral_tools"}, True),
- (
- "mistral_provider_id",
- "mistral-large",
- {"sdk": "manifold_completions", "model_id": "Mistral-Large-3", "structure_method": "instructor/mistral_tools"},
- True,
- ),
- ("not_mistral", "gpt-4o", {"sdk": "manifold_responses"}, False),
- ]
diff --git a/tests/unit/pipelex/providers/pipelex_hosted/test_extract_pipelex_hosted_metadata.py b/tests/unit/pipelex/providers/pipelex_hosted/test_extract_pipelex_hosted_metadata.py
deleted file mode 100644
index da51f9e4d..000000000
--- a/tests/unit/pipelex/providers/pipelex_hosted/test_extract_pipelex_hosted_metadata.py
+++ /dev/null
@@ -1,64 +0,0 @@
-"""Which header `extract_pipelex_hosted_metadata` takes the request id from, and in what order.
-
-The Pipelex service stamps its trace id on every answer a provider gave, and since the header
-spellings were given a pipelex vocabulary it emits that id twice: under `x-pipelex-trace-id`, the
-spelling the dialect owns, and under `x-portkey-trace-id`, the inherited one it still carries for
-the vendor SDK on the image path. The two always hold the same value, so the precedence below is
-not about picking the better id — it is about the moment the gateway stops emitting the vendor
-spelling, after which a runtime that only knew that one would report no request id at all.
-
-`x-request-id` stays ahead of both: it is the *provider's* own id when the provider sent one, which
-is what a support conversation with that provider needs, and the gateway's trace id is the fallback
-for every answer that carried none.
-"""
-
-from __future__ import annotations
-
-import httpx
-
-from pipelex.providers.pipelex_hosted.pipelex_hosted_error_metadata import extract_pipelex_hosted_metadata
-
-_ORIGIN = "https://pipelex_hosted.example.com"
-
-
-def _refusal_with_headers(headers: dict[str, str]) -> httpx.HTTPStatusError:
- """A native-route failure as the hosted client raises it: plain httpx, no vendor SDK."""
- request = httpx.Request("POST", f"{_ORIGIN}/v1/pipelex/extract")
- response = httpx.Response(status_code=502, request=request, headers=headers)
- return httpx.HTTPStatusError("Server error '502 Bad Gateway'", request=request, response=response)
-
-
-class TestTheRequestIdThePipelexHostedPathReports:
- def test_reads_the_pipelex_spelled_trace_id(self) -> None:
- """The spelling the dialect owns, alone on the response — where the gateway is heading."""
- metadata = extract_pipelex_hosted_metadata(_refusal_with_headers({"x-pipelex-trace-id": "trace-pipelex"}))
-
- assert metadata.request_id == "trace-pipelex"
-
- def test_prefers_the_pipelex_spelling_over_the_vendor_one(self) -> None:
- """Both spellings on the wire is what the gateway emits today, with one value under each."""
- headers = {"x-portkey-trace-id": "trace-vendor", "x-pipelex-trace-id": "trace-pipelex"}
-
- metadata = extract_pipelex_hosted_metadata(_refusal_with_headers(headers))
-
- assert metadata.request_id == "trace-pipelex"
-
- def test_still_reads_the_vendor_spelling_while_the_gateway_emits_it(self) -> None:
- """The fallback is harmless until the gateway drops the inherited spelling, and useful until then."""
- metadata = extract_pipelex_hosted_metadata(_refusal_with_headers({"x-portkey-trace-id": "trace-vendor"}))
-
- assert metadata.request_id == "trace-vendor"
-
- def test_prefers_the_providers_own_request_id_over_any_trace_id(self) -> None:
- """A provider answered and named its call; that id, not the gateway's, is the one to quote."""
- headers = {"x-request-id": "provider-1", "x-pipelex-trace-id": "trace-pipelex", "x-portkey-trace-id": "trace-vendor"}
-
- metadata = extract_pipelex_hosted_metadata(_refusal_with_headers(headers))
-
- assert metadata.request_id == "provider-1"
-
- def test_reports_no_request_id_when_no_provider_was_reached(self) -> None:
- """A refusal the gateway raised before trying a provider carries neither trace spelling."""
- metadata = extract_pipelex_hosted_metadata(_refusal_with_headers({}))
-
- assert metadata.request_id is None
diff --git a/tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_clients.py b/tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_clients.py
deleted file mode 100644
index 41b8a9f0d..000000000
--- a/tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_clients.py
+++ /dev/null
@@ -1,137 +0,0 @@
-"""What each hosted client is handed at construction.
-
-Three SDKs sit under this package and they do not agree about `base_url`: `AsyncOpenAI` and
-`AsyncPortkey` both expect the version segment in it (their own defaults are
-`https://api.openai.com/v1` and `https://api.portkey.ai/v1`), while `AsyncAnthropic` defaults to
-`https://api.anthropic.com` and appends `/v1/messages` itself. The origin rule composes with all
-three only because each factory appends what its SDK expects — so these tests read the arguments the
-factory actually passed rather than trusting that it did.
-
-The second property pinned here is negative and matters more: **nothing about routing is sent.** The
-token travels in the service's own header, the OpenAI `Authorization` slot holds a placeholder the
-gateway never reads, and no config id or provider name appears anywhere.
-"""
-
-from __future__ import annotations
-
-from typing import TYPE_CHECKING, Any
-
-import pytest
-
-from pipelex.cogt.model_backends.backend import InferenceBackend
-from pipelex.plugins.model_handle import ModelHandle
-from pipelex.providers.pipelex_hosted.pipelex_hosted_completions_factory import PipelexHostedCompletionsFactory
-from pipelex.providers.pipelex_hosted.pipelex_hosted_constants import PipelexHostedSdk
-from pipelex.providers.pipelex_hosted.pipelex_hosted_exceptions import PipelexHostedFactoryError
-from pipelex.providers.pipelex_hosted.pipelex_hosted_factory import PipelexHostedFactory
-from pipelex.providers.pipelex_hosted.pipelex_hosted_responses_factory import PipelexHostedResponsesFactory
-
-if TYPE_CHECKING:
- from collections.abc import Mapping
-
- from pytest_mock import MockerFixture
-
-_ORIGIN = "https://pipelex_hosted.example.com"
-_TOKEN = "hosted-service-token"
-_AUTH_HEADER = "x-pipelex-api-key"
-
-# Anything that would tell the service who should serve the model. None of it belongs on this path:
-# the model id in the body is the whole of the routing decision, and the gateway refuses a client
-# that tries to make it (`pig-03`).
-_ROUTING_MARKERS = ("x-portkey-config", "x-portkey-provider", "x-portkey-virtual-key", "x-portkey-custom-host")
-
-
-def _backend() -> InferenceBackend:
- return InferenceBackend(name="pipelex_manifold", endpoint=_ORIGIN, api_key=_TOKEN)
-
-
-def _handle(sdk: PipelexHostedSdk) -> ModelHandle:
- return ModelHandle(sdk=str(sdk), backend="pipelex_manifold")
-
-
-def _patch_config(mocker: MockerFixture, module: str) -> None:
- config = mocker.MagicMock()
- config.inference.transport_max_retries = 3
- mocker.patch(f"{module}.get_config", return_value=config)
-
-
-def _assert_no_routing(kwargs: Mapping[str, Any]) -> None:
- rendered = str(kwargs).lower()
- for marker in _ROUTING_MARKERS:
- assert marker not in rendered, f"the hosted client was handed a routing marker: {marker}"
-
-
-class TestPipelexHostedCompletionsClient:
- def test_the_client_gets_the_origin_plus_v1_and_the_token_in_the_service_header(self, mocker: MockerFixture) -> None:
- _patch_config(mocker, "pipelex.providers.pipelex_hosted.pipelex_hosted_completions_factory")
- mock_openai = mocker.patch("openai.AsyncOpenAI")
-
- PipelexHostedCompletionsFactory.make_openai_client_for_completions(_handle(PipelexHostedSdk.COMPLETIONS), backend=_backend())
-
- kwargs = mock_openai.call_args.kwargs
- assert kwargs["base_url"] == f"{_ORIGIN}/v1"
- assert kwargs["default_headers"] == {_AUTH_HEADER: _TOKEN}
- assert kwargs["max_retries"] == 3
- # The SDK has refused an empty api_key since 2.34.0, so the slot holds a placeholder rather
- # than the token — sending the token twice would put it somewhere the gateway does not read.
- assert kwargs["api_key"] != _TOKEN
- assert kwargs["api_key"]
- _assert_no_routing(kwargs)
-
- def test_a_handle_from_another_sdk_set_is_refused(self, mocker: MockerFixture) -> None:
- _patch_config(mocker, "pipelex.providers.pipelex_hosted.pipelex_hosted_completions_factory")
- mocker.patch("openai.AsyncOpenAI")
-
- with pytest.raises(PipelexHostedFactoryError):
- PipelexHostedCompletionsFactory.make_openai_client_for_completions(_handle(PipelexHostedSdk.RESPONSES), backend=_backend())
-
-
-class TestPipelexHostedResponsesClient:
- def test_the_client_gets_the_origin_plus_v1_and_the_token_in_the_service_header(self, mocker: MockerFixture) -> None:
- _patch_config(mocker, "pipelex.providers.pipelex_hosted.pipelex_hosted_responses_factory")
- mock_openai = mocker.patch("openai.AsyncOpenAI")
-
- PipelexHostedResponsesFactory.make_openai_client_for_responses(_handle(PipelexHostedSdk.RESPONSES), backend=_backend())
-
- kwargs = mock_openai.call_args.kwargs
- assert kwargs["base_url"] == f"{_ORIGIN}/v1"
- assert kwargs["default_headers"] == {_AUTH_HEADER: _TOKEN}
- assert kwargs["api_key"] != _TOKEN
- _assert_no_routing(kwargs)
-
- def test_a_handle_from_another_sdk_set_is_refused(self, mocker: MockerFixture) -> None:
- _patch_config(mocker, "pipelex.providers.pipelex_hosted.pipelex_hosted_responses_factory")
- mocker.patch("openai.AsyncOpenAI")
-
- with pytest.raises(PipelexHostedFactoryError):
- PipelexHostedResponsesFactory.make_openai_client_for_responses(_handle(PipelexHostedSdk.COMPLETIONS), backend=_backend())
-
-
-class TestPipelexHostedImageClient:
- def test_the_vendor_client_is_built_under_the_same_endpoint_rule(self, mocker: MockerFixture) -> None:
- """`AsyncPortkey` is a beta-only dependency of the image path, and it obeys the same rule.
-
- The vendor SDK's own `base_url` default is Portkey's cloud, so the value passed here is the
- whole of what keeps this client pointed at our service.
- """
- mock_portkey = mocker.patch("portkey_ai.AsyncPortkey")
-
- PipelexHostedFactory.make_portkey_client(_backend())
-
- kwargs = mock_portkey.call_args.kwargs
- assert kwargs["base_url"] == f"{_ORIGIN}/v1"
- assert kwargs["api_key"] == _TOKEN
- _assert_no_routing(kwargs)
-
- def test_debug_is_read_from_the_backend_and_from_nothing_else(self, mocker: MockerFixture) -> None:
- """One configuration block must not govern two services.
-
- The Portkey-path sibling routes this through the telemetry manager's Portkey-path
- knobs; reading those here would make a change meant for the cloud path silently alter the
- hosted one.
- """
- mocker.patch("portkey_ai.AsyncPortkey")
- backend = InferenceBackend(name="pipelex_manifold", endpoint=_ORIGIN, api_key=_TOKEN, extra_config={"debug": True})
-
- assert PipelexHostedFactory.is_debug_enabled(backend) is True
- assert PipelexHostedFactory.is_debug_enabled(_backend()) is False
diff --git a/tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_completions_messages.py b/tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_completions_messages.py
deleted file mode 100644
index d8cbc1277..000000000
--- a/tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_completions_messages.py
+++ /dev/null
@@ -1,134 +0,0 @@
-"""`PipelexHostedCompletionsFactory.make_simple_messages` — the override for a Pipelex-operated gateway.
-
-Documents travel to a Pipelex-operated gateway as a `ChatCompletionContentPartImageParam` holding a
-data URL, not as the OpenAI file part the base class sends: the gateway translates that part into
-whatever document format the provider it picked actually wants, and it cannot translate a file part.
-"""
-
-from __future__ import annotations
-
-from typing import TYPE_CHECKING, Any
-
-import pytest
-
-from pipelex.cogt.image.prompt_image import PromptImageDetail
-from pipelex.providers.pipelex_hosted.pipelex_hosted_completions_factory import PipelexHostedCompletionsFactory
-from pipelex.tools.misc.filetype_utils import FileType
-from pipelex.tools.uri.prepared_file import PreparedFileBase64, PreparedFileHttpUrl, PreparedFileLocalPath
-
-if TYPE_CHECKING:
- from pytest_mock import MockerFixture
-
-_FACTORY_NAMESPACE = "pipelex.providers.pipelex_hosted.pipelex_hosted_completions_factory"
-
-_PNG_FILE_TYPE = FileType(extension="png", mime="image/png")
-_PDF_FILE_TYPE = FileType(extension="pdf", mime="application/pdf")
-
-
-def _make_llm_job(
- mocker: MockerFixture,
- *,
- system_text: str | None = None,
- user_text: str | None = None,
- has_images: bool = False,
- has_documents: bool = False,
- image_detail: PromptImageDetail | None = None,
-) -> Any:
- job = mocker.MagicMock()
- job.llm_prompt.system_text = system_text
- job.llm_prompt.user_text = user_text
- job.llm_prompt.user_images = [mocker.MagicMock()] if has_images else []
- job.llm_prompt.user_documents = [mocker.MagicMock()] if has_documents else []
- job.job_params.image_detail = image_detail
- return job
-
-
[email protected](loop_scope="class")
-class TestPipelexHostedCompletionsMessages:
- async def test_system_and_user_text(self, mocker: MockerFixture) -> None:
- factory = PipelexHostedCompletionsFactory(is_http_url_enabled=False)
- llm_job = _make_llm_job(mocker, system_text="You are concise.", user_text="Summarize this.")
-
- messages = await factory.make_simple_messages(llm_job=llm_job)
-
- assert messages == [
- {"role": "system", "content": "You are concise."},
- {"role": "user", "content": [{"type": "text", "text": "Summarize this."}]},
- ]
-
- async def test_a_document_travels_as_an_image_url_data_url(self, mocker: MockerFixture) -> None:
- """The whole reason this override exists, and the reason it is not the base class's."""
- factory = PipelexHostedCompletionsFactory(is_http_url_enabled=False)
- llm_job = _make_llm_job(mocker, user_text="Read this doc.", has_documents=True)
- prep = mocker.patch(
- f"{_FACTORY_NAMESPACE}.prep_prompt_documents",
- new_callable=mocker.AsyncMock,
- return_value=[PreparedFileBase64(base64_data="UERG", file_type=_PDF_FILE_TYPE)],
- )
-
- messages = await factory.make_simple_messages(llm_job=llm_job)
-
- # Documents are base64 whatever the factory's images setting allows: an http URL here would
- # reach the gateway as a link it does not fetch.
- prep.assert_awaited_once_with(prompt_documents=llm_job.llm_prompt.user_documents, is_http_url_enabled=False)
- assert messages == [
- {
- "role": "user",
- "content": [
- {"type": "text", "text": "Read this doc."},
- {"type": "image_url", "image_url": {"url": "data:application/pdf;base64,UERG", "detail": "auto"}},
- ],
- },
- ]
-
- @pytest.mark.parametrize(
- ("image_detail", "expected_detail"),
- [(None, "auto"), (PromptImageDetail.HIGH, "high"), (PromptImageDetail.LOW, "low")],
- )
- async def test_images_become_image_url_parts_at_the_requested_detail(
- self,
- mocker: MockerFixture,
- image_detail: PromptImageDetail | None,
- expected_detail: str,
- ) -> None:
- factory = PipelexHostedCompletionsFactory(is_http_url_enabled=False)
- llm_job = _make_llm_job(mocker, user_text="Look at these.", has_images=True, image_detail=image_detail)
- prep = mocker.patch(
- f"{_FACTORY_NAMESPACE}.prep_prompt_images",
- new_callable=mocker.AsyncMock,
- return_value=[PreparedFileBase64(base64_data="QUJD", file_type=_PNG_FILE_TYPE)],
- )
-
- messages = await factory.make_simple_messages(llm_job=llm_job)
-
- prep.assert_awaited_once_with(prompt_images=llm_job.llm_prompt.user_images, is_http_url_enabled=False)
- assert messages == [
- {
- "role": "user",
- "content": [
- {"type": "text", "text": "Look at these."},
- {"type": "image_url", "image_url": {"url": "data:image/png;base64,QUJD", "detail": expected_detail}},
- ],
- },
- ]
-
- @pytest.mark.parametrize(
- ("prepped_document", "expected_match"),
- [
- (PreparedFileHttpUrl(url="https://docs.example/file.pdf"), "PreparedFileHttpUrl is not supported for documents"),
- (PreparedFileLocalPath(path="some/local/file.pdf"), "PreparedFileLocalPath is not supported for documents"),
- ],
- ids=["http-url-document", "local-path-document"],
- )
- async def test_a_document_that_is_not_bytes_is_refused(
- self,
- mocker: MockerFixture,
- prepped_document: PreparedFileHttpUrl | PreparedFileLocalPath,
- expected_match: str,
- ) -> None:
- factory = PipelexHostedCompletionsFactory(is_http_url_enabled=False)
- llm_job = _make_llm_job(mocker, user_text="text", has_documents=True)
- mocker.patch(f"{_FACTORY_NAMESPACE}.prep_prompt_documents", new_callable=mocker.AsyncMock, return_value=[prepped_document])
-
- with pytest.raises(TypeError, match=expected_match):
- await factory.make_simple_messages(llm_job=llm_job)
diff --git a/tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_endpoint_rule.py b/tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_endpoint_rule.py
deleted file mode 100644
index 7428a3049..000000000
--- a/tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_endpoint_rule.py
+++ /dev/null
@@ -1,66 +0,0 @@
-"""The endpoint rule, and the fallback that must not exist.
-
-The backend declares the Pipelex service's **origin** — scheme, host and port, with no
-version segment — and each client appends what its own SDK expects beneath it. The rule is normative
-rather than advisory because getting it wrong is not loud: a `/v1`-suffixed endpoint under the
-Anthropic SDK produces `POST /v1/v1/messages`, which a gateway forwards and a provider answers with
-a 200-shaped failure.
-
-**The absent-endpoint case is the one worth a test of its own.** The Portkey-path sibling reads
-`backend.endpoint or PORTKEY_GATEWAY_URL`, which is correct there — an unset endpoint means "use the
-vendor's cloud". The same line on this path would mean that an endpoint that resolves empty
-silently builds a client aimed at `api.portkey.ai` carrying the
-*Pipelex* service token: a live billable request to the wrong vendor, with nothing anywhere
-reporting it. There is no symptom to notice, which is why the refusal is pinned here.
-"""
-
-from __future__ import annotations
-
-import pytest
-
-from pipelex.cogt.model_backends.backend import InferenceBackend
-from pipelex.providers.pipelex_hosted.pipelex_hosted_exceptions import PipelexHostedCredentialsError, PipelexHostedEndpointError
-from pipelex.providers.pipelex_hosted.pipelex_hosted_factory import PipelexHostedFactory
-
-_ORIGIN = "https://pipelex_hosted.example.com"
-_TOKEN = "hosted-service-token"
-
-
-def _backend(*, endpoint: str | None = _ORIGIN, api_key: str | None = _TOKEN) -> InferenceBackend:
- return InferenceBackend(name="pipelex_manifold", endpoint=endpoint, api_key=api_key)
-
-
-class TestPipelexHostedEndpointRule:
- def test_origin_is_returned_as_declared(self) -> None:
- assert PipelexHostedFactory.get_origin(_backend()) == _ORIGIN
-
- @pytest.mark.parametrize("declared", [f"{_ORIGIN}/", f"{_ORIGIN}///", f" {_ORIGIN} "])
- def test_a_trailing_slash_or_surrounding_space_is_forgiven(self, declared: str) -> None:
- """The one shape of a correct answer a human types by accident, normalized rather than refused."""
- assert PipelexHostedFactory.get_origin(_backend(endpoint=declared)) == _ORIGIN
-
- def test_the_version_segment_is_appended_by_the_factory_not_the_operator(self) -> None:
- assert PipelexHostedFactory.get_base_url(_backend()) == f"{_ORIGIN}/v1"
-
- @pytest.mark.parametrize("declared", [None, "", " ", "/"], ids=["unset", "empty", "blank", "slash-only"])
- def test_an_absent_endpoint_is_refused_and_never_defaulted(self, declared: str | None) -> None:
- with pytest.raises(PipelexHostedEndpointError) as exc_info:
- PipelexHostedFactory.get_origin(_backend(endpoint=declared))
-
- # The vendor's cloud must appear nowhere in the outcome — neither as a value nor as a hint.
- assert "portkey" not in exc_info.value.message.lower()
- assert "`endpoint`" in exc_info.value.message
-
- def test_an_absent_api_key_is_refused_by_name(self) -> None:
- with pytest.raises(PipelexHostedCredentialsError, match="`api_key`"):
- PipelexHostedFactory.get_api_key(_backend(api_key=None))
-
- def test_the_only_header_about_us_is_the_service_token(self) -> None:
- """One header, no routing.
-
- The hosted dialect says nothing on the wire about which provider should serve a model —
- the service decides that from the model id in the body and refuses a client that tries to
- say otherwise. Asserting the whole dict rather than one key is what makes a header added
- later a red test rather than a silent widening.
- """
- assert PipelexHostedFactory.make_auth_headers(_backend()) == {"x-pipelex-api-key": _TOKEN}
diff --git a/tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_error_message.py b/tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_error_message.py
deleted file mode 100644
index 86a8d6141..000000000
--- a/tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_error_message.py
+++ /dev/null
@@ -1,109 +0,0 @@
-"""Which message `extract_pipelex_hosted_metadata` reports for a failure on the hosted native routes.
-
-`str()` of an `httpx.HTTPStatusError` is httpx's generic sentence, `Client error '401 Unauthorized'
-for url …`, which never says why the service refused. The gateway and the native routes explain
-themselves in the JSON body instead, so the message is read from there — the nested
-`error.message` first, the top-level `message` second — and `str(exc)` is only the fallback for a
-failure whose body carries neither.
-"""
-
-from __future__ import annotations
-
-from typing import Any
-
-import httpx
-import pytest
-
-from pipelex.providers.pipelex_hosted.pipelex_hosted_error_metadata import extract_pipelex_hosted_metadata
-
-_URL = "https://pipelex_hosted.example.com/v1/pipelex/extract"
-_HTTPX_SENTENCE = f"Client error '401 Unauthorized' for url '{_URL}'"
-_GATEWAY_MESSAGE = "Portkey Error: Invalid API Key. Error Code: 03"
-
-
-def _status_error(*, json_body: Any | None = None, text_body: str | None = None, status_code: int = 401) -> httpx.HTTPStatusError:
- """A native-route refusal as the hosted client raises it: `raise_for_status()` on a plain httpx response."""
- request = httpx.Request("POST", _URL)
- if json_body is not None:
- response = httpx.Response(status_code=status_code, request=request, json=json_body)
- else:
- response = httpx.Response(status_code=status_code, request=request, text=text_body or "")
- return httpx.HTTPStatusError(_HTTPX_SENTENCE, request=request, response=response)
-
-
-class TestTheMessageThePipelexHostedPathReports:
- def test_reports_the_gateways_own_message(self) -> None:
- """The body the gateway sends for a refused key, verbatim — its explanation is what reaches the user."""
- body = {"status": "failure", "message": _GATEWAY_MESSAGE, "error": {"message": _GATEWAY_MESSAGE, "code": "03"}}
-
- metadata = extract_pipelex_hosted_metadata(_status_error(json_body=body))
-
- assert metadata.message == _GATEWAY_MESSAGE
- assert metadata.provider_error_code == "03"
- assert metadata.status_code == 401
-
- def test_prefers_the_nested_error_message_over_the_top_level_one(self) -> None:
- body = {"message": "top-level", "error": {"message": "nested", "code": "pig-01"}}
-
- metadata = extract_pipelex_hosted_metadata(_status_error(json_body=body))
-
- assert metadata.message == "nested"
-
- def test_reads_the_top_level_message_when_the_error_object_has_none(self) -> None:
- body = {"message": "top-level", "error": {"code": "pig-01"}}
-
- metadata = extract_pipelex_hosted_metadata(_status_error(json_body=body))
-
- assert metadata.message == "top-level"
-
- @pytest.mark.parametrize(
- ("topic", "json_body"),
- [
- ("no message anywhere", {"error": {"code": "pig-01"}}),
- ("a blank nested message and no top-level one", {"error": {"message": " "}}),
- ("a null message", {"message": None}),
- ("a message that is not a string", {"error": {"message": 42}, "message": ["a"]}),
- ("a body that is not an object", ["unexpected"]),
- ],
- )
- def test_falls_back_to_the_exception_text_when_the_body_explains_nothing(self, topic: str, json_body: Any) -> None:
- metadata = extract_pipelex_hosted_metadata(_status_error(json_body=json_body))
-
- assert metadata.message == _HTTPX_SENTENCE, topic
-
- def test_falls_back_to_the_exception_text_when_the_body_is_not_json(self) -> None:
- metadata = extract_pipelex_hosted_metadata(_status_error(text_body="<html>Unauthorized</html>"))
-
- assert metadata.message == _HTTPX_SENTENCE
- assert metadata.body is None
-
- def test_a_request_error_keeps_its_own_text(self) -> None:
- """A connect or timeout failure has no response, hence no body to read a message from."""
- exc = httpx.ConnectError("connection refused", request=httpx.Request("POST", _URL))
-
- metadata = extract_pipelex_hosted_metadata(exc)
-
- assert metadata.message == "connection refused"
- assert metadata.status_code is None
-
-
-class TestTheQuotaReadingOfANativeRoute429:
- """The quota check reads `metadata.message`, so on the native routes it now sees the service's words.
-
- Before, it saw httpx's sentence, which never names a quota, so every 429 there read as a
- transient rate limit to retry, even one the service explained as an exhausted quota.
- """
-
- def test_a_429_whose_body_names_a_quota_is_quota_exhaustion(self) -> None:
- body = {"error": {"message": "Monthly quota exceeded for this workspace"}}
-
- metadata = extract_pipelex_hosted_metadata(_status_error(json_body=body, status_code=429))
-
- assert metadata.is_quota_exhaustion
-
- def test_a_429_whose_body_names_no_quota_stays_a_rate_limit(self) -> None:
- body = {"error": {"message": "Too many requests, slow down"}}
-
- metadata = extract_pipelex_hosted_metadata(_status_error(json_body=body, status_code=429))
-
- assert not metadata.is_quota_exhaustion
diff --git a/tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_extract_worker.py b/tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_extract_worker.py
deleted file mode 100644
index 12561bccc..000000000
--- a/tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_extract_worker.py
+++ /dev/null
@@ -1,208 +0,0 @@
-"""The extract worker's three invisible failure modes.
-
-**The usage translation.** The native route reports honest counts (`usage.pages`) and the runtime's
-cost model is per million tokens. Untranslated, `nb_tokens_by_category` simply stays empty — no
-exception, no warning — and the job reports a cost of zero. There is nothing to notice, which is why
-it is pinned here against the figure the Portkey path reports for the same work.
-
-**The withdrawn parameters.** `ExtractJobParams` carries fields the frozen contract deliberately
-does not, and the gateway refuses them at *any* value including their own defaults. A worker that
-reached for `model_dump()` would send `should_caption_images=false` and be refused — at request
-time, in production, with a message about a parameter nobody meant to send.
-
-**The input form.** Which one a model takes follows from what the catalog says, not from a list of
-model names kept in step by hand: a web-page extractor is handed the page's own URL, everything else
-is handed the bytes inline. The gateway holds no credentials for our storage, so a local path or a
-`pipelex-storage://` URI must become bytes on this side.
-"""
-
-from __future__ import annotations
-
-from typing import TYPE_CHECKING, Any
-
-import pytest
-
-from pipelex.cogt.extract.exceptions import ExtractInputError
-from pipelex.cogt.usage.token_category import NbTokensByCategoryDict, TokenCategory
-from pipelex.providers.pipelex_hosted.pipelex_hosted_extract_worker import PIPELEX_HOSTED_UNIT_TOKENS, PipelexHostedExtractWorker
-
-if TYPE_CHECKING:
- from pytest_mock import MockerFixture
-
-_PDF_BYTES_URL = "data:application/pdf;base64,JVBERi0xLjQK"
-
-
-def _make_worker(
- mocker: MockerFixture,
- *,
- is_web_page_supported: bool = False,
- response_body: dict[str, Any] | None = None,
-) -> PipelexHostedExtractWorker:
- worker = object.__new__(PipelexHostedExtractWorker)
- model = mocker.MagicMock()
- model.model_id = "adi/prebuilt-layout"
- model.name = "azure-document-intelligence"
- model.desc = "test-hosted-extract"
- model.is_web_page_supported_for_extract = is_web_page_supported
- worker.inference_model = model
- client = mocker.MagicMock()
- client.post_json = mocker.AsyncMock(return_value=response_body if response_body is not None else {"pages": {}, "usage": {"pages": 3}})
- worker.client = client
- return worker
-
-
-def _post_json(worker: PipelexHostedExtractWorker) -> Any:
- """The stand-in for the native client, as `Any` so its mock attributes typecheck."""
- return worker.client.post_json
-
-
-def _make_extract_job(mocker: MockerFixture, *, document_uri: str | None = None, image_uri: str | None = None) -> Any:
- job = mocker.MagicMock()
- job.extract_input.document_uri = document_uri
- job.extract_input.image_uri = image_uri
- job.job_params.max_nb_images = None
- job.job_params.render_js = None
- job.job_params.include_raw_html = None
- job.job_report.extract_tokens_usage = None
- return job
-
-
[email protected](loop_scope="class")
-class TestPipelexHostedExtractRequestBody:
- async def test_the_withdrawn_parameters_are_absent_rather_than_sent_at_their_defaults(self, mocker: MockerFixture) -> None:
- """`should_caption_images=false` is refused by the gateway exactly as loudly as `true` is."""
- worker = _make_worker(mocker)
- mocker.patch(
- "pipelex.providers.pipelex_hosted.pipelex_hosted_extract_worker.make_base64_url_from_any_uri",
- new_callable=mocker.AsyncMock,
- return_value=_PDF_BYTES_URL,
- )
- mocker.patch("pipelex.providers.pipelex_hosted.pipelex_hosted_extract_worker.get_storage_provider")
-
- await worker._extract_pages(_make_extract_job(mocker, document_uri="/local/report.pdf")) # ruff: ignore[private-member-access] # pyright: ignore[reportPrivateUsage]
-
- body = _post_json(worker).call_args.kwargs["body"]
- rendered = str(body)
- for withdrawn in ("image_min_size", "should_caption_images", "should_include_page_views", "page_views_dpi"):
- assert withdrawn not in rendered, f"the withdrawn parameter '{withdrawn}' reached the wire"
-
- async def test_an_unset_optional_parameter_is_omitted_rather_than_sent_as_null(self, mocker: MockerFixture) -> None:
- """The gateway refuses `render_js` on a provider that cannot honour it, null included."""
- worker = _make_worker(mocker)
- mocker.patch(
- "pipelex.providers.pipelex_hosted.pipelex_hosted_extract_worker.make_base64_url_from_any_uri",
- new_callable=mocker.AsyncMock,
- return_value=_PDF_BYTES_URL,
- )
- mocker.patch("pipelex.providers.pipelex_hosted.pipelex_hosted_extract_worker.get_storage_provider")
-
- await worker._extract_pages(_make_extract_job(mocker, document_uri="/local/report.pdf")) # ruff: ignore[private-member-access] # pyright: ignore[reportPrivateUsage]
-
- body = _post_json(worker).call_args.kwargs["body"]
- assert body["params"] == {}
- assert body["input"] == {"document_uri": _PDF_BYTES_URL}
- assert body["model"] == "adi/prebuilt-layout"
-
- async def test_a_web_page_model_is_handed_the_url_itself(self, mocker: MockerFixture) -> None:
- """The gateway fetches `https:` on this path; turning the page into bytes here would fetch it twice."""
- worker = _make_worker(mocker, is_web_page_supported=True)
- fetch = mocker.patch(
- "pipelex.providers.pipelex_hosted.pipelex_hosted_extract_worker.make_base64_url_from_any_uri",
- new_callable=mocker.AsyncMock,
- )
-
- await worker._extract_pages(_make_extract_job(mocker, document_uri="https://example.com/article")) # ruff: ignore[private-member-access] # pyright: ignore[reportPrivateUsage]
-
- body = _post_json(worker).call_args.kwargs["body"]
- assert body["input"] == {"document_uri": "https://example.com/article"}
- fetch.assert_not_awaited()
-
- async def test_a_non_web_page_model_is_handed_the_bytes_inline(self, mocker: MockerFixture) -> None:
- worker = _make_worker(mocker)
- fetch = mocker.patch(
- "pipelex.providers.pipelex_hosted.pipelex_hosted_extract_worker.make_base64_url_from_any_uri",
- new_callable=mocker.AsyncMock,
- return_value=_PDF_BYTES_URL,
- )
- mocker.patch("pipelex.providers.pipelex_hosted.pipelex_hosted_extract_worker.get_storage_provider")
-
- await worker._extract_pages(_make_extract_job(mocker, document_uri="pipelex-storage://bucket/report.pdf")) # ruff: ignore[private-member-access] # pyright: ignore[reportPrivateUsage]
-
- body = _post_json(worker).call_args.kwargs["body"]
- assert body["input"] == {"document_uri": _PDF_BYTES_URL}
- fetch.assert_awaited_once()
-
- async def test_a_web_page_model_with_no_document_uri_is_refused_by_name(self, mocker: MockerFixture) -> None:
- worker = _make_worker(mocker, is_web_page_supported=True)
-
- with pytest.raises(ExtractInputError, match="document_uri"):
- await worker._extract_pages(_make_extract_job(mocker, image_uri="file:///local/scan.png")) # ruff: ignore[private-member-access] # pyright: ignore[reportPrivateUsage]
-
- async def test_no_input_at_all_is_refused(self, mocker: MockerFixture) -> None:
- worker = _make_worker(mocker)
- mocker.patch("pipelex.providers.pipelex_hosted.pipelex_hosted_extract_worker.get_storage_provider")
-
- with pytest.raises(ExtractInputError):
- await worker._extract_pages(_make_extract_job(mocker)) # ruff: ignore[private-member-access] # pyright: ignore[reportPrivateUsage]
-
-
[email protected](loop_scope="class")
-class TestPipelexHostedExtractUsageTranslation:
- async def test_pages_become_megatokens_in_both_categories(self, mocker: MockerFixture) -> None:
- """The figure the Portkey path reports for the same work, from a different unit.
-
- The costume reports `usage.prompt_tokens = pages * 1_000_000`; the native route reports
- `usage.pages = N`. Both must price the same, or phase 4's mixed-profile comparison means
- nothing. Both categories are filled because that is what the abstract worker's own fallback
- produces.
- """
- worker = _make_worker(mocker)
- mocker.patch(
- "pipelex.providers.pipelex_hosted.pipelex_hosted_extract_worker.make_base64_url_from_any_uri",
- new_callable=mocker.AsyncMock,
- return_value=_PDF_BYTES_URL,
- )
- mocker.patch("pipelex.providers.pipelex_hosted.pipelex_hosted_extract_worker.get_storage_provider")
- job = _make_extract_job(mocker, document_uri="/local/report.pdf")
- usage = mocker.MagicMock()
- job.job_report.extract_tokens_usage = usage
-
- await worker._extract_pages(job) # ruff: ignore[private-member-access] # pyright: ignore[reportPrivateUsage]
-
- assert usage.nb_tokens_by_category == {
- TokenCategory.INPUT: 3 * PIPELEX_HOSTED_UNIT_TOKENS,
- TokenCategory.OUTPUT: 3 * PIPELEX_HOSTED_UNIT_TOKENS,
- }
-
- @pytest.mark.parametrize(
- "response_body",
- [
- {"pages": {}},
- {"pages": {}, "usage": None},
- {"pages": {}, "usage": {}},
- {"pages": {}, "usage": {"pages": "three"}},
- ],
- ids=["no-usage", "null-usage", "empty-usage", "non-numeric-pages"],
- )
- async def test_a_usage_block_the_route_did_not_send_leaves_the_abstract_fallback_in_charge(
- self,
- mocker: MockerFixture,
- response_body: dict[str, Any],
- ) -> None:
- """Silence here is correct: `ExtractWorkerAbstract` counts the pages it received instead."""
- worker = _make_worker(mocker, response_body=response_body)
- mocker.patch(
- "pipelex.providers.pipelex_hosted.pipelex_hosted_extract_worker.make_base64_url_from_any_uri",
- new_callable=mocker.AsyncMock,
- return_value=_PDF_BYTES_URL,
- )
- mocker.patch("pipelex.providers.pipelex_hosted.pipelex_hosted_extract_worker.get_storage_provider")
- job = _make_extract_job(mocker, document_uri="/local/report.pdf")
- usage = mocker.MagicMock()
- empty_categories: NbTokensByCategoryDict = {}
- usage.nb_tokens_by_category = empty_categories
- job.job_report.extract_tokens_usage = usage
-
- await worker._extract_pages(job) # ruff: ignore[private-member-access] # pyright: ignore[reportPrivateUsage]
-
- assert usage.nb_tokens_by_category == {}
diff --git a/tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_extras_by_spec.py b/tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_extras_by_spec.py
deleted file mode 100644
index 8b0f9681d..000000000
--- a/tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_extras_by_spec.py
+++ /dev/null
@@ -1,145 +0,0 @@
-from __future__ import annotations
-
-from typing import TYPE_CHECKING, Any
-
-import pytest
-
-from pipelex.cogt.exceptions import ImgGenParameterError, InferenceErrorCategory
-from pipelex.cogt.img_gen.img_gen_job import ImgGenJob
-from pipelex.cogt.img_gen.img_gen_job_components import AspectRatio, Background, ImgGenJobConfig, ImgGenJobParams, ImgGenJobReport, SizeTier
-from pipelex.cogt.img_gen.img_gen_prompt import ImgGenPrompt
-from pipelex.cogt.llm.llm_job import LLMJob
-from pipelex.cogt.llm.llm_job_components import LLMJobConfig, LLMJobParams, LLMJobReport
-from pipelex.cogt.llm.llm_prompt import LLMPrompt
-from pipelex.cogt.model_backends.backend import PipelexBackend
-from pipelex.cogt.model_backends.model_spec_factory import InferenceModelSpecBlueprint, InferenceModelSpecFactory
-from pipelex.providers.pipelex_hosted.pipelex_hosted_factory import PipelexHostedFactory
-from tests.unit.pipelex.providers.pipelex_hosted.test_data import PipelexHostedExtrasBySpecTestData, PipelexHostedMetadataTestData
-
-if TYPE_CHECKING:
- from pipelex.cogt.image.image_size import ImageSize
- from pipelex.cogt.model_backends.model_spec import InferenceModelSpec
-
-
-def _spec(*, handle: str, entry: dict[str, Any]) -> InferenceModelSpec:
- """The spec the hosted backend would build from this catalog table, through the real factory."""
- return InferenceModelSpecFactory.make_inference_model_spec(
- PipelexBackend.PIPELEX_HOSTED,
- name=handle,
- blueprint=InferenceModelSpecBlueprint.model_validate(entry),
- backend_listed_constraints=[],
- backend_valued_constraints={},
- )
-
-
-def _img_gen_job(*, aspect_ratio: AspectRatio, size: SizeTier | ImageSize | None) -> ImgGenJob:
- return ImgGenJob(
- job_metadata=PipelexHostedMetadataTestData.JOB_METADATA,
- img_gen_prompt=ImgGenPrompt(positive_text="a lighthouse at dusk"),
- job_params=ImgGenJobParams(aspect_ratio=aspect_ratio, size=size, background=Background.AUTO),
- job_config=ImgGenJobConfig(is_sync_mode=True),
- job_report=ImgGenJobReport(),
- )
-
-
-def _llm_job() -> LLMJob:
- return LLMJob(
- job_metadata=PipelexHostedMetadataTestData.JOB_METADATA,
- llm_prompt=LLMPrompt(user_text="ping"),
- job_params=LLMJobParams(temperature=0.5),
- job_config=LLMJobConfig(schema_reask_max_attempts=1),
- job_report=LLMJobReport(),
- )
-
-
-class TestPipelexHostedExtrasBySpec:
- @pytest.mark.parametrize(
- ("handle", "entry", "aspect_ratio", "size", "expected_image_config"),
- PipelexHostedExtrasBySpecTestData.GEMINI_IMAGE_CASES,
- )
- def test_gemini_image_spec_gets_image_config(
- self,
- handle: str,
- entry: dict[str, Any],
- aspect_ratio: AspectRatio,
- size: SizeTier | ImageSize | None,
- expected_image_config: dict[str, str],
- ) -> None:
- """A Gemini taxonomy in the rules sends `image_config`, whether the model id is the provider's or defaults to the handle."""
- spec = _spec(handle=handle, entry=entry)
- assert spec.model_id == entry.get("model_id", handle)
-
- _, extra_body = PipelexHostedFactory.make_extras(spec, inference_job=_img_gen_job(aspect_ratio=aspect_ratio, size=size), output_desc="Image")
-
- assert extra_body == {"image_config": expected_image_config}
-
- @pytest.mark.parametrize(
- ("topic", "handle", "entry"),
- PipelexHostedExtrasBySpecTestData.NON_GEMINI_IMAGE_CASES,
- )
- def test_non_gemini_image_spec_gets_no_image_config(
- self,
- topic: str, # ruff: ignore[unused-method-argument]
- handle: str,
- entry: dict[str, Any],
- ) -> None:
- """A spec whose rules name a non-Gemini taxonomy gets no `image_config`."""
- spec = _spec(handle=handle, entry=entry)
-
- _, extra_body = PipelexHostedFactory.make_extras(
- spec, inference_job=_img_gen_job(aspect_ratio=AspectRatio.SQUARE, size=SizeTier.ONE_K), output_desc="Image"
- )
-
- assert extra_body == {}
-
- @pytest.mark.parametrize("size", [None, SizeTier.ONE_K])
- @pytest.mark.parametrize(
- ("topic", "handle", "entry", "error_match"),
- PipelexHostedExtrasBySpecTestData.UNDECIDABLE_IMAGE_CASES,
- )
- def test_undecidable_image_spec_is_refused_as_a_configuration_fault(
- self,
- topic: str, # ruff: ignore[unused-method-argument]
- handle: str,
- entry: dict[str, Any],
- error_match: str,
- size: SizeTier | None,
- ) -> None:
- """A spec that cannot say whether it is a Gemini one fails the job instead of dropping the ratio and size silently, as the catalog's fault."""
- spec = _spec(handle=handle, entry=entry)
-
- with pytest.raises(ImgGenParameterError, match=error_match) as exc_info:
- PipelexHostedFactory.make_extras(spec, inference_job=_img_gen_job(aspect_ratio=AspectRatio.SQUARE, size=size), output_desc="Image")
-
- assert exc_info.value.error_category == InferenceErrorCategory.CONFIGURATION
-
- def test_size_beyond_the_gemini_taxonomy_is_refused(self) -> None:
- """A handle-only Gemini spec still checks the request against its taxonomy's grids."""
- spec = _spec(handle="nano-banana", entry=PipelexHostedExtrasBySpecTestData.GEMINI_IMAGE_CASES[0][1])
-
- with pytest.raises(ImgGenParameterError, match="does not support image size '2K'"):
- PipelexHostedFactory.make_extras(
- spec, inference_job=_img_gen_job(aspect_ratio=AspectRatio.SQUARE, size=SizeTier.TWO_K), output_desc="Image"
- )
-
- @pytest.mark.parametrize(
- ("topic", "handle", "entry", "expects_seed"),
- PipelexHostedExtrasBySpecTestData.MISTRAL_SEED_CASES,
- )
- def test_mistral_seed_follows_the_model_id_prefix(
- self,
- topic: str, # ruff: ignore[unused-method-argument]
- handle: str,
- entry: dict[str, Any],
- expects_seed: bool,
- ) -> None:
- """The Mistral seed is sent for the hosted Mistral handle with or without a provider model id, and only for it."""
- spec = _spec(handle=handle, entry=entry)
-
- _, extra_body = PipelexHostedFactory.make_extras(spec, inference_job=_llm_job(), output_desc="text")
-
- if expects_seed:
- assert set(extra_body) == {"seed"}
- assert 0 <= extra_body["seed"] <= 1000000
- else:
- assert extra_body == {}
diff --git a/tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_img_gen_worker.py b/tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_img_gen_worker.py
deleted file mode 100644
index 2a0979012..000000000
--- a/tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_img_gen_worker.py
+++ /dev/null
@@ -1,190 +0,0 @@
-"""The image worker's escape paths — the ones that re-bill a generation if they leak.
-
-The HTTP request succeeds in every test here; it is the *body* that is wrong. A raw exception at
-this point is neither a `PipelexError` nor annotated with the model, so it slips past the Temporal
-error bridge (`convert_pipelex_errors`), gets marked retryable, and resubmits a non-idempotent image
-generation — the user pays twice for one picture.
-
-**The `JSONDecodeError` arm is the one with no symptom.** A 2xx carrying an intermediary's HTML
-error page makes the SDK's own decode raise, and `json.JSONDecodeError` is not an `APIError`, so it
-falls straight through the `except (portkey_exceptions.APIError, portkey_vendored_openai.APIError)`
-arm that catches everything else. Nothing about the code reads as missing a case.
-"""
-
-from __future__ import annotations
-
-import json
-from typing import TYPE_CHECKING, Any
-
-import httpx
-import pytest
-from portkey_ai.api_resources import exceptions as portkey_exc
-
-from pipelex.cogt.exceptions import ImgGenGenerationError, InferenceErrorCategory
-from pipelex.cogt.inference.error_classification import UserActionKind
-from pipelex.providers.pipelex_hosted.pipelex_hosted_img_gen_worker import PipelexHostedImgGenWorker
-from tests.unit.pipelex.providers.pipelex_hosted.test_data import PipelexHostedMetadataTestData
-
-if TYPE_CHECKING:
- from pytest_mock import MockerFixture
-
-# A one-pixel PNG, so the success path reaches the real image decoding rather than stopping earlier.
-_PNG_1PX = "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z8BQDwAEhQGAhKmMIQAAAABJRU5ErkJggg=="
-
-_AZURE_GPT_IMAGE_BODY = {
- "data": [{"b64_json": _PNG_1PX}],
- "size": "1024x1024",
- "output_format": "png",
- "usage": {"input_tokens": 11, "output_tokens": 22},
-}
-
-
-def _make_worker(mocker: MockerFixture) -> PipelexHostedImgGenWorker:
- worker = object.__new__(PipelexHostedImgGenWorker)
- model = mocker.MagicMock()
- model.model_id = "gpt-image-1"
- model.name = "gpt-image-1"
- model.desc = "test-hosted-img-gen"
- model.rules = mocker.MagicMock()
- worker.inference_model = model
- client = mocker.MagicMock()
- client.images.generate = mocker.AsyncMock()
- client.images.edit = mocker.AsyncMock()
- worker.portkey_client = client
- return worker
-
-
-def _images(worker: PipelexHostedImgGenWorker) -> Any:
- """The stand-in for the vendor client's Images resource, as `Any` so its mocks typecheck."""
- return worker.portkey_client.images
-
-
-def _make_img_gen_job(mocker: MockerFixture) -> Any:
- job = mocker.MagicMock()
- job.img_gen_prompt.positive_text = "a torus, rendered"
- job.job_report.img_gen_tokens_usage = None
- job.job_metadata = PipelexHostedMetadataTestData.JOB_METADATA
- return job
-
-
-def _patch_args_factory(mocker: MockerFixture, *, args: dict[str, Any] | None = None) -> None:
- mocker.patch(
- "pipelex.providers.pipelex_hosted.pipelex_hosted_img_gen_worker.ImgGenArgsFactory.make_args_for_model",
- new_callable=mocker.AsyncMock,
- return_value=args if args is not None else {"prompt": "a torus, rendered"},
- )
-
-
-# Each body is a 2xx the worker must refuse rather than let escape, with the advice it deserves:
-# a shape it cannot read at all is the model's fault, a stripped image is the prompt's.
-_MALFORMED_BODIES: list[tuple[dict[str, Any], UserActionKind]] = [
- ({"data": [], "size": "1024x1024", "output_format": "png"}, UserActionKind.CHANGE_MODEL),
- ({"data": [{}], "size": "1024x1024", "output_format": "png"}, UserActionKind.CHANGE_INPUT),
- ({"data": [{"b64_json": _PNG_1PX}], "size": "wide x tall", "output_format": "png"}, UserActionKind.CHANGE_MODEL),
- ({"data": [{"b64_json": _PNG_1PX}], "output_format": "png"}, UserActionKind.CHANGE_MODEL),
-]
-
-
-def _make_response(mocker: MockerFixture, body: dict[str, Any]) -> Any:
- response = mocker.MagicMock()
- response.model_dump.return_value = body
- return response
-
-
[email protected](loop_scope="class")
-class TestPipelexHostedImgGenWorkerSuccess:
- async def test_an_azure_gpt_image_body_becomes_generated_images(self, mocker: MockerFixture) -> None:
- worker = _make_worker(mocker)
- _patch_args_factory(mocker)
- _images(worker).generate.return_value = _make_response(mocker, _AZURE_GPT_IMAGE_BODY)
-
- images = await worker._gen_image_list(img_gen_job=_make_img_gen_job(mocker), nb_images=1) # ruff: ignore[private-member-access] # pyright: ignore[reportPrivateUsage]
-
- assert len(images) == 1
- generated = images[0]
- assert generated.base64_str == _PNG_1PX
- assert generated.size is not None
- assert (generated.size.width, generated.size.height) == (1024, 1024)
- assert generated.image_format == "png"
-
- async def test_input_images_route_to_the_edits_endpoint(self, mocker: MockerFixture) -> None:
- """The two Images routes are not interchangeable: /images/generations rejects input images."""
- worker = _make_worker(mocker)
- _patch_args_factory(mocker, args={"prompt": "edit it", "image": [("a.png", b"\x89PNG", "image/png")]})
- _images(worker).edit.return_value = _make_response(mocker, _AZURE_GPT_IMAGE_BODY)
-
- await worker._gen_image_list(img_gen_job=_make_img_gen_job(mocker), nb_images=1) # ruff: ignore[private-member-access] # pyright: ignore[reportPrivateUsage]
-
- _images(worker).edit.assert_awaited_once()
- _images(worker).generate.assert_not_awaited()
-
- async def test_several_input_images_travel_as_a_list_not_as_repeated_bare_parts(self, mocker: MockerFixture) -> None:
- """A server handed repeated bare `image` parts keeps one and drops the rest — silently.
-
- The SDK serializes a list under `image` as `image[]` parts and a single file as the bare
- field, so passing the list is what makes an edit of several images an edit of several
- images rather than a plausible edit of the first.
- """
- worker = _make_worker(mocker)
- files = [("a.png", b"\x89PNG", "image/png"), ("b.png", b"\x89PNG", "image/png")]
- _patch_args_factory(mocker, args={"prompt": "edit them", "image": files})
- _images(worker).edit.return_value = _make_response(mocker, _AZURE_GPT_IMAGE_BODY)
-
- await worker._gen_image_list(img_gen_job=_make_img_gen_job(mocker), nb_images=2) # ruff: ignore[private-member-access] # pyright: ignore[reportPrivateUsage]
-
- assert _images(worker).edit.call_args.kwargs["image"] == files
-
-
[email protected](loop_scope="class")
-class TestPipelexHostedImgGenWorkerFailures:
- async def test_a_non_json_2xx_becomes_a_categorized_error(self, mocker: MockerFixture) -> None:
- """The arm with no symptom: a decode failure is not an `APIError` and catches nowhere else."""
- worker = _make_worker(mocker)
- _patch_args_factory(mocker)
- _images(worker).generate.side_effect = json.JSONDecodeError("Expecting value", "<html>", 0)
-
- with pytest.raises(ImgGenGenerationError) as exc_info:
- await worker._gen_image_list(img_gen_job=_make_img_gen_job(mocker), nb_images=1) # ruff: ignore[private-member-access] # pyright: ignore[reportPrivateUsage]
-
- assert exc_info.value.error_category is InferenceErrorCategory.UNKNOWN
- assert exc_info.value.user_action is not None
- assert exc_info.value.user_action.kind is UserActionKind.CONTACT_SUPPORT
- assert "gpt-image-1" in exc_info.value.message
-
- async def test_a_provider_status_error_is_classified_rather_than_raised_raw(self, mocker: MockerFixture) -> None:
- worker = _make_worker(mocker)
- _patch_args_factory(mocker)
- request = httpx.Request("POST", "https://pipelex_hosted.example.com/v1/images/generations")
- response = httpx.Response(status_code=429, request=request, headers={"x-request-id": "mf-1"})
- _images(worker).generate.side_effect = portkey_exc.RateLimitError(
- message="http 429",
- request=request,
- response=response,
- body={},
- )
-
- with pytest.raises(ImgGenGenerationError) as exc_info:
- await worker._gen_image_list(img_gen_job=_make_img_gen_job(mocker), nb_images=1) # ruff: ignore[private-member-access] # pyright: ignore[reportPrivateUsage]
-
- assert exc_info.value.error_category is InferenceErrorCategory.TRANSIENT
-
- @pytest.mark.parametrize(
- ("body", "expected_kind"),
- _MALFORMED_BODIES,
- ids=["no-images", "image-without-data", "non-numeric-size", "no-size-at-all"],
- )
- async def test_a_malformed_success_body_is_wrapped_rather_than_escaping(
- self,
- mocker: MockerFixture,
- body: dict[str, Any],
- expected_kind: UserActionKind,
- ) -> None:
- worker = _make_worker(mocker)
- _patch_args_factory(mocker)
- _images(worker).generate.return_value = _make_response(mocker, body)
-
- with pytest.raises(ImgGenGenerationError) as exc_info:
- await worker._gen_image_list(img_gen_job=_make_img_gen_job(mocker), nb_images=1) # ruff: ignore[private-member-access] # pyright: ignore[reportPrivateUsage]
-
- assert exc_info.value.user_action is not None
- assert exc_info.value.user_action.kind is expected_kind
diff --git a/tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_metadata.py b/tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_metadata.py
deleted file mode 100644
index 1fb22bd9a..000000000
--- a/tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_metadata.py
+++ /dev/null
@@ -1,121 +0,0 @@
-"""The `x-pipelex-metadata` value: its exact shape, who wins a collision, and why it cannot forge a line.
-
-The header is how The Pipelex service attributes spend and logs a call, so its value is asserted as
-the wire string. The collision rule is the security-relevant one: `extras` is caller data whose key
-charset admits every one of the runtime's key names, so a label named `user_id` must never restate
-the run's identity to the service that bills for it.
-"""
-
-from __future__ import annotations
-
-import json
-
-import pytest
-
-from pipelex.providers.pipelex_hosted.pipelex_hosted_constants import PIPELEX_HOSTED_AUTH_HEADER, PIPELEX_HOSTED_METADATA_HEADER
-from pipelex.providers.pipelex_hosted.pipelex_hosted_metadata import (
- encode_pipelex_hosted_metadata,
- make_pipelex_hosted_metadata,
- make_pipelex_hosted_metadata_headers,
-)
-from pipelex.system.job_metadata import JobMetadata, RunMetadata
-from pipelex.system.run_extras import RUN_EXTRAS_KEY_PATTERN
-from tests.unit.pipelex.providers.pipelex_hosted.test_data import PipelexHostedMetadataTestData
-
-_RUNTIME_KEYS = ("user_id", "pipeline_run_id", "pipe_run_id", "pipe_code", "content_generation_job_id")
-
-
-def _job_metadata(
- *,
- extras: dict[str, str] | None = None,
- user_id: str = "user_42",
- pipe_code: str | None = None,
- pipe_run_id: str | None = None,
- content_generation_job_id: str | None = None,
-) -> JobMetadata:
- return JobMetadata(
- run_metadata=RunMetadata(
- storage_scope="test/scope",
- read_scope=None,
- user_id=user_id,
- pipeline_run_id="run_abc",
- extras=extras or {},
- ),
- pipe_code=pipe_code,
- pipe_run_id=pipe_run_id,
- content_generation_job_id=content_generation_job_id,
- )
-
-
-class TestPipelexHostedMetadata:
- def test_the_header_is_named_by_the_dialect_and_never_by_the_vendor(self) -> None:
- assert PIPELEX_HOSTED_METADATA_HEADER == "x-pipelex-metadata"
- assert PIPELEX_HOSTED_METADATA_HEADER != PIPELEX_HOSTED_AUTH_HEADER
-
- def test_a_job_with_extras_yields_the_exact_wire_value(self) -> None:
- headers = make_pipelex_hosted_metadata_headers(job_metadata=PipelexHostedMetadataTestData.JOB_METADATA)
-
- assert headers == {PIPELEX_HOSTED_METADATA_HEADER: PipelexHostedMetadataTestData.EXPECTED_HEADER_VALUE}
- decoded = json.loads(headers[PIPELEX_HOSTED_METADATA_HEADER])
- assert decoded == {
- "org_id": "org_acme",
- "api_key_id": "key_123",
- "user_id": "user_42",
- "pipeline_run_id": "run_abc",
- "pipe_run_id": "0123456789abcdef",
- "pipe_code": "summarize_doc",
- "content_generation_job_id": "cgj_1",
- }
-
- def test_every_runtime_key_is_a_legal_extras_key_so_a_collision_is_possible(self) -> None:
- """The premise of the collision rule: the extras charset does not keep these names out."""
- for runtime_key in _RUNTIME_KEYS:
- assert RUN_EXTRAS_KEY_PATTERN.fullmatch(runtime_key), runtime_key
-
- def test_the_runtime_ids_win_over_colliding_extras_keys(self) -> None:
- job_metadata = _job_metadata(
- extras={"user_id": "spoofed_user", "pipeline_run_id": "spoofed_run", "org_id": "org_acme"},
- pipe_code="real_pipe",
- pipe_run_id="real_pipe_run",
- content_generation_job_id="real_cgj",
- )
-
- metadata = make_pipelex_hosted_metadata(job_metadata=job_metadata)
-
- assert metadata == {
- "org_id": "org_acme",
- "user_id": "user_42",
- "pipeline_run_id": "run_abc",
- "pipe_run_id": "real_pipe_run",
- "pipe_code": "real_pipe",
- "content_generation_job_id": "real_cgj",
- }
-
- def test_a_none_id_is_omitted_and_a_colliding_extras_key_does_not_stand_in_for_it(self) -> None:
- """An id the job lacks is absent, never `null`, and never filled by the caller's label of that name."""
- job_metadata = _job_metadata(extras={"pipe_code": "spoofed_pipe", "org_id": "org_acme"})
-
- metadata = make_pipelex_hosted_metadata(job_metadata=job_metadata)
-
- assert metadata == {"org_id": "org_acme", "user_id": "user_42", "pipeline_run_id": "run_abc"}
- assert "null" not in make_pipelex_hosted_metadata_headers(job_metadata=job_metadata)[PIPELEX_HOSTED_METADATA_HEADER]
-
- def test_empty_extras_yield_the_runtime_ids_alone(self) -> None:
- headers = make_pipelex_hosted_metadata_headers(job_metadata=_job_metadata(pipe_code="p", pipe_run_id="r"))
-
- assert headers == {PIPELEX_HOSTED_METADATA_HEADER: '{"user_id":"user_42","pipeline_run_id":"run_abc","pipe_run_id":"r","pipe_code":"p"}'}
-
- @pytest.mark.parametrize(
- "hostile_user_id",
- ["user\r\nx-injected: 1", "user\nforged", "café-☃", "del\x7fchar", "tab\there"],
- ids=["crlf", "lf", "non-ascii", "del", "tab"],
- )
- def test_the_value_is_printable_ascii_whatever_went_in(self, hostile_user_id: str) -> None:
- """`user_id` has no charset of its own, so the encoding is what keeps the header one line."""
- value = make_pipelex_hosted_metadata_headers(job_metadata=_job_metadata(user_id=hostile_user_id))[PIPELEX_HOSTED_METADATA_HEADER]
-
- assert all(0x20 <= ord(char) <= 0x7E for char in value), value
- assert json.loads(value)["user_id"] == hostile_user_id
-
- def test_the_encoding_is_compact_json(self) -> None:
- assert encode_pipelex_hosted_metadata(metadata={"a": "1", "b": "2"}) == '{"a":"1","b":"2"}'
diff --git a/tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_metadata_scope.py b/tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_metadata_scope.py
deleted file mode 100644
index d4c9bd970..000000000
--- a/tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_metadata_scope.py
+++ /dev/null
@@ -1,132 +0,0 @@
-"""Only the hosted dialect sends `x-pipelex-metadata`: no direct-provider or Portkey path does.
-
-The run's identity and the host's labels are forwarded to our own gateway, which bills and logs the
-call; a vendor reached directly with the caller's own key has no use for them and must not receive
-them. The Anthropic worker is the path most at risk, because it serves both a direct Anthropic
-backend and Claude behind the Pipelex service from the same code: only the extras factory the hosted package
-builds it with adds the header, so a worker built without one sends nothing, whatever its backend.
-"""
-
-from __future__ import annotations
-
-from typing import TYPE_CHECKING, Any
-
-import pytest
-from anthropic import AsyncAnthropic
-from anthropic.types import Message, ToolUseBlock, Usage
-
-from pipelex.cogt.llm.llm_job import LLMJob
-from pipelex.cogt.llm.llm_job_components import LLMJobConfig, LLMJobParams, LLMJobReport
-from pipelex.cogt.llm.llm_prompt import LLMPrompt
-from pipelex.cogt.llm.structured_output import StructureMethod
-from pipelex.providers.anthropic.anthropic_llm_worker import AnthropicLLMWorker
-from pipelex.providers.openai.openai_completions_factory import OpenAICompletionsFactory
-from pipelex.providers.openai.openai_responses_factory import OpenAIResponsesFactory
-from pipelex.providers.pipelex_hosted.pipelex_hosted_constants import PIPELEX_HOSTED_METADATA_HEADER
-from pipelex.providers.portkey.portkey_factory import PortkeyFactory
-from tests.helpers.instructor_test_utils import DummySchema
-from tests.unit.pipelex.providers.pipelex_hosted.test_data import PipelexHostedMetadataTestData
-
-if TYPE_CHECKING:
- from pytest_mock import MockerFixture
-
-
-class _RequestCapturedError(Exception):
- """Raised by a stubbed SDK call once it has recorded its arguments."""
-
-
-def _llm_job() -> LLMJob:
- return LLMJob(
- job_metadata=PipelexHostedMetadataTestData.JOB_METADATA,
- llm_prompt=LLMPrompt(user_text="ping"),
- job_params=LLMJobParams(temperature=0.5),
- job_config=LLMJobConfig(schema_reask_max_attempts=1),
- job_report=LLMJobReport(),
- )
-
-
-def _model(mocker: MockerFixture, *, backend_name: str) -> Any:
- model = mocker.MagicMock()
- model.desc = "test-model-desc"
- model.model_id = "claude-test"
- model.name = "claude-test"
- model.backend_name = backend_name
- model.thinking_mode = None
- model.listed_constraints = []
- model.extra_headers = None
- model.structure_method = StructureMethod.INSTRUCTOR_ANTHROPIC_TOOLS
- return model
-
-
-def _anthropic_worker(mocker: MockerFixture, *, sdk_client: AsyncAnthropic, backend_name: str) -> AnthropicLLMWorker:
- from instructor import from_anthropic # ruff: ignore[import-outside-top-level]
-
- worker = object.__new__(AnthropicLLMWorker)
- worker.inference_model = _model(mocker, backend_name=backend_name)
- worker.extras_factory = None
- worker.default_max_tokens = 4096
- worker.anthropic_async_client = sdk_client
- worker.instructor_for_objects = from_anthropic(client=sdk_client, mode=StructureMethod.INSTRUCTOR_ANTHROPIC_TOOLS.as_instructor_mode())
- config = mocker.MagicMock()
- config.inference.llm.anthropic.structured_output_timeout_seconds = 1200
- mocker.patch("pipelex.providers.anthropic.anthropic_llm_worker.get_config", return_value=config)
- return worker
-
-
-def _tool_call_message() -> Message:
- return Message(
- id="msg_test",
- type="message",
- role="assistant",
- model="claude-test",
- content=[ToolUseBlock(type="tool_use", id="toolu_test", name="DummySchema", input={"text": "answer"})],
- stop_reason="tool_use",
- stop_sequence=None,
- usage=Usage(input_tokens=1, output_tokens=1),
- )
-
-
[email protected](loop_scope="class")
-class TestPipelexHostedMetadataScope:
- @pytest.mark.parametrize(
- "factory",
- [
- OpenAICompletionsFactory(is_http_url_enabled=False),
- OpenAIResponsesFactory(is_http_url_enabled=False),
- PortkeyFactory,
- ],
- ids=["openai-completions", "openai-responses", "portkey"],
- )
- async def test_other_backends_extras_carry_no_metadata_header(self, mocker: MockerFixture, factory: Any) -> None:
- model = _model(mocker, backend_name="openai")
- model.model_id = "gpt-4o"
-
- extra_headers, _ = factory.make_extras(inference_model=model, inference_job=_llm_job(), output_desc="text")
-
- assert PIPELEX_HOSTED_METADATA_HEADER not in extra_headers
- assert "x-portkey-metadata" not in extra_headers
-
- @pytest.mark.parametrize("backend_name", ["anthropic", "bedrock", "pipelex_manifold"])
- async def test_a_plain_anthropic_worker_sends_no_headers_on_the_text_call(self, mocker: MockerFixture, backend_name: str) -> None:
- sdk_client = AsyncAnthropic(api_key="test-key")
- stream = mocker.MagicMock(side_effect=_RequestCapturedError)
- mocker.patch.object(sdk_client.messages, "stream", new=stream)
- worker = _anthropic_worker(mocker, sdk_client=sdk_client, backend_name=backend_name)
-
- with pytest.raises(_RequestCapturedError):
- await worker._gen_text(_llm_job()) # ruff: ignore[private-member-access] # pyright: ignore[reportPrivateUsage]
-
- assert "extra_headers" not in stream.call_args.kwargs
-
- @pytest.mark.parametrize("backend_name", ["anthropic", "pipelex_manifold"])
- async def test_a_plain_anthropic_worker_sends_no_headers_on_the_structured_call(self, mocker: MockerFixture, backend_name: str) -> None:
- sdk_client = AsyncAnthropic(api_key="test-key")
- create = mocker.AsyncMock(return_value=_tool_call_message())
- mocker.patch.object(sdk_client.messages, "create", new=create)
- worker = _anthropic_worker(mocker, sdk_client=sdk_client, backend_name=backend_name)
-
- await worker._gen_object(_llm_job(), schema=DummySchema) # ruff: ignore[private-member-access] # pyright: ignore[reportPrivateUsage]
-
- await_args = create.await_args
- assert await_args is not None
- assert PIPELEX_HOSTED_METADATA_HEADER not in str(await_args.kwargs.get("extra_headers"))
diff --git a/tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_metadata_sdk_paths.py b/tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_metadata_sdk_paths.py
deleted file mode 100644
index 3482c1467..000000000
--- a/tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_metadata_sdk_paths.py
+++ /dev/null
@@ -1,232 +0,0 @@
-"""Every path the hosted dialect calls the service on carries `x-pipelex-metadata` for its job.
-
-The header differs per job, so it cannot be a client default: each path adds it per request, and
-each is pinned here where the request leaves the runtime — the kwargs handed to the SDK call, or the
-headers handed to `httpx` on the native routes. The paths are the OpenAI-substrate chat completions
-(text, and image generation over completions) and responses, the vendor-SDK image path, the native
-extract and search routes, and Claude over the Anthropic worker the package registers as `manifold_anthropic`.
-"""
-
-from __future__ import annotations
-
-from typing import TYPE_CHECKING, Any
-
-import httpx
-import pytest
-from anthropic import AsyncAnthropic
-from anthropic.types import Message, ToolUseBlock, Usage
-
-from pipelex.cogt.llm.llm_job import LLMJob
-from pipelex.cogt.llm.llm_job_components import LLMJobConfig, LLMJobParams, LLMJobReport
-from pipelex.cogt.llm.llm_prompt import LLMPrompt
-from pipelex.cogt.llm.structured_output import StructureMethod
-from pipelex.cogt.model_backends.backend import InferenceBackend, PipelexBackend
-from pipelex.providers.anthropic.anthropic_llm_worker import AnthropicLLMWorker
-from pipelex.providers.openai.openai_completions_llm_worker import OpenAICompletionsLLMWorker
-from pipelex.providers.pipelex_hosted.pipelex_hosted_anthropic_extras import PipelexHostedAnthropicExtrasFactory
-from pipelex.providers.pipelex_hosted.pipelex_hosted_completions_factory import PipelexHostedCompletionsFactory
-from pipelex.providers.pipelex_hosted.pipelex_hosted_constants import PIPELEX_HOSTED_METADATA_HEADER
-from pipelex.providers.pipelex_hosted.pipelex_hosted_extract_worker import PipelexHostedExtractWorker
-from pipelex.providers.pipelex_hosted.pipelex_hosted_img_gen_worker import PipelexHostedImgGenWorker
-from pipelex.providers.pipelex_hosted.pipelex_hosted_native_client import PipelexHostedNativeClient
-from pipelex.providers.pipelex_hosted.pipelex_hosted_responses_factory import PipelexHostedResponsesFactory
-from pipelex.providers.pipelex_hosted.pipelex_hosted_search_worker import PipelexHostedSearchWorker
-from tests.helpers.instructor_test_utils import DummySchema
-from tests.unit.pipelex.providers.pipelex_hosted.test_data import PipelexHostedMetadataTestData
-
-if TYPE_CHECKING:
- from pytest_mock import MockerFixture
-
-_EXPECTED = {PIPELEX_HOSTED_METADATA_HEADER: PipelexHostedMetadataTestData.EXPECTED_HEADER_VALUE}
-_ORIGIN = "https://pipelex_hosted.example.com"
-
-
-class _RequestCapturedError(Exception):
- """Raised by a stubbed SDK call once it has recorded its arguments, so no response has to be faked."""
-
-
-def _llm_job() -> LLMJob:
- return LLMJob(
- job_metadata=PipelexHostedMetadataTestData.JOB_METADATA,
- llm_prompt=LLMPrompt(user_text="ping"),
- job_params=LLMJobParams(temperature=0.5),
- job_config=LLMJobConfig(schema_reask_max_attempts=1),
- job_report=LLMJobReport(),
- )
-
-
-def _model(mocker: MockerFixture, *, backend_name: str = PipelexBackend.PIPELEX_HOSTED, model_id: str = "gpt-4o") -> Any:
- model = mocker.MagicMock()
- model.desc = "test-model-desc"
- model.model_id = model_id
- model.name = model_id
- model.backend_name = backend_name
- model.thinking_mode = None
- model.listed_constraints = []
- model.extra_headers = None
- return model
-
-
-def _native_client() -> PipelexHostedNativeClient:
- return PipelexHostedNativeClient(backend=InferenceBackend(name="pipelex_manifold", endpoint=_ORIGIN, api_key="token"))
-
-
-def _patch_httpx_post(mocker: MockerFixture, *, json_body: dict[str, Any]) -> Any:
- response = httpx.Response(status_code=200, request=httpx.Request("POST", _ORIGIN), json=json_body)
- return mocker.patch.object(httpx.AsyncClient, "post", new_callable=mocker.AsyncMock, return_value=response)
-
-
-def _anthropic_worker(mocker: MockerFixture, *, sdk_client: AsyncAnthropic, backend_name: str) -> AnthropicLLMWorker:
- from instructor import from_anthropic # ruff: ignore[import-outside-top-level]
-
- worker = object.__new__(AnthropicLLMWorker)
- model = _model(mocker, backend_name=backend_name, model_id="claude-test")
- model.structure_method = StructureMethod.INSTRUCTOR_ANTHROPIC_TOOLS
- worker.inference_model = model
- worker.extras_factory = PipelexHostedAnthropicExtrasFactory()
- worker.default_max_tokens = 4096
- worker.instructor_for_objects = from_anthropic(client=sdk_client, mode=StructureMethod.INSTRUCTOR_ANTHROPIC_TOOLS.as_instructor_mode())
- config = mocker.MagicMock()
- config.inference.llm.anthropic.structured_output_timeout_seconds = 1200
- mocker.patch("pipelex.providers.anthropic.anthropic_llm_worker.get_config", return_value=config)
- return worker
-
-
-def _tool_call_message() -> Message:
- return Message(
- id="msg_test",
- type="message",
- role="assistant",
- model="claude-test",
- content=[ToolUseBlock(type="tool_use", id="toolu_test", name="DummySchema", input={"text": "answer"})],
- stop_reason="tool_use",
- stop_sequence=None,
- usage=Usage(input_tokens=1, output_tokens=1),
- )
-
-
[email protected](loop_scope="class")
-class TestPipelexHostedMetadataSdkPaths:
- @pytest.mark.parametrize(
- "factory",
- [PipelexHostedCompletionsFactory(is_http_url_enabled=False), PipelexHostedResponsesFactory(is_http_url_enabled=False)],
- ids=["completions", "responses"],
- )
- async def test_the_openai_substrate_extras_carry_the_header(self, mocker: MockerFixture, factory: Any) -> None:
- """`make_extras` feeds every OpenAI-substrate call: completions text and objects, image gen over completions, responses."""
- extra_headers, _ = factory.make_extras(inference_model=_model(mocker), inference_job=_llm_job(), output_desc="text")
-
- assert extra_headers == _EXPECTED
-
- async def test_a_catalog_header_of_the_same_name_does_not_override_the_job(self, mocker: MockerFixture) -> None:
- model = _model(mocker)
- model.extra_headers = {"anthropic-beta": "some-beta", PIPELEX_HOSTED_METADATA_HEADER: '{"user_id":"catalog"}'}
-
- extra_headers, _ = PipelexHostedCompletionsFactory(is_http_url_enabled=False).make_extras(
- inference_model=model, inference_job=_llm_job(), output_desc="text"
- )
-
- assert extra_headers == {"anthropic-beta": "some-beta", **_EXPECTED}
-
- async def test_the_completions_worker_sends_the_header_on_the_sdk_call(self, mocker: MockerFixture) -> None:
- worker = object.__new__(OpenAICompletionsLLMWorker)
- worker.inference_model = _model(mocker)
- worker.openai_completions_factory = PipelexHostedCompletionsFactory(is_http_url_enabled=False)
- client = mocker.MagicMock()
- client.chat.completions.create = mocker.AsyncMock(side_effect=_RequestCapturedError)
- worker.openai_client_for_text = client
-
- with pytest.raises(_RequestCapturedError):
- await worker._gen_text(_llm_job()) # ruff: ignore[private-member-access] # pyright: ignore[reportPrivateUsage]
-
- assert client.chat.completions.create.call_args.kwargs["extra_headers"] == _EXPECTED
-
- @pytest.mark.parametrize(
- ("args", "route"),
- [({"prompt": "draw"}, "generate"), ({"prompt": "edit", "image": [("a.png", b"\x89PNG", "image/png")]}, "edit")],
- ids=["generate", "edit"],
- )
- async def test_the_image_worker_sends_the_header_on_both_images_routes(self, mocker: MockerFixture, args: dict[str, Any], route: str) -> None:
- worker = object.__new__(PipelexHostedImgGenWorker)
- worker.inference_model = _model(mocker, model_id="gpt-image-1")
- client: Any = mocker.MagicMock()
- client.images.generate = mocker.AsyncMock(side_effect=_RequestCapturedError)
- client.images.edit = mocker.AsyncMock(side_effect=_RequestCapturedError)
- worker.portkey_client = client
- mocker.patch(
- "pipelex.providers.pipelex_hosted.pipelex_hosted_img_gen_worker.ImgGenArgsFactory.make_args_for_model",
- new_callable=mocker.AsyncMock,
- return_value=args,
- )
- job = mocker.MagicMock()
- job.job_metadata = PipelexHostedMetadataTestData.JOB_METADATA
-
- with pytest.raises(_RequestCapturedError):
- await worker._gen_image_list(img_gen_job=job, nb_images=1) # ruff: ignore[private-member-access] # pyright: ignore[reportPrivateUsage]
-
- assert getattr(client.images, route).call_args.kwargs["extra_headers"] == _EXPECTED
-
- async def test_the_extract_route_sends_the_header_on_the_wire(self, mocker: MockerFixture) -> None:
- post = _patch_httpx_post(mocker, json_body={"pages": {}})
- worker = object.__new__(PipelexHostedExtractWorker)
- model = _model(mocker, model_id="firecrawl/scrape")
- model.is_web_page_supported_for_extract = True
- worker.inference_model = model
- worker.client = _native_client()
- job = mocker.MagicMock()
- job.job_metadata = PipelexHostedMetadataTestData.JOB_METADATA
- job.extract_input.document_uri = "https://example.com/page"
- job.job_params.max_nb_images = None
- job.job_params.render_js = None
- job.job_params.include_raw_html = None
- job.job_report.extract_tokens_usage = None
-
- await worker._extract_pages(job) # ruff: ignore[private-member-access] # pyright: ignore[reportPrivateUsage]
-
- assert post.call_args.kwargs["headers"][PIPELEX_HOSTED_METADATA_HEADER] == PipelexHostedMetadataTestData.EXPECTED_HEADER_VALUE
-
- async def test_the_search_route_sends_the_header_on_the_wire(self, mocker: MockerFixture) -> None:
- post = _patch_httpx_post(mocker, json_body={"answer": "a torus is a surface", "sources": []})
- worker = object.__new__(PipelexHostedSearchWorker)
- worker.inference_model = _model(mocker, model_id="linkup/standard")
- worker.client = _native_client()
- job = mocker.MagicMock()
- job.job_metadata = PipelexHostedMetadataTestData.JOB_METADATA
- job.query = "what is a torus"
- job.job_params.search_setting.include_images = False
- job.job_params.search_setting.include_inline_citations = False
- job.job_params.search_setting.max_results = 10
- job.job_params.include_domains = None
- job.job_params.exclude_domains = None
- job.job_params.from_date = None
- job.job_params.to_date = None
- job.job_report.search_tokens_usage = None
-
- await worker._search_sourced_answer(job) # ruff: ignore[private-member-access] # pyright: ignore[reportPrivateUsage]
-
- assert post.call_args.kwargs["headers"][PIPELEX_HOSTED_METADATA_HEADER] == PipelexHostedMetadataTestData.EXPECTED_HEADER_VALUE
-
- async def test_claude_behind_pipelex_hosted_sends_the_header_on_the_text_call(self, mocker: MockerFixture) -> None:
- sdk_client = AsyncAnthropic(api_key="test-key")
- stream = mocker.MagicMock(side_effect=_RequestCapturedError)
- mocker.patch.object(sdk_client.messages, "stream", new=stream)
- worker = _anthropic_worker(mocker, sdk_client=sdk_client, backend_name=PipelexBackend.PIPELEX_HOSTED)
- worker.anthropic_async_client = sdk_client
-
- with pytest.raises(_RequestCapturedError):
- await worker._gen_text(_llm_job()) # ruff: ignore[private-member-access] # pyright: ignore[reportPrivateUsage]
-
- assert stream.call_args.kwargs["extra_headers"] == _EXPECTED
-
- async def test_claude_behind_pipelex_hosted_sends_the_header_on_the_structured_call(self, mocker: MockerFixture) -> None:
- """Through a real instructor client, so what is asserted is what reaches the SDK's `messages.create`."""
- sdk_client = AsyncAnthropic(api_key="test-key")
- create = mocker.AsyncMock(return_value=_tool_call_message())
- mocker.patch.object(sdk_client.messages, "create", new=create)
- worker = _anthropic_worker(mocker, sdk_client=sdk_client, backend_name=PipelexBackend.PIPELEX_HOSTED)
-
- await worker._gen_object(_llm_job(), schema=DummySchema) # ruff: ignore[private-member-access] # pyright: ignore[reportPrivateUsage]
-
- await_args = create.await_args
- assert await_args is not None
- assert await_args.kwargs["extra_headers"] == _EXPECTED
diff --git a/tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_native_client.py b/tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_native_client.py
deleted file mode 100644
index b26522e0f..000000000
--- a/tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_native_client.py
+++ /dev/null
@@ -1,139 +0,0 @@
-"""The request the native-route client actually builds, and the two ways a 2xx can still be wrong.
-
-`POST /v1/pipelex/extract` and `POST /v1/pipelex/search` are not OpenAI-shaped, so they are called
-with plain `httpx`. Building the request by hand is what makes the dialect's two properties readable
-in a test rather than dependent on a vendor constructor's defaults: the only header about us is the
-service token, the only other one says whose call it is, and the body carries the model with
-nothing about routing.
-
-The failure arm is the other half. A 2xx whose body is not JSON — an intermediary's HTML error page
-is how this happens — left raw is neither a `PipelexError` nor annotated with the model, so it
-escapes the Temporal error bridge (`convert_pipelex_errors`), gets marked retryable, and re-bills a
-call that already reached a provider.
-"""
-
-from __future__ import annotations
-
-from typing import TYPE_CHECKING, Any
-
-import httpx
-import pytest
-
-from pipelex.cogt.exceptions import CogtError
-from pipelex.cogt.inference.error_render import InferenceErrorFamily
-from pipelex.cogt.model_backends.backend import InferenceBackend
-from pipelex.providers.pipelex_hosted.pipelex_hosted_exceptions import PipelexHostedError
-from pipelex.providers.pipelex_hosted.pipelex_hosted_native_client import PipelexHostedNativeClient
-from tests.unit.pipelex.providers.pipelex_hosted.test_data import PipelexHostedMetadataTestData
-
-if TYPE_CHECKING:
- from pytest_mock import MockerFixture
-
-_ORIGIN = "https://pipelex_hosted.example.com"
-_TOKEN = "hosted-service-token"
-
-
-def _client() -> PipelexHostedNativeClient:
- return PipelexHostedNativeClient(backend=InferenceBackend(name="pipelex_manifold", endpoint=_ORIGIN, api_key=_TOKEN))
-
-
-def _inference_model(mocker: MockerFixture) -> Any:
- model = mocker.MagicMock()
- model.name = "linkup-sourced-answer"
- model.desc = "test-hosted-search"
- return model
-
-
-def _patch_transport(mocker: MockerFixture, response: httpx.Response) -> Any:
- """Stand in for the network at the `httpx.AsyncClient.post` seam.
-
- Patching the SDK's own method rather than the whole client keeps `raise_for_status` and the JSON
- decoding — the two things these tests are about — running for real.
- """
- return mocker.patch.object(httpx.AsyncClient, "post", new_callable=mocker.AsyncMock, return_value=response)
-
-
-def _response(*, status_code: int = 200, json_body: Any = None, text_body: str | None = None) -> httpx.Response:
- request = httpx.Request("POST", f"{_ORIGIN}/v1/pipelex/search")
- if text_body is not None:
- return httpx.Response(status_code=status_code, request=request, text=text_body)
- return httpx.Response(status_code=status_code, request=request, json=json_body)
-
-
[email protected](loop_scope="class")
-class TestPipelexHostedNativeClientRequest:
- async def test_the_wire_carries_one_token_header_and_a_body_with_no_routing(self, mocker: MockerFixture) -> None:
- post = _patch_transport(mocker, _response(json_body={"answer": "ok"}))
-
- await _client().post_json(
- route="/pipelex/search",
- body={"model": "linkup/standard", "query": "what is a torus"},
- family=InferenceErrorFamily.SEARCH,
- inference_model=_inference_model(mocker),
- job_metadata=PipelexHostedMetadataTestData.JOB_METADATA,
- )
-
- assert post.call_args.args[0] == f"{_ORIGIN}/v1/pipelex/search"
- headers = post.call_args.kwargs["headers"]
- # Asserted whole: a header added later should turn this red rather than widen silently. The
- # metadata header says whose call this is, not anything about us or about routing.
- assert headers == {
- "x-pipelex-api-key": _TOKEN,
- "x-pipelex-metadata": PipelexHostedMetadataTestData.EXPECTED_HEADER_VALUE,
- "Content-Type": "application/json",
- }
- assert post.call_args.kwargs["json"] == {"model": "linkup/standard", "query": "what is a torus"}
-
- async def test_a_json_object_body_comes_back_as_a_dict(self, mocker: MockerFixture) -> None:
- _patch_transport(mocker, _response(json_body={"answer": "ok", "sources": []}))
-
- result = await _client().post_json(
- route="/pipelex/search",
- body={"model": "linkup/standard", "query": "q"},
- family=InferenceErrorFamily.SEARCH,
- inference_model=_inference_model(mocker),
- job_metadata=PipelexHostedMetadataTestData.JOB_METADATA,
- )
-
- assert result == {"answer": "ok", "sources": []}
-
-
[email protected](loop_scope="class")
-class TestPipelexHostedNativeClientFailures:
- async def test_a_non_json_2xx_becomes_a_pipelex_error_naming_the_model(self, mocker: MockerFixture) -> None:
- _patch_transport(mocker, _response(text_body="<html><body>502 Bad Gateway</body></html>"))
-
- with pytest.raises(PipelexHostedError) as exc_info:
- await _client().post_json(
- route="/pipelex/search",
- body={"model": "linkup/standard", "query": "q"},
- family=InferenceErrorFamily.SEARCH,
- inference_model=_inference_model(mocker),
- job_metadata=PipelexHostedMetadataTestData.JOB_METADATA,
- )
-
- assert "linkup-sourced-answer" in exc_info.value.message
-
- async def test_a_2xx_carrying_a_json_scalar_is_refused_with_what_it_was(self, mocker: MockerFixture) -> None:
- _patch_transport(mocker, _response(json_body=["not", "an", "object"]))
-
- with pytest.raises(PipelexHostedError, match="list"):
- await _client().post_json(
- route="/pipelex/search",
- body={"model": "linkup/standard", "query": "q"},
- family=InferenceErrorFamily.SEARCH,
- inference_model=_inference_model(mocker),
- job_metadata=PipelexHostedMetadataTestData.JOB_METADATA,
- )
-
- async def test_a_status_error_is_classified_rather_than_raised_raw(self, mocker: MockerFixture) -> None:
- _patch_transport(mocker, _response(status_code=401, json_body={"error": {"message": "bad token"}}))
-
- with pytest.raises(CogtError):
- await _client().post_json(
- route="/pipelex/search",
- body={"model": "linkup/standard", "query": "q"},
- family=InferenceErrorFamily.SEARCH,
- inference_model=_inference_model(mocker),
- job_metadata=PipelexHostedMetadataTestData.JOB_METADATA,
- )
diff --git a/tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_plugin_registrations.py b/tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_plugin_registrations.py
deleted file mode 100644
index c66efe6ff..000000000
--- a/tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_plugin_registrations.py
+++ /dev/null
@@ -1,94 +0,0 @@
-"""What the hosted plugin claims, stated in one place.
-
-These sdk names are a contract with a file in another repository: the `sdk` column of the hosted
-plane's model catalog has to name exactly these strings, and a mismatch is not a startup error —
-it is an `InferenceBackendNotFoundError` at the first request against that model, which is to say in
-production, for one model, on whatever day someone first uses it. The claim is cheap to pin and
-expensive to discover.
-
-Two of the entries are worth reading rather than skimming. `(IMG_GEN, manifold_completions)` is the
-same sdk name registered under a second family, because some image models answer on the Chat
-Completions shape rather than on the Images API and the catalog says which by giving them
-`model_type = "img_gen"` while leaving them on the default completions sdk. And Claude has a token of
-its own, `manifold_anthropic`, rather than the plain `anthropic` the open Anthropic plugin owns: it is
-the same worker built with the package's extras factory, which is what adds the metadata header.
-"""
-
-from __future__ import annotations
-
-from typing import TYPE_CHECKING
-
-from anthropic import AsyncAnthropic
-
-from pipelex.cogt.model_backends.backend import InferenceBackend
-from pipelex.plugins.inference_backend_registry import InferenceFamily
-from pipelex.plugins.model_handle import ModelHandle
-from pipelex.plugins.registrar import PluginRegistrar
-from pipelex.providers.anthropic.anthropic_llm_worker import AnthropicLLMWorker
-from pipelex.providers.builtins import KERNEL_BUILTIN_PLUGINS
-from pipelex.providers.pipelex_hosted.pipelex_hosted_anthropic_extras import PipelexHostedAnthropicExtrasFactory
-from pipelex.providers.pipelex_hosted.pipelex_hosted_plugin import PipelexHostedPlugin
-
-if TYPE_CHECKING:
- from collections.abc import Callable
-
- from pytest_mock import MockerFixture
-
-_EXPECTED_KEYS = {
- (InferenceFamily.LLM, "manifold_anthropic"),
- (InferenceFamily.LLM, "manifold_completions"),
- (InferenceFamily.LLM, "manifold_responses"),
- (InferenceFamily.IMG_GEN, "manifold_img_gen"),
- (InferenceFamily.IMG_GEN, "manifold_completions"),
- (InferenceFamily.EXTRACT, "manifold_extract"),
- (InferenceFamily.SEARCH, "manifold_search"),
-}
-
-
-def _build_now(*, handle: object, build: Callable[[], object]) -> object:
- del handle
- return build()
-
-
-def _registrar(mocker: MockerFixture) -> PluginRegistrar:
- return PluginRegistrar(config=mocker.MagicMock())
-
-
-class TestPipelexHostedPluginRegistrations:
- def test_the_plugin_claims_exactly_the_pipelex_hosted_sdk_set(self, mocker: MockerFixture) -> None:
- registrar = _registrar(mocker)
-
- PipelexHostedPlugin().register(registrar)
-
- assert set(registrar.inference_backends) == _EXPECTED_KEYS
-
- def test_the_plain_anthropic_sdk_is_not_claimed(self, mocker: MockerFixture) -> None:
- """The open Anthropic plugin owns `anthropic`; claiming it here would fail the boot on a duplicate."""
- registrar = _registrar(mocker)
-
- PipelexHostedPlugin().register(registrar)
-
- assert all(sdk.startswith("manifold_") for _, sdk in registrar.inference_backends)
-
- def test_claude_is_built_with_the_metadata_extras_factory(self, mocker: MockerFixture) -> None:
- registrar = _registrar(mocker)
- PipelexHostedPlugin().register(registrar)
- make_worker = registrar.inference_backends[InferenceFamily.LLM, "manifold_anthropic"]
- model = mocker.MagicMock()
- model.sdk = "manifold_anthropic"
- model.max_tokens = 4096
- model.get_instructor_mode.return_value = None
- backend = InferenceBackend(name="pipelex_manifold", endpoint="https://pipelex_hosted.example.com", api_key="token")
- sdk_clients = mocker.MagicMock()
- sdk_clients.get_or_create.side_effect = _build_now
- mocker.patch.object(ModelHandle, "make_for_inference_model", return_value=mocker.MagicMock(sdk="manifold_anthropic"))
-
- worker = make_worker(inference_model=model, backend=backend, sdk_clients=sdk_clients, reporting_delegate=None)
-
- assert isinstance(worker, AnthropicLLMWorker)
- assert isinstance(worker.extras_factory, PipelexHostedAnthropicExtrasFactory)
- assert isinstance(worker.anthropic_async_client, AsyncAnthropic)
-
- def test_the_plugin_is_a_kernel_builtin(self) -> None:
- """Registered beside the gateway plugin, so a hosted-declared backend needs no plugin install."""
- assert any(isinstance(plugin, PipelexHostedPlugin) for plugin in KERNEL_BUILTIN_PLUGINS)
diff --git a/tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_request_limits.py b/tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_request_limits.py
deleted file mode 100644
index 6477546bc..000000000
--- a/tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_request_limits.py
+++ /dev/null
@@ -1,477 +0,0 @@
-"""The Pipelex service's request-shape refusals, from the wire code to the rendered advice.
-
-The Pipelex service bounds what a request may weigh and how deeply it may
-nest, and refuses anything over those bounds with codes of its own: ``pig-07`` (the
-body is over its byte cap, at 413), ``pig-08`` (the body's size cannot be read — a
-chunked body, or an unreadable ``Content-Length`` — at 411), ``pig-10`` (a
-``pipelex-storage://`` object over its cap, at 413) and ``pig-11`` (the body nests
-deeper than the gateway's depth limit, at 400).
-
-These codes are the service's wire contract, so the hosted plugin owns them: each
-is a ``GatewayRequestLimit`` member in ``pipelex_hosted_error_codes``, contributed as one
-entry of the service error vocabulary that ``classify_inference_error`` consults
-ahead of the status ladder. Without that entry the Classify step falls through to
-the generic ladder, and a caller who sent something too large reads "the provider
-rejected the request" rather than "the request was too large". These tests pin the
-whole chain: the code is in the vocabulary under the right member, it survives
-every Extract hop that can carry it, it classifies as a caller/limit error that is
-never retried, and the Render step says which limit was hit. The package's
-``conftest.py`` hands the classifier the hosted vocabulary.
-
-**The code is the discriminator, not the provider.** A request reaches the gateway
-through several SDKs — the Portkey substrate, plain ``httpx`` on the native routes,
-and the shared Anthropic driver that Claude travels on — so the refusal arrives
-under three different ``ProviderName`` values. ``pig-`` and ``pipelex_`` are both
-the service's own code namespaces, which is why the vocabulary matches on the code
-alone.
-
-**And one failure can wear two codes.** The gateway renders a refusal in the
-vocabulary of the route it arrived on, so "this file is over its cap" is ``pig-10``
-on the LLM routes and ``pipelex_storage_object_too_large`` (or, for a document
-fetched by URL, ``pipelex_document_too_large``) on the native ``/v1/pipelex/*``
-ones. A caller cannot tell which route their extract took, so both renderings have
-to classify alike.
-"""
-
-from __future__ import annotations
-
-import json
-from typing import TYPE_CHECKING, Any
-
-import anthropic
-import httpx
-import pytest
-from openai import OpenAI
-from portkey_ai import Portkey
-
-from pipelex.cogt.exceptions import InferenceErrorCategory
-from pipelex.cogt.inference.error_classification import (
- ProviderErrorMetadata,
- UserActionKind,
- extract_anthropic_metadata,
- extract_gateway_metadata,
- extract_openai_metadata,
-)
-from pipelex.cogt.inference.error_classify import ClassificationResult, classify_inference_error
-from pipelex.cogt.inference.error_render import InferenceErrorFamily, render_inference_error
-from pipelex.cogt.inference.provider_name import ProviderName
-from pipelex.providers.pipelex_hosted.pipelex_hosted_error_codes import (
- _GATEWAY_REQUEST_LIMIT_BY_CODE, # pyright: ignore[reportPrivateUsage]
- GatewayRequestLimit,
-)
-from pipelex.providers.pipelex_hosted.pipelex_hosted_error_metadata import extract_pipelex_hosted_metadata
-
-if TYPE_CHECKING:
- from pytest_mock import MockerFixture
-
- from pipelex.cogt.inference.service_error_vocabulary import ServiceErrorVocabulary
-
-_ORIGIN = "https://pipelex_hosted.example.com"
-
-
-def _refusal_body(message: str, code: str) -> dict[str, Any]:
- """The body the gateway's ``generateApiErrorResponse`` renders, verbatim in shape.
-
- ``{status, message, error: {message, code}}`` — the code lives only under
- ``error.code``, and there is no ``error.type`` beside it.
- """
- beautified = f"Portkey Error: {message}. Error Code: {code}"
- return {"status": "failure", "message": beautified, "error": {"message": beautified, "code": code}}
-
-
-_BODY_TOO_LARGE_BODY = _refusal_body(
- "This request's body is 17825792 bytes, over this gateway's limit of 16777216 bytes for a body of media type application/json",
- "pig-07",
-)
-_LENGTH_REQUIRED_BODY = _refusal_body(
- "This gateway requires a declared Content-Length on a POST carrying a body; it does not accept a chunked body",
- "pig-08",
-)
-_OBJECT_TOO_LARGE_BODY = _refusal_body("The storage object is over this gateway's per-object limit", "pig-10")
-_BODY_TOO_DEEP_BODY = _refusal_body("The request body nests deeper than this gateway's limit of 128 levels", "pig-11")
-
-
-def _as_the_portkey_sdk_raises_it(*, status_code: int, body: dict[str, Any]) -> BaseException:
- """Build the exception through Portkey's own factory rather than by hand.
-
- The constructor accepts any ``body`` you give it; the SDK's factory does not —
- it sets ``body`` to ``json.loads(text)["error"]["message"]``, a string. Only the
- factory reproduces what the Extract step actually receives in production.
- """
- request = httpx.Request("POST", f"{_ORIGIN}/v1/chat/completions")
- response = httpx.Response(
- status_code=status_code,
- request=request,
- content=json.dumps(body).encode(),
- headers={"content-type": "application/json"},
- )
- client = Portkey(api_key="unused-in-this-test", base_url=f"{_ORIGIN}/v1")
- return client._make_status_error_from_response(request=request, response=response) # ruff: ignore[private-member-access] # pyright: ignore[reportPrivateUsage]
-
-
-def _as_the_openai_sdk_raises_it(*, status_code: int, body: dict[str, Any]) -> BaseException:
- """Build the exception through the OpenAI SDK's own factory, for the same reason as above.
-
- This is the hop a gateway or hosted *chat* call actually takes: both plugins
- build an ``OpenAICompletionsLLMWorker`` / ``OpenAIResponsesLLMWorker`` over a
- client pointed at the service, so an LLM-route refusal is distilled by
- ``extract_openai_metadata`` and never by ``extract_gateway_metadata``.
-
- That hop reads ``exc.type`` before ``exc.code`` — the opposite precedence to
- the two Pipelex-service hops — and it stays that way because it is the vendor's
- hop too. It recovers the code regardless, because the gateway's fail-closed
- envelope carries a ``code`` and no ``type`` at all; pinning it here is what
- turns that into a checked property instead of a standing assumption.
- """
- request = httpx.Request("POST", f"{_ORIGIN}/v1/chat/completions")
- response = httpx.Response(
- status_code=status_code,
- request=request,
- content=json.dumps(body).encode(),
- headers={"content-type": "application/json"},
- )
- client = OpenAI(api_key="unused-in-this-test", base_url=f"{_ORIGIN}/v1")
- return client._make_status_error_from_response(response) # ruff: ignore[private-member-access] # pyright: ignore[reportPrivateUsage]
-
-
-def _envelope(code: str | None, *, status_code: int, provider: ProviderName = ProviderName.GATEWAY) -> ProviderErrorMetadata:
- return ProviderErrorMetadata(
- provider=provider,
- sdk_exception_type="BadRequestError",
- message="Portkey Error: refused",
- status_code=status_code,
- provider_error_code=code,
- )
-
-
-def _request_limit(code: str | None) -> GatewayRequestLimit | None:
- """The family member a wire code names, if it names one."""
- return _GATEWAY_REQUEST_LIMIT_BY_CODE.get(code) if code is not None else None
-
-
-def _classified_limit(result: ClassificationResult) -> GatewayRequestLimit | None:
- """The family member the classifier matched the refusal to, read off the vocabulary entry it carries."""
- return _request_limit(result.service_error_code.code) if result.service_error_code is not None else None
-
-
-class TestTheCodeIsRecognized:
- """Each code is in the hosted vocabulary, under the family member that names its limit."""
-
- @pytest.mark.parametrize(
- ("code", "expected"),
- [
- ("pig-07", GatewayRequestLimit.BODY_TOO_LARGE),
- ("pig-08", GatewayRequestLimit.BODY_LENGTH_REQUIRED),
- ("pig-10", GatewayRequestLimit.OBJECT_TOO_LARGE),
- ("pig-11", GatewayRequestLimit.BODY_TOO_DEEP),
- ],
- )
- def test_each_limit_code_maps_to_its_kind(
- self, code: str, expected: GatewayRequestLimit, pipelex_hosted_service_error_vocabulary: ServiceErrorVocabulary
- ) -> None:
- assert _request_limit(code) == expected
- assert pipelex_hosted_service_error_vocabulary.lookup(code=code) is not None
-
- @pytest.mark.parametrize("code", [None, "pig-01", "pig-09", "invalid_request_error", "PIG-07", ""])
- def test_any_other_code_is_not_a_request_limit(self, code: str | None) -> None:
- """The gateway's routing and storage-resolution refusals are a different family, and so is a vendor's code."""
- assert _request_limit(code) is None
- assert _classified_limit(classify_inference_error(_envelope(code, status_code=400))) is None
-
- @pytest.mark.parametrize("provider", list(ProviderName))
- def test_the_code_is_read_whichever_provider_reported_it(self, provider: ProviderName) -> None:
- """Claude reaches the gateway on the Anthropic driver, so the refusal is not always reported as GATEWAY."""
- result = classify_inference_error(_envelope("pig-07", status_code=413, provider=provider))
-
- assert _classified_limit(result) == GatewayRequestLimit.BODY_TOO_LARGE
-
-
-class TestTheCodeSurvivesEveryExtractHop:
- """The refusal body the gateway actually emits, through each SDK that can carry it."""
-
- def test_through_the_portkey_substrate(self) -> None:
- exc = _as_the_portkey_sdk_raises_it(status_code=413, body=_BODY_TOO_LARGE_BODY)
-
- metadata = extract_gateway_metadata(exc)
-
- assert metadata.provider_error_code == "pig-07"
- assert _request_limit(metadata.provider_error_code) == GatewayRequestLimit.BODY_TOO_LARGE
-
- def test_the_portkey_substrate_discards_the_payload_and_the_code_survives_anyway(self) -> None:
- """The reason the hop above is built through the SDK rather than by hand.
-
- Portkey's ``_make_status_error_from_response`` puts the *message string* on
- ``exc.body``, never the document — so a test that hands the constructor a
- nested dict passes on a shape production never produces, while the real path
- recovers no code at all. Pinned here so it cannot quietly regress.
- """
- exc = _as_the_portkey_sdk_raises_it(status_code=413, body=_BODY_TOO_LARGE_BODY)
-
- assert isinstance(getattr(exc, "body", None), str)
- assert _request_limit(extract_gateway_metadata(exc).provider_error_code) == GatewayRequestLimit.BODY_TOO_LARGE
-
- def test_the_length_rule_arrives_on_the_substrate_too(self) -> None:
- """``pig-08`` is raised by the same middleware as ``pig-07``, ahead of authentication."""
- exc = _as_the_portkey_sdk_raises_it(status_code=411, body=_LENGTH_REQUIRED_BODY)
-
- metadata = extract_gateway_metadata(exc)
-
- assert metadata.provider_error_code == "pig-08"
- assert _request_limit(metadata.provider_error_code) == GatewayRequestLimit.BODY_LENGTH_REQUIRED
-
- def test_through_plain_httpx_on_the_native_routes(self) -> None:
- request = httpx.Request("POST", f"{_ORIGIN}/v1/pipelex/extract")
- response = httpx.Response(status_code=400, request=request, json=_BODY_TOO_DEEP_BODY)
- exc = httpx.HTTPStatusError("Client error '400 Bad Request'", request=request, response=response)
-
- metadata = extract_pipelex_hosted_metadata(exc)
-
- assert metadata.provider_error_code == "pig-11"
- assert _request_limit(metadata.provider_error_code) == GatewayRequestLimit.BODY_TOO_DEEP
-
- def test_through_the_shared_anthropic_driver(self) -> None:
- request = httpx.Request("POST", f"{_ORIGIN}/v1/messages")
- response = httpx.Response(status_code=413, request=request)
- exc = anthropic.BadRequestError(message="error", response=response, body=_OBJECT_TOO_LARGE_BODY)
-
- metadata = extract_anthropic_metadata(exc)
-
- assert metadata.provider_error_code == "pig-10"
- assert _request_limit(metadata.provider_error_code) == GatewayRequestLimit.OBJECT_TOO_LARGE
-
- @pytest.mark.parametrize(
- ("body", "expected"),
- [
- (_BODY_TOO_LARGE_BODY, GatewayRequestLimit.BODY_TOO_LARGE),
- (_BODY_TOO_DEEP_BODY, GatewayRequestLimit.BODY_TOO_DEEP),
- ],
- )
- def test_through_the_openai_substrate_that_carries_every_chat_call(self, body: dict[str, Any], expected: GatewayRequestLimit) -> None:
- """The hop a gateway or hosted LLM call actually takes.
-
- Both plugins build an ``OpenAICompletionsLLMWorker`` over a client pointed
- at the service, so a chat-route refusal is distilled by
- ``extract_openai_metadata``. That hop reads ``type`` before ``code``, which
- is right for the vendor it also serves and would throw a ``pipelex_*`` code
- away — it recovers these because the fail-closed envelope carries no
- ``type``. That is a property of the gateway's envelope, so it is checked
- here rather than assumed.
- """
- exc = _as_the_openai_sdk_raises_it(status_code=413, body=body)
-
- metadata = extract_openai_metadata(exc)
-
- assert _request_limit(metadata.provider_error_code) == expected
-
-
-class TestClassification:
- """A limit refusal is a caller error the runtime must not retry."""
-
- @pytest.mark.parametrize(
- ("code", "status_code", "expected_limit", "expected_category", "expected_action"),
- [
- ("pig-07", 413, GatewayRequestLimit.BODY_TOO_LARGE, InferenceErrorCategory.CONTENT, UserActionKind.CHANGE_INPUT),
- (
- "pig-08",
- 411,
- GatewayRequestLimit.BODY_LENGTH_REQUIRED,
- InferenceErrorCategory.CONFIGURATION,
- UserActionKind.CONTACT_SUPPORT,
- ),
- ("pig-10", 413, GatewayRequestLimit.OBJECT_TOO_LARGE, InferenceErrorCategory.CONTENT, UserActionKind.CHANGE_INPUT),
- ("pig-11", 400, GatewayRequestLimit.BODY_TOO_DEEP, InferenceErrorCategory.CONTENT, UserActionKind.CHANGE_INPUT),
- ],
- )
- def test_each_limit_classifies_as_a_caller_error(
- self,
- code: str,
- status_code: int,
- expected_limit: GatewayRequestLimit,
- expected_category: InferenceErrorCategory,
- expected_action: UserActionKind,
- ) -> None:
- result = classify_inference_error(_envelope(code, status_code=status_code))
-
- assert _classified_limit(result) == expected_limit
- assert result.category == expected_category
- assert result.user_action_kind == expected_action
- assert result.category.is_retryable is False
- assert result.is_model_not_found is False
-
- def test_a_413_without_the_code_is_left_to_the_status_ladder(self) -> None:
- """Only the gateway's own code names a limit; a bare 413 from a vendor is not one."""
- result = classify_inference_error(_envelope(None, status_code=413))
-
- assert _classified_limit(result) is None
- assert result.category == InferenceErrorCategory.CONFIGURATION
-
- def test_without_the_pipelex_hosted_vocabulary_the_code_is_left_to_the_status_ladder(self, mocker: MockerFixture) -> None:
- """The codes classify only because the plugin contributes them: a runtime without it reads the bare status."""
- mocker.patch("pipelex.cogt.inference.error_classify.get_optional_service_error_vocabulary", return_value=None)
-
- result = classify_inference_error(_envelope("pig-07", status_code=413))
-
- assert result.service_error_code is None
- assert result.user_action_kind == UserActionKind.CHANGE_INPUT
-
- def test_the_411_would_otherwise_read_as_a_configuration_error_with_input_advice(self) -> None:
- """What the fall-through gave before: the generic 4xx bucket, telling the caller to revise the prompt."""
- fell_through = classify_inference_error(_envelope("something-else", status_code=411))
-
- assert fell_through.user_action_kind == UserActionKind.CHANGE_INPUT
-
-
-class TestRenderedAdvice:
- """Each limit gets advice naming what to do about it, not the generic rejection line."""
-
- @pytest.mark.parametrize(
- ("code", "status_code", "expected_phrase"),
- [
- ("pig-07", 413, "too large"),
- ("pig-08", 411, "Content-Length"),
- ("pig-10", 413, "per-file size limit"),
- ("pig-11", 400, "deeply"),
- ],
- )
- def test_the_detail_names_the_limit(self, code: str, status_code: int, expected_phrase: str) -> None:
- metadata = _envelope(code, status_code=status_code)
- classification = classify_inference_error(metadata)
-
- rendered = render_inference_error(
- metadata=metadata,
- classification=classification,
- family=InferenceErrorFamily.LLM,
- model_desc="claude-fake",
- model_handle="fake-handle",
- )
-
- assert rendered.user_action is not None
- assert expected_phrase in rendered.user_action.detail
- assert "review the prompt, parameters, and inputs" not in rendered.user_action.detail
-
- def test_the_two_size_limits_are_told_apart(self) -> None:
- """A body over its cap and one file over its cap need different remedies."""
- details: list[str] = []
- for code, status_code in (("pig-07", 413), ("pig-10", 413)):
- metadata = _envelope(code, status_code=status_code)
- rendered = render_inference_error(
- metadata=metadata,
- classification=classify_inference_error(metadata),
- family=InferenceErrorFamily.LLM,
- model_desc="claude-fake",
- model_handle="fake-handle",
- )
- assert rendered.user_action is not None
- details.append(rendered.user_action.detail)
-
- assert details[0] != details[1]
-
-
-def _native_route_refusal_body(message: str, code: str) -> dict[str, Any]:
- """The body pig's native ``/v1/pipelex/*`` routes render, verbatim in shape.
-
- A different envelope from the fail-closed one above, and the difference is the
- whole point of these tests: ``providerErrorResponse`` renders every refusal on
- those routes through the gateway's standard provider-error shape, which puts a
- generic ``invalid_request_error`` in ``error.type`` and the frozen contract code
- in ``error.code``. Reading ``type`` first — which is right for Anthropic, whose
- error section has no ``code`` at all — throws the code away.
- """
- return {
- "error": {"message": message, "type": "invalid_request_error", "param": None, "code": code},
- "provider": "linkup",
- }
-
-
-class TestTheSameLimitOnTheNativeRoutes:
- """The gateway renders one failure twice, and both renderings have to classify.
-
- ``pig-10`` is how the LLM routes say "this file is over its cap", because there
- the client speaks a provider's protocol and the gateway's own ``pig-0N`` family
- is the only vocabulary available. On ``/v1/pipelex/extract`` and
- ``/v1/pipelex/search`` the wire contract is pig's own and the same refusal is a
- ``pipelex_*`` code — one for a storage object it resolved, one for a document it
- fetched by URL. A caller cannot tell which route their extract took, so the two
- must read alike.
- """
-
- @pytest.mark.parametrize("code", ["pipelex_storage_object_too_large", "pipelex_document_too_large"])
- def test_a_file_over_its_cap_classifies_as_too_large(self, code: str) -> None:
- request = httpx.Request("POST", f"{_ORIGIN}/v1/pipelex/extract")
- response = httpx.Response(status_code=413, request=request, json=_native_route_refusal_body("over the limit", code))
- exc = httpx.HTTPStatusError("Client error '413 Payload Too Large'", request=request, response=response)
-
- metadata = extract_pipelex_hosted_metadata(exc)
- result = classify_inference_error(metadata)
-
- assert metadata.provider_error_code == code
- assert _classified_limit(result) == GatewayRequestLimit.OBJECT_TOO_LARGE
- assert result.category == InferenceErrorCategory.CONTENT
- assert result.category.is_retryable is False
-
- def test_both_routes_give_the_caller_the_same_advice(self) -> None:
- """``pig-10`` and its native-route twin are one limit, so one remedy."""
- details: list[str] = []
- for metadata in (
- _envelope("pig-10", status_code=413),
- _envelope("pipelex_storage_object_too_large", status_code=413),
- ):
- rendered = render_inference_error(
- metadata=metadata,
- classification=classify_inference_error(metadata),
- family=InferenceErrorFamily.EXTRACT,
- model_desc="extractor-fake",
- model_handle="fake-handle",
- )
- assert rendered.user_action is not None
- details.append(rendered.user_action.detail)
-
- assert details[0] == details[1]
-
- def test_the_native_envelope_survives_the_portkey_substrate_too(self) -> None:
- """Where the response fallback and the code-first precedence meet, on one real call.
-
- A gateway extract or search reaches Azure Document Intelligence and Linkup
- through the chat costume, so the refusal those providers raise is rendered
- by ``providerErrorResponse`` — the ``type``-bearing native envelope — and
- then raised by Portkey's factory, which replaces the payload with the
- message string. Recovering the code needs the response fallback *and* the
- ``code``-first precedence; either one alone leaves the caller reading "the
- provider rejected the request" for a file they can simply make smaller.
- """
- request = httpx.Request("POST", f"{_ORIGIN}/v1/chat/completions")
- payload = _native_route_refusal_body("over the limit", "pipelex_document_too_large")
- response = httpx.Response(
- status_code=413,
- request=request,
- content=json.dumps(payload).encode(),
- headers={"content-type": "application/json"},
- )
- client = Portkey(api_key="unused-in-this-test", base_url=f"{_ORIGIN}/v1")
- exc = client._make_status_error_from_response(request=request, response=response) # ruff: ignore[private-member-access] # pyright: ignore[reportPrivateUsage]
-
- assert isinstance(getattr(exc, "body", None), str)
- metadata = extract_gateway_metadata(exc)
- result = classify_inference_error(metadata)
-
- assert metadata.provider_error_code == "pipelex_document_too_large"
- assert _classified_limit(result) == GatewayRequestLimit.OBJECT_TOO_LARGE
- assert result.category.is_retryable is False
-
- def test_the_generic_type_does_not_shadow_the_contract_code(self) -> None:
- """The regression this envelope exists to pin.
-
- Every native-route refusal carries ``type: "invalid_request_error"`` beside
- its code. Reading ``type`` first reports that bucket as the provider error
- code for the whole ``pipelex_*`` vocabulary, so no contract code ever
- reaches the classifier — including the ones that are not limits.
- """
- request = httpx.Request("POST", f"{_ORIGIN}/v1/pipelex/extract")
- body = _native_route_refusal_body("that host is refused", "pipelex_document_host_refused")
- response = httpx.Response(status_code=400, request=request, json=body)
- exc = httpx.HTTPStatusError("Client error '400 Bad Request'", request=request, response=response)
-
- metadata = extract_pipelex_hosted_metadata(exc)
-
- assert metadata.provider_error_code == "pipelex_document_host_refused"
- assert _request_limit(metadata.provider_error_code) is None
diff --git a/tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_routing_refusals.py b/tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_routing_refusals.py
deleted file mode 100644
index b6839e823..000000000
--- a/tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_routing_refusals.py
+++ /dev/null
@@ -1,716 +0,0 @@
-"""The Pipelex service's routing refusals, from the wire code to the rendered advice.
-
-Before a request can reach a provider the Pipelex service has to decide
-*which* provider: it reads the model out of the request, looks it up in its own
-routing table, and hands the call to the integration that serves it. When that
-resolution fails it refuses the request itself, with codes of its own — ``pig-01``
-when it serves no such model, ``pig-02`` when the model's integration is switched
-off for want of a credential, ``pig-05`` when a native-protocol path names a model
-another provider serves, and ``pig-06`` when a model reaches a route its provider
-does not serve.
-
-These codes are the service's wire contract, so the hosted plugin owns them: each
-is a ``GatewayRoutingRefusal`` member in ``pipelex_hosted_error_codes``, contributed as one
-entry of the service error vocabulary that ``classify_inference_error`` consults
-ahead of the status ladder (the package's ``conftest.py`` hands the classifier that
-vocabulary). Every ``pig-`` code answers HTTP 400, so without its entry the
-Classify step falls through to the status ladder's 400 arm and a caller who named a
-model the deployment does not serve is told *"The provider rejected the request —
-review the prompt, parameters, and inputs."* — and receives an
-``LLMCompletionError`` rather than the ``LLMModelNotFoundError`` that case produces
-when the model deck itself cannot find a model. These tests pin the whole chain:
-the code is in the vocabulary under the right member, it survives every Extract hop
-that can carry it, it classifies as a configuration problem that is never retried,
-the Render step says which routing decision failed and who has to change what, and
-both consequences of the category that outlive this module are pinned too — the
-HTTP status the family answers, and the advice surviving the pipe layer's re-raise.
-
-``model_not_allowed_error``, the Portkey substrate's answer for a model an
-integration serves but does not allow for this caller, is not one of the service's
-codes and not in its vocabulary: the runtime reads it in core, and
-``tests/unit/pipelex/cogt/inference/test_model_not_allowed.py`` pins it.
-
-**Every member is its own wire code here**, unlike the two families beside it.
-That is not an accident of the code space: grouping is by remedy in all three
-families, and each of these names a different thing that has to change.
-
-**Only ``pig-01`` sets ``is_model_not_found``.** The flag is not a category — it
-selects the family's ``*ModelNotFoundError`` class, which ``pipe_operator.py``
-re-raises as a ``PipeOperatorModelAvailabilityError`` carrying the model handle.
-``pig-01`` is literally "this deployment does not know that model", seen from the
-service. For ``pig-05`` and ``pig-06`` the model exists and *is* served — it just
-cannot do what was asked, or was asked over the wrong protocol — so claiming it
-was not found would be false.
-
-**``pig-02`` is the family's ``CONTACT_SUPPORT`` arm.** A switched-off integration
-is the service operator's fact: nothing about the request causes it, none of the
-caller's own credentials are at fault, and sending them shopping for another model
-would hide an unset variable. The same call ``STORAGE_NOT_SERVED`` and
-``BODY_LENGTH_REQUIRED`` get in the two families beside this one.
-
-**``pig-03`` and ``pig-04`` are deliberately outside the family**, and that scope
-decision is pinned below rather than left to a comment. Neither is produced today
-by a client talking to a Pipelex-operated service: ``pig-03`` refuses client-side
-routing forms that
-``tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_clients.py`` pins the
-hosted clients against by name, and ``pig-04`` refuses a path the service does
-not mount at all. Two limits on the first half, recorded beside the map rather
-than implied here: that test names four headers while the service refuses on an
-allow-list, and the gateway img-gen worker does send ``x-portkey-config``, which
-Portkey's cloud reads and one of our gateways would refuse.
-
-**``pig-05`` is mapped but unreachable from today's runtime**, which is why no
-Extract hop is pinned for it. It is raised only on a native Google protocol path
-(``/v1/<v1|v1alpha|v1beta>/models/<model>:generateContent`` or its
-``streamGenerateContent`` twin), and no worker speaks that protocol to
-the service: both the gateway and hosted plugins build their LLM workers on the
-OpenAI substrate, and ``PipelexHostedNativeClient`` serves only the ``/v1/pipelex/*``
-extract and search routes. The map entry costs nothing and is right the day a
-native Google path is wired — but the Google Extract hop would not carry the code
-even then, which the last case in ``TestTheCodeSurvivesEveryExtractHop`` pins as
-the trap it is.
-"""
-
-from __future__ import annotations
-
-import json
-from typing import TYPE_CHECKING, Any
-
-import anthropic
-import httpx
-import pytest
-from openai import OpenAI
-from portkey_ai import Portkey
-
-from pipelex.base_exceptions import ErrorDomain
-from pipelex.cogt.exceptions import CogtError, InferenceErrorCategory, LLMCompletionError, LLMModelNotFoundError
-from pipelex.cogt.inference.error_classification import (
- MODEL_NOT_ALLOWED_ERROR_CODE,
- ProviderErrorMetadata,
- UserActionKind,
- extract_anthropic_metadata,
- extract_gateway_metadata,
- extract_google_metadata,
- extract_openai_metadata,
-)
-from pipelex.cogt.inference.error_classify import ClassificationResult, classify_inference_error
-from pipelex.cogt.inference.error_render import InferenceErrorFamily, render_inference_error
-from pipelex.cogt.inference.provider_name import ProviderName
-from pipelex.pipe_operators.exceptions import PipeOperatorModelAvailabilityError
-from pipelex.providers.pipelex_hosted.pipelex_hosted_error_codes import (
- _GATEWAY_REQUEST_LIMIT_BY_CODE, # pyright: ignore[reportPrivateUsage]
- _GATEWAY_ROUTING_REFUSAL_BY_CODE, # pyright: ignore[reportPrivateUsage]
- _GATEWAY_UNRESOLVED_REFERENCE_BY_CODE, # pyright: ignore[reportPrivateUsage]
- PIPELEX_HOSTED_SERVICE_ERROR_CODES,
- GatewayRoutingRefusal,
-)
-from pipelex.providers.pipelex_hosted.pipelex_hosted_error_metadata import extract_pipelex_hosted_metadata
-from pipelex.system.pipe_run_mode import PipeRunMode
-
-if TYPE_CHECKING:
- from pytest_mock import MockerFixture
-
- from pipelex.cogt.inference.service_error_vocabulary import ServiceErrorVocabulary
-
-_ORIGIN = "https://pipelex_hosted.example.com"
-
-# Every code in the family, paired with the member it must reach. Reused by the
-# recognition, classification and rendering cases so a code added to the map
-# without an arm — or an arm added without a code — cannot pass unnoticed.
-_EVERY_CODE_AND_MEMBER: list[tuple[str, GatewayRoutingRefusal]] = [
- ("pig-01", GatewayRoutingRefusal.UNKNOWN_MODEL),
- ("pig-02", GatewayRoutingRefusal.DISABLED_INTEGRATION),
- ("pig-05", GatewayRoutingRefusal.WRONG_PROTOCOL),
- ("pig-06", GatewayRoutingRefusal.UNSERVED_CAPABILITY),
-]
-
-# The same codes as a flat list, for the cases that only need the wire code.
-_EVERY_CODE: list[str] = [pair[0] for pair in _EVERY_CODE_AND_MEMBER]
-
-# Every member whose remedy is picking a different model, i.e. all of them but the
-# one that means an operator never enabled the integration.
-_CHANGE_MODEL_CODES: list[str] = [code for code, member in _EVERY_CODE_AND_MEMBER if member is not GatewayRoutingRefusal.DISABLED_INTEGRATION]
-
-# The gateway's request-shape limits and its unresolvable-reference codes, for the
-# three-way disjointness cases.
-_REQUEST_LIMIT_CODES: list[str] = ["pig-07", "pig-08", "pig-10", "pig-11", "pipelex_storage_object_too_large", "pipelex_document_too_large"]
-_UNRESOLVED_REFERENCE_CODES: list[str] = ["pig-09", "pipelex_storage_uri_invalid", "pipelex_storage_unreadable", "pipelex_document_host_refused"]
-
-_GENERIC_ADVICE = "The provider rejected the request — review the prompt, parameters, and inputs."
-_GENERIC_NOT_FOUND_ADVICE = "The requested model was not found — pick an available model."
-
-
-def _fail_closed_refusal_body(message: str, code: str) -> dict[str, Any]:
- """The body the gateway's ``generateApiErrorResponse`` renders, verbatim in shape.
-
- ``{status, message, error: {message, code}}`` — the code lives only under
- ``error.code``, and there is no ``error.type`` beside it. Every routing refusal
- is rendered by that one helper, on the LLM routes and the native ones alike, so
- this is the only envelope the family arrives in.
- """
- beautified = f"Portkey Error: {message}. Error Code: {code}"
- return {"status": "failure", "message": beautified, "error": {"message": beautified, "code": code}}
-
-
-_UNKNOWN_MODEL_BODY = _fail_closed_refusal_body("No model found for the request", "pig-01")
-
-
-def _as_the_portkey_sdk_raises_it(*, status_code: int, body: dict[str, Any]) -> BaseException:
- """Build the exception through Portkey's own factory rather than by hand.
-
- The constructor accepts any ``body`` you give it; the SDK's factory does not —
- it sets ``body`` to ``json.loads(text)["error"]["message"]``, a string. Only the
- factory reproduces what the Extract step actually receives in production.
- """
- request = httpx.Request("POST", f"{_ORIGIN}/v1/chat/completions")
- response = httpx.Response(
- status_code=status_code,
- request=request,
- content=json.dumps(body).encode(),
- headers={"content-type": "application/json"},
- )
- client = Portkey(api_key="unused-in-this-test", base_url=f"{_ORIGIN}/v1")
- return client._make_status_error_from_response(request=request, response=response) # ruff: ignore[private-member-access] # pyright: ignore[reportPrivateUsage]
-
-
-def _as_the_openai_sdk_raises_it(*, status_code: int, body: dict[str, Any]) -> BaseException:
- """Build the exception through the OpenAI SDK's own factory, for the same reason as above.
-
- This is the hop a gateway or hosted *chat* call actually takes: both plugins
- build an ``OpenAICompletionsLLMWorker`` / ``OpenAIResponsesLLMWorker`` over a
- client pointed at the service, so an LLM-route refusal is distilled by
- ``extract_openai_metadata`` and never by ``extract_gateway_metadata``.
- """
- request = httpx.Request("POST", f"{_ORIGIN}/v1/chat/completions")
- response = httpx.Response(
- status_code=status_code,
- request=request,
- content=json.dumps(body).encode(),
- headers={"content-type": "application/json"},
- )
- client = OpenAI(api_key="unused-in-this-test", base_url=f"{_ORIGIN}/v1")
- return client._make_status_error_from_response(response) # ruff: ignore[private-member-access] # pyright: ignore[reportPrivateUsage]
-
-
-def _envelope(code: str | None, *, status_code: int = 400, provider: ProviderName = ProviderName.GATEWAY) -> ProviderErrorMetadata:
- return ProviderErrorMetadata(
- provider=provider,
- sdk_exception_type="BadRequestError",
- message="Portkey Error: refused",
- status_code=status_code,
- provider_error_code=code,
- )
-
-
-def _routing_refusal(code: str | None) -> GatewayRoutingRefusal | None:
- """The family member a wire code names, if it names one."""
- return _GATEWAY_ROUTING_REFUSAL_BY_CODE.get(code) if code is not None else None
-
-
-def _in_another_family(code: str | None) -> bool:
- """Whether a wire code names a request-shape limit or an unresolvable reference."""
- return code in _GATEWAY_REQUEST_LIMIT_BY_CODE or code in _GATEWAY_UNRESOLVED_REFERENCE_BY_CODE
-
-
-def _classified_code(result: ClassificationResult) -> str | None:
- """The wire code of the vocabulary entry the classifier matched, if it matched one."""
- return result.service_error_code.code if result.service_error_code is not None else None
-
-
-def _rendered_error(
- metadata: ProviderErrorMetadata,
- *,
- family: InferenceErrorFamily = InferenceErrorFamily.LLM,
- model_handle: str = "fake-handle",
-) -> CogtError:
- return render_inference_error(
- metadata=metadata,
- classification=classify_inference_error(metadata),
- family=family,
- model_desc=f"{model_handle} → Model[some-wire-id]",
- model_handle=model_handle,
- )
-
-
-def _rendered_detail(
- metadata: ProviderErrorMetadata,
- *,
- family: InferenceErrorFamily = InferenceErrorFamily.LLM,
- model_handle: str = "fake-handle",
-) -> str:
- rendered = _rendered_error(metadata, family=family, model_handle=model_handle)
- assert rendered.user_action is not None
- return rendered.user_action.detail
-
-
-class TestTheCodeIsRecognized:
- """Each code is in the hosted vocabulary, under the family member that names the routing decision."""
-
- @pytest.mark.parametrize(("code", "expected"), _EVERY_CODE_AND_MEMBER)
- def test_each_code_maps_to_its_member(
- self, code: str, expected: GatewayRoutingRefusal, pipelex_hosted_service_error_vocabulary: ServiceErrorVocabulary
- ) -> None:
- assert _routing_refusal(code) == expected
- assert pipelex_hosted_service_error_vocabulary.lookup(code=code) is not None
-
- @pytest.mark.parametrize("member", list(GatewayRoutingRefusal))
- def test_every_member_is_reachable_from_a_wire_code(self, member: GatewayRoutingRefusal) -> None:
- """A member no code reaches is dead advice — it would never render for anyone."""
- assert member in {expected for _, expected in _EVERY_CODE_AND_MEMBER}
-
- def test_the_table_covers_the_whole_production_map(self) -> None:
- """The other direction, which the per-code cases cannot see.
-
- Every case in this module walks the table above into the map. Without this
- one, a code added to the map and forgotten here would be classified and
- rendered in production and exercised by nothing.
- """
- assert set(_EVERY_CODE) == set(_GATEWAY_ROUTING_REFUSAL_BY_CODE)
-
- @pytest.mark.parametrize(
- "code",
- [
- None,
- "pig-07",
- "pig-09",
- "pig-11",
- "invalid_request_error",
- "PIG-01",
- "pipelex_storage_unreadable",
- "model_not_found",
- "model_not_allowed",
- "MODEL_NOT_ALLOWED_ERROR",
- MODEL_NOT_ALLOWED_ERROR_CODE,
- "",
- ],
- )
- def test_any_other_code_is_not_a_routing_refusal(self, code: str | None) -> None:
- """The request-shape limits, the unresolvable references, the substrate's own refusal and a vendor's code are all other families."""
- assert _routing_refusal(code) is None
- assert _routing_refusal(_classified_code(classify_inference_error(_envelope(code)))) is None
-
- def test_the_substrates_model_not_allowed_refusal_is_not_the_services_to_contribute(
- self, pipelex_hosted_service_error_vocabulary: ServiceErrorVocabulary
- ) -> None:
- """Core reads ``model_not_allowed_error`` itself, so the hosted vocabulary must not claim it too."""
- assert pipelex_hosted_service_error_vocabulary.lookup(code=MODEL_NOT_ALLOWED_ERROR_CODE) is None
-
- @pytest.mark.parametrize("provider", list(ProviderName))
- def test_the_code_is_read_whichever_provider_reported_it(self, provider: ProviderName) -> None:
- """Claude reaches the service on the Anthropic driver, so the refusal is not always reported as GATEWAY."""
- result = classify_inference_error(_envelope("pig-01", provider=provider))
-
- assert _routing_refusal(_classified_code(result)) == GatewayRoutingRefusal.UNKNOWN_MODEL
-
-
-class TestTheCodeSurvivesEveryExtractHop:
- """The refusal body the gateway actually emits, through each SDK that can carry it."""
-
- def test_through_the_portkey_substrate(self) -> None:
- exc = _as_the_portkey_sdk_raises_it(status_code=400, body=_UNKNOWN_MODEL_BODY)
-
- metadata = extract_gateway_metadata(exc)
-
- assert metadata.provider_error_code == "pig-01"
- assert _routing_refusal(metadata.provider_error_code) == GatewayRoutingRefusal.UNKNOWN_MODEL
-
- def test_the_portkey_substrate_discards_the_payload_and_the_code_survives_anyway(self) -> None:
- """The reason the hop above is built through the SDK rather than by hand.
-
- Portkey's ``_make_status_error_from_response`` puts the *message string* on
- ``exc.body``, never the document — so a test that hands the constructor a
- nested dict passes on a shape production never produces, while the real path
- recovers no code at all.
- """
- exc = _as_the_portkey_sdk_raises_it(status_code=400, body=_UNKNOWN_MODEL_BODY)
-
- assert isinstance(getattr(exc, "body", None), str)
- assert _routing_refusal(extract_gateway_metadata(exc).provider_error_code) == GatewayRoutingRefusal.UNKNOWN_MODEL
-
- @pytest.mark.parametrize(("code", "expected"), _EVERY_CODE_AND_MEMBER)
- def test_through_the_openai_substrate_that_carries_every_chat_call(self, code: str, expected: GatewayRoutingRefusal) -> None:
- """The hop a gateway or hosted LLM call actually takes.
-
- That hop reads ``type`` before ``code``, which is right for the vendor it
- also serves — it recovers these because the fail-closed envelope carries no
- ``type`` at all. That is a property of the gateway's envelope rather than of
- the hop, so it is checked here rather than assumed.
- """
- exc = _as_the_openai_sdk_raises_it(status_code=400, body=_fail_closed_refusal_body("refused", code))
-
- assert _routing_refusal(extract_openai_metadata(exc).provider_error_code) == expected
-
- def test_through_plain_httpx_on_the_native_routes(self) -> None:
- """Where ``pig-06`` is actually raised: ``/v1/pipelex/extract`` and its siblings.
-
- The route's model-versus-capability refusal is rendered by the same
- fail-closed helper as the LLM routes' — it is a ``pig-0N`` code, not one of
- the native routes' own ``pipelex_*`` contract codes.
- """
- request = httpx.Request("POST", f"{_ORIGIN}/v1/pipelex/extract")
- response = httpx.Response(status_code=400, request=request, json=_fail_closed_refusal_body("provider does not serve extract", "pig-06"))
- exc = httpx.HTTPStatusError("Client error '400 Bad Request'", request=request, response=response)
-
- metadata = extract_pipelex_hosted_metadata(exc)
-
- assert metadata.provider_error_code == "pig-06"
- assert _routing_refusal(metadata.provider_error_code) == GatewayRoutingRefusal.UNSERVED_CAPABILITY
-
- def test_through_the_shared_anthropic_driver(self) -> None:
- """Claude travels on the vendor's own SDK, which recovers the code from the body it kept."""
- request = httpx.Request("POST", f"{_ORIGIN}/v1/messages")
- response = httpx.Response(status_code=400, request=request)
- exc = anthropic.BadRequestError(message="error", response=response, body=_UNKNOWN_MODEL_BODY)
-
- metadata = extract_anthropic_metadata(exc)
-
- assert metadata.provider_error_code == "pig-01"
- assert _routing_refusal(metadata.provider_error_code) == GatewayRoutingRefusal.UNKNOWN_MODEL
-
- def test_the_google_hop_would_not_carry_a_gateway_code_and_nothing_reaches_it_today(self) -> None:
- """``pig-05``'s hop, pinned as the trap it is rather than as a passing path.
-
- ``pig-05`` is raised only on the native Google protocol path, and no worker
- speaks that protocol to the gateway today — both service plugins build their
- LLM workers on the OpenAI substrate, and ``PipelexHostedNativeClient`` serves only
- the ``/v1/pipelex/*`` routes. So the map entry is correct and unreachable.
-
- Were that path wired, the code would still not arrive: Google's Extract hop
- reads the symbolic ``status`` a Google error carries (``RESOURCE_EXHAUSTED``
- and friends), and the gateway's envelope has no ``error.status`` — only a
- top-level ``status: "failure"``, which the hop dutifully returns as though it
- were a provider code. This asserts that, so whoever wires a native Google
- path finds the requirement stated rather than a silent misclassification.
- """
-
- class _GoogleApiError(Exception):
- """The shape ``extract_google_metadata`` reads: ``code`` is the HTTP status, ``details`` the raw body."""
-
- def __init__(self, *, details: dict[str, Any]) -> None:
- super().__init__("Portkey Error: refused. Error Code: pig-05")
- self.code = 400
- self.details = details
- self.response = None
-
- metadata = extract_google_metadata(_GoogleApiError(details=_fail_closed_refusal_body("wrong protocol", "pig-05")))
-
- assert metadata.provider_error_code == "failure"
- assert _classified_code(classify_inference_error(metadata)) is None
-
-
-class TestClassification:
- """A routing refusal is a configuration problem the runtime must not retry."""
-
- @pytest.mark.parametrize(("code", "expected"), _EVERY_CODE_AND_MEMBER)
- def test_each_code_classifies_as_its_member_and_is_never_retried(self, code: str, expected: GatewayRoutingRefusal) -> None:
- result = classify_inference_error(_envelope(code))
-
- assert _classified_code(result) == code
- assert _routing_refusal(_classified_code(result)) == expected
- assert result.category == InferenceErrorCategory.CONFIGURATION
- assert result.category.is_retryable is False
-
- @pytest.mark.parametrize("code", _CHANGE_MODEL_CODES)
- def test_a_refusal_the_caller_can_route_around_asks_them_to_change_the_model(self, code: str) -> None:
- result = classify_inference_error(_envelope(code))
-
- assert result.user_action_kind == UserActionKind.CHANGE_MODEL
-
- def test_a_disabled_integration_is_an_operators_problem(self) -> None:
- """The credential is the gateway operator's and unset; the caller's own key is fine."""
- result = classify_inference_error(_envelope("pig-02"))
-
- assert _routing_refusal(_classified_code(result)) == GatewayRoutingRefusal.DISABLED_INTEGRATION
- assert result.user_action_kind == UserActionKind.CONTACT_SUPPORT
- assert result.is_model_not_found is False
-
- @pytest.mark.parametrize("code", _EVERY_CODE)
- def test_only_the_unknown_model_is_a_missing_model(self, code: str) -> None:
- """The flag selects the ``*ModelNotFoundError`` class, so setting it wrongly makes the runtime lie.
-
- For ``pig-05`` and ``pig-06`` the model exists and is served — it just
- cannot do what was asked, or was asked over the wrong protocol.
- """
- result = classify_inference_error(_envelope(code))
-
- assert result.is_model_not_found is (code == "pig-01")
-
- def test_a_plain_400_without_a_recognized_code_still_takes_the_status_ladder(self) -> None:
- """Only the gateway's own codes name a routing decision; a bare 400 from a vendor does not."""
- result = classify_inference_error(_envelope("something-else"))
-
- assert result.service_error_code is None
- assert result.category == InferenceErrorCategory.CONTENT
- assert result.user_action_kind == UserActionKind.CHANGE_INPUT
-
- def test_without_the_pipelex_hosted_vocabulary_an_unserved_model_is_a_plain_400(self, mocker: MockerFixture) -> None:
- """The family classifies only because the plugin contributes it: a runtime without it reads the bare status."""
- mocker.patch("pipelex.cogt.inference.error_classify.get_optional_service_error_vocabulary", return_value=None)
-
- result = classify_inference_error(_envelope("pig-01"))
-
- assert result.service_error_code is None
- assert result.is_model_not_found is False
- assert result.category == InferenceErrorCategory.CONTENT
- assert result.user_action_kind == UserActionKind.CHANGE_INPUT
-
-
-class TestEndToEnd:
- """The headline of the bug: what a caller actually receives, built the way production builds it."""
-
- def test_an_unserved_model_reaches_the_caller_as_a_model_not_found_carrying_the_handle(self) -> None:
- """Before this family it was an ``LLMCompletionError`` telling them to review their prompt.
-
- The handle matters as much as the class: ``pipe_operator.py`` re-raises a
- ``ModelNotFoundError`` as a ``PipeOperatorModelAvailabilityError`` carrying
- it, which is the pipe-level error a caller already gets when the deck itself
- cannot find a model.
- """
- exc = _as_the_portkey_sdk_raises_it(status_code=400, body=_UNKNOWN_MODEL_BODY)
- metadata = extract_gateway_metadata(exc)
-
- rendered = render_inference_error(
- metadata=metadata,
- classification=classify_inference_error(metadata),
- family=InferenceErrorFamily.LLM,
- model_desc="some-model",
- model_handle="some-handle",
- )
-
- assert isinstance(rendered, LLMModelNotFoundError)
- assert rendered.model_handle == "some-handle"
- assert rendered.error_category == InferenceErrorCategory.CONFIGURATION
-
- def test_a_wrong_protocol_refusal_does_not_claim_the_model_was_not_found(self) -> None:
- """The model exists and is served — only the protocol the runtime spoke was wrong."""
- exc = _as_the_portkey_sdk_raises_it(status_code=400, body=_fail_closed_refusal_body("served by another provider", "pig-05"))
- metadata = extract_gateway_metadata(exc)
- classification = classify_inference_error(metadata)
-
- rendered = render_inference_error(
- metadata=metadata,
- classification=classification,
- family=InferenceErrorFamily.LLM,
- model_desc="some-model",
- model_handle="some-handle",
- )
-
- assert isinstance(rendered, LLMCompletionError)
- assert not isinstance(rendered, LLMModelNotFoundError)
- assert classification.user_action_kind == UserActionKind.CHANGE_MODEL
- assert rendered.user_action is not None
- assert "not found" not in rendered.user_action.detail
-
-
-class TestRenderedAdvice:
- """Each member gets advice naming what has to change, not a generic rejection line."""
-
- @pytest.mark.parametrize("code", _EVERY_CODE)
- def test_no_member_renders_the_generic_rejection_line(self, code: str) -> None:
- """The whole point: every one of these used to read as a prompt to revise."""
- assert _rendered_detail(_envelope(code)) != _GENERIC_ADVICE
-
- @pytest.mark.parametrize("code", _EVERY_CODE)
- def test_no_member_renders_the_generic_action_kind_advice_either(self, code: str) -> None:
- """Branching ahead of the action kind is what this asserts.
-
- ``CHANGE_MODEL`` alone would render "the requested model was not found" for
- every member but ``pig-01``, whose model exists, and ``CONTACT_SUPPORT`` alone would render
- "the error could not be classified" for a refusal that named itself exactly.
- """
- detail = _rendered_detail(_envelope(code))
-
- assert detail != _GENERIC_NOT_FOUND_ADVICE
- assert "could not be classified" not in detail
-
- @pytest.mark.parametrize(
- ("code", "expected_phrase"),
- [
- ("pig-01", "does not serve that model"),
- ("pig-02", "has not enabled"),
- ("pig-05", "not over the protocol"),
- ("pig-06", "does not serve that capability"),
- ],
- )
- def test_the_detail_names_the_remedy(self, code: str, expected_phrase: str) -> None:
- assert expected_phrase in _rendered_detail(_envelope(code))
-
- @pytest.mark.parametrize("code", _EVERY_CODE)
- def test_every_member_leaves_the_handle_to_the_message(self, code: str) -> None:
- """The service's own message states every specific, so the advice names no handle of its own."""
- assert "some-distinctive-handle" not in _rendered_detail(_envelope(code), model_handle="some-distinctive-handle")
-
- def test_the_unserved_model_and_the_wrong_protocol_are_told_apart(self) -> None:
- """A model the gateway does not serve and one it serves differently need different moves."""
- unknown = _rendered_detail(_envelope("pig-01"))
- wrong_protocol = _rendered_detail(_envelope("pig-05"))
-
- assert unknown != wrong_protocol
- assert "does not serve that model" in unknown
- assert "serves that model" in wrong_protocol
-
- def test_the_disabled_integration_blames_neither_the_prompt_nor_the_callers_key(self) -> None:
- """The distinction the ``CONTACT_SUPPORT`` ruling exists to keep.
-
- ``CHECK_CREDENTIALS`` would send a hosted caller to rotate a perfectly valid
- key, and ``CHANGE_MODEL`` would send them shopping for a model over an
- operator's unset variable.
- """
- detail = _rendered_detail(_envelope("pig-02"))
-
- assert "contact support" in detail.lower()
- assert "prompt" not in detail
- assert "pick a model" not in detail
-
- def test_the_deck_disagreement_refusals_name_the_deck(self) -> None:
- """Advice saying only "pick another model" would send an operator hunting for a model problem.
-
- The runtime picks the protocol and the route from its own deck, so these two
- usually mean the deck and the gateway's routing table disagree.
- """
- for code in ("pig-05", "pig-06"):
- assert "model deck" in _rendered_detail(_envelope(code))
-
- def test_an_unserved_capability_reaching_an_extract_reads_the_same(self) -> None:
- """``pig-06`` arrives on extract and search calls, so the advice must not assume an LLM family."""
- metadata = _envelope("pig-06")
-
- assert _rendered_detail(metadata, family=InferenceErrorFamily.EXTRACT) == _rendered_detail(metadata)
-
-
-class TestTheScopeDecisionIsPinned:
- """``pig-03`` and ``pig-04`` are routing codes the runtime deliberately does not map.
-
- Neither is producible by the clients the runtime ships, so the status ladder's
- reading of each is as good as any. These assert family membership only — they
- take no position on the verdict the ladder gives them, which for ``pig-04``'s
- 404 is model-not-found and wrong in kind.
- """
-
- @pytest.mark.parametrize(("code", "status_code"), [("pig-03", 400), ("pig-04", 404)])
- def test_the_unmapped_routing_codes_are_not_routing_refusals(self, code: str, status_code: int) -> None:
- metadata = _envelope(code, status_code=status_code)
-
- assert _routing_refusal(code) is None
- assert _classified_code(classify_inference_error(metadata)) is None
-
- def test_the_unmapped_routing_codes_belong_to_no_gateway_family_at_all(self) -> None:
- """Not quietly picked up by one of the neighbouring maps either."""
- for code in ("pig-03", "pig-04"):
- assert not _in_another_family(code)
-
-
-class TestTheThreeGatewayFamiliesDoNotShadowEachOther:
- """One bounds the request's shape, one says a reference could not be resolved, one says it could not be routed.
-
- All three read the same ``pig-`` namespace, so a code landing in two maps would
- silently give one family's advice to another's refusal — and the branch order in
- ``classify_inference_error`` would start to matter, which it must not.
- """
-
- @pytest.mark.parametrize("code", _EVERY_CODE)
- def test_no_routing_code_belongs_to_another_family(self, code: str) -> None:
- assert not _in_another_family(code)
-
- @pytest.mark.parametrize("code", _REQUEST_LIMIT_CODES + _UNRESOLVED_REFERENCE_CODES)
- def test_no_other_familys_code_is_a_routing_refusal(self, code: str) -> None:
- assert _routing_refusal(code) is None
-
- def test_the_three_maps_are_disjoint_as_sets(self) -> None:
- """The direction the per-code cases cannot see: a code added to two maps at once."""
- limits = set(_GATEWAY_REQUEST_LIMIT_BY_CODE)
- references = set(_GATEWAY_UNRESOLVED_REFERENCE_BY_CODE)
- routing = set(_GATEWAY_ROUTING_REFUSAL_BY_CODE)
-
- assert limits & references == set()
- assert limits & routing == set()
- assert references & routing == set()
-
- def test_the_vocabulary_contributes_every_mapped_code_once(self) -> None:
- """The contribution is the three maps and nothing else, one entry per code.
-
- The registrar refuses a code claimed twice at boot; this states the same
- property of the contribution itself, without a boot.
- """
- contributed = [entry.code for entry in PIPELEX_HOSTED_SERVICE_ERROR_CODES]
-
- assert len(contributed) == len(set(contributed))
- assert set(contributed) == set(_GATEWAY_REQUEST_LIMIT_BY_CODE) | set(_GATEWAY_UNRESOLVED_REFERENCE_BY_CODE) | set(
- _GATEWAY_ROUTING_REFUSAL_BY_CODE
- )
-
-
-class TestWhatTheFamilyAnswersOverHTTP:
- """The category is not only advice — it decides the status an HTTP surface returns.
-
- ``CONFIGURATION`` implies ``ErrorDomain.CONFIG``, which
- ``error_domain_to_http_status`` renders as 500; the ``CONTENT`` the ``pig-``
- members used to receive on their 400 implies ``INPUT`` and renders as 422. So
- classifying the family moved their HTTP answer as surely as it moved its wording, and that is the half a
- classification test cannot see. 500 is also the status outer clients retry,
- which is worth pinning precisely because "never retried" elsewhere in this
- module is a statement about ``InferenceErrorCategory.is_retryable`` inside this
- process and about nothing else.
- """
-
- @pytest.mark.parametrize("code", _EVERY_CODE)
- def test_every_member_answers_500_rather_than_the_422_it_used_to(self, code: str) -> None:
- report = _rendered_error(_envelope(code)).to_error_report()
-
- assert report.error_domain == ErrorDomain.CONFIG
- assert report.http_status == 500
-
- def test_an_unrecognized_400_still_answers_422(self) -> None:
- """The contrast that makes the case above a change rather than a constant."""
- report = _rendered_error(_envelope("something-else")).to_error_report()
-
- assert report.error_domain == ErrorDomain.INPUT
- assert report.http_status == 422
-
-
-class TestTheAdviceSurvivesThePipeBoundary:
- """``pig-01`` is the one member whose error class is re-raised on the way out.
-
- ``pipe_operator.py`` catches ``ModelNotFoundError`` and re-raises it as a
- ``PipeOperatorModelAvailabilityError``, whose constructor takes a message, a
- handle and a stack and no user action — so the advice reaches a caller only
- because ``_enrich_error_report_from_cause`` inherits ``user_action`` and
- ``error_domain`` off the ``__cause__`` chain. That inheritance is what carries
- every word of this family's most-argued detail through the pipe layer, and
- nothing else in this module crosses that boundary to see it.
-
- Every other member keeps the family's failure class, which the pipe operator
- lets through for the pipe router to locate.
- """
-
- def _re_raised_as_the_pipe_operator_does(self, cause: LLMModelNotFoundError) -> PipeOperatorModelAvailabilityError:
- """Mirror ``PipeOperator``'s ``except ModelNotFoundError`` arm, ``from`` included.
-
- The ``from`` is the load-bearing part: without it there is no ``__cause__``
- and the enrichment this class exists to pin has nothing to read.
- """
- try:
- raise cause
- except LLMModelNotFoundError as model_not_found_error:
- try:
- raise PipeOperatorModelAvailabilityError(
- message=model_not_found_error.message,
- run_mode=PipeRunMode.LIVE,
- pipe_type="PipeLLM",
- pipe_code="some_pipe",
- pipe_stack=[],
- model_handle=model_not_found_error.model_handle,
- ) from model_not_found_error
- except PipeOperatorModelAvailabilityError as availability_error:
- return availability_error
-
- def test_the_unknown_model_advice_reaches_the_caller_through_the_pipe_error(self) -> None:
- rendered = _rendered_error(_envelope("pig-01"))
- assert isinstance(rendered, LLMModelNotFoundError)
-
- report = self._re_raised_as_the_pipe_operator_does(rendered).to_error_report()
-
- assert report.error_type == "PipeOperatorModelAvailabilityError"
- assert report.user_action_detail() == _rendered_detail(_envelope("pig-01"))
- assert report.error_domain == ErrorDomain.CONFIG
- assert report.http_status == 500
diff --git a/tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_search_worker.py b/tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_search_worker.py
deleted file mode 100644
index 6136a5131..000000000
--- a/tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_search_worker.py
+++ /dev/null
@@ -1,181 +0,0 @@
-"""The search worker's wire body and its usage translation.
-
-The translation is the same silent failure the extract worker has, in the other unit: the route
-reports `usage.searches` and the runtime prices per million, so an untranslated response leaves
-`nb_tokens_by_category` empty and `linkup-standard` at `costs = { input = 0.005 }` prices nothing at
-all, with no exception and no warning.
-
-The body carries **no `depth`**: the model id is where that lives — `linkup/standard` versus
-`linkup/deep` — and a second source for a decision the gateway takes from one place is a source of
-disagreement rather than of flexibility.
-"""
-
-from __future__ import annotations
-
-from typing import TYPE_CHECKING, Any
-
-import pytest
-from pydantic import BaseModel
-
-from pipelex.cogt.usage.token_category import NbTokensByCategoryDict, TokenCategory
-from pipelex.core.stuffs.search_result_content import SearchResultContent
-from pipelex.providers.pipelex_hosted.pipelex_hosted_exceptions import PipelexHostedSearchEmptyResultError, PipelexHostedSearchResponseError
-from pipelex.providers.pipelex_hosted.pipelex_hosted_extract_worker import PIPELEX_HOSTED_UNIT_TOKENS
-from pipelex.providers.pipelex_hosted.pipelex_hosted_search_worker import PipelexHostedSearchWorker
-
-if TYPE_CHECKING:
- from pytest_mock import MockerFixture
-
-_SOURCED_ANSWER = {
- "answer": "A torus is a surface shaped like a ring.",
- "sources": [{"name": "Torus", "url": "https://example.com/torus", "snippet": "ring-shaped surface"}],
- "usage": {"searches": 1},
-}
-
-
-class _Capital(BaseModel):
- city: str
-
-
-def _make_worker(mocker: MockerFixture, *, response_body: dict[str, Any] | None = None) -> PipelexHostedSearchWorker:
- worker = object.__new__(PipelexHostedSearchWorker)
- model = mocker.MagicMock()
- model.model_id = "linkup/standard"
- model.name = "linkup-sourced-answer"
- model.desc = "test-hosted-search"
- worker.inference_model = model
- client = mocker.MagicMock()
- client.post_json = mocker.AsyncMock(return_value=response_body if response_body is not None else _SOURCED_ANSWER)
- worker.client = client
- return worker
-
-
-def _post_json(worker: PipelexHostedSearchWorker) -> Any:
- """The stand-in for the native client, as `Any` so its mock attributes typecheck."""
- return worker.client.post_json
-
-
-def _make_search_job(mocker: MockerFixture) -> Any:
- job = mocker.MagicMock()
- job.query = "what is a torus"
- job.job_params.search_setting.include_images = False
- job.job_params.search_setting.include_inline_citations = False
- job.job_params.search_setting.max_results = 10
- job.job_params.include_domains = None
- job.job_params.exclude_domains = None
- job.job_params.from_date = None
- job.job_params.to_date = None
- job.job_report.search_tokens_usage = None
- return job
-
-
[email protected](loop_scope="class")
-class TestPipelexHostedSearchRequestBody:
- async def test_the_body_names_the_model_and_carries_no_depth(self, mocker: MockerFixture) -> None:
- worker = _make_worker(mocker)
-
- await worker._search_sourced_answer(_make_search_job(mocker)) # ruff: ignore[private-member-access] # pyright: ignore[reportPrivateUsage]
-
- call = _post_json(worker).call_args.kwargs
- assert call["route"] == "/pipelex/search"
- assert call["body"]["model"] == "linkup/standard"
- assert call["body"]["query"] == "what is a torus"
- assert "depth" not in call["body"]
-
- async def test_unset_optional_parameters_are_omitted_rather_than_sent_as_null(self, mocker: MockerFixture) -> None:
- worker = _make_worker(mocker)
-
- await worker._search_sourced_answer(_make_search_job(mocker)) # ruff: ignore[private-member-access] # pyright: ignore[reportPrivateUsage]
-
- body = _post_json(worker).call_args.kwargs["body"]
- for absent in ("include_domains", "exclude_domains", "from_date", "to_date", "output_schema"):
- assert absent not in body
-
- async def test_a_structured_search_sends_the_caller_s_schema(self, mocker: MockerFixture) -> None:
- worker = _make_worker(mocker, response_body={"data": {"city": "Paris"}, "sources": [], "usage": {"searches": 1}})
-
- result = await worker._search_structured(_make_search_job(mocker), schema=_Capital) # ruff: ignore[private-member-access] # pyright: ignore[reportPrivateUsage]
-
- assert result == {"city": "Paris"}
- body = _post_json(worker).call_args.kwargs["body"]
- assert body["output_schema"] == _Capital.model_json_schema()
-
-
[email protected](loop_scope="class")
-class TestPipelexHostedSearchResponse:
- async def test_a_sourced_answer_becomes_the_runtime_s_own_content(self, mocker: MockerFixture) -> None:
- worker = _make_worker(mocker)
-
- result = await worker._search_sourced_answer(_make_search_job(mocker)) # ruff: ignore[private-member-access] # pyright: ignore[reportPrivateUsage]
-
- assert isinstance(result, SearchResultContent)
- assert result.answer.startswith("A torus is")
- assert [source.url for source in result.sources] == ["https://example.com/torus"]
-
- async def test_a_response_with_no_answer_is_refused_rather_than_returned_empty(self, mocker: MockerFixture) -> None:
- worker = _make_worker(mocker, response_body={"sources": [], "usage": {"searches": 1}})
-
- with pytest.raises(PipelexHostedSearchResponseError):
- await worker._search_sourced_answer(_make_search_job(mocker)) # ruff: ignore[private-member-access] # pyright: ignore[reportPrivateUsage]
-
- async def test_a_structured_search_that_found_nothing_says_so(self, mocker: MockerFixture) -> None:
- """The query's fault, not the model's — which is why it carries CHANGE_INPUT."""
- worker = _make_worker(mocker, response_body={"data": None, "sources": [], "usage": {"searches": 1}})
-
- with pytest.raises(PipelexHostedSearchEmptyResultError):
- await worker._search_structured(_make_search_job(mocker), schema=_Capital) # ruff: ignore[private-member-access] # pyright: ignore[reportPrivateUsage]
-
- async def test_the_usage_key_does_not_stop_the_envelope_being_recognised(self, mocker: MockerFixture) -> None:
- """The route puts `usage` beside the envelope, and it must not reach the unwrapper.
-
- `extract_structured_search_payload` recognises the envelope by its key set being *exactly*
- `data` and `sources`. Hand it a third key and it returns the whole body as the payload —
- which validates against an output class whose fields have defaults and yields an
- all-defaults object, with no exception and no warning. The failure has no symptom at all
- beyond a wrong answer, so it is pinned rather than left to the shape of the fixture.
- """
- worker = _make_worker(mocker, response_body={"data": {"city": "Paris"}, "sources": [], "usage": {"searches": 1}})
-
- result = await worker._search_structured(_make_search_job(mocker), schema=_Capital) # ruff: ignore[private-member-access] # pyright: ignore[reportPrivateUsage]
-
- assert result == {"city": "Paris"}
- assert "usage" not in result
- assert "sources" not in result
-
-
[email protected](loop_scope="class")
-class TestPipelexHostedSearchUsageTranslation:
- async def test_searches_become_megatokens_in_both_categories(self, mocker: MockerFixture) -> None:
- """The same cost figure the Portkey path reports, which is what makes the two comparable."""
- worker = _make_worker(mocker, response_body={**_SOURCED_ANSWER, "usage": {"searches": 2}})
- job = _make_search_job(mocker)
- usage = mocker.MagicMock()
- job.job_report.search_tokens_usage = usage
-
- await worker._search_sourced_answer(job) # ruff: ignore[private-member-access] # pyright: ignore[reportPrivateUsage]
-
- assert usage.nb_tokens_by_category == {
- TokenCategory.INPUT: 2 * PIPELEX_HOSTED_UNIT_TOKENS,
- TokenCategory.OUTPUT: 2 * PIPELEX_HOSTED_UNIT_TOKENS,
- }
-
- @pytest.mark.parametrize(
- "usage_block",
- [None, {}, {"searches": "one"}],
- ids=["null-usage", "empty-usage", "non-numeric-searches"],
- )
- async def test_a_usage_block_the_route_did_not_send_leaves_the_categories_untouched(
- self,
- mocker: MockerFixture,
- usage_block: dict[str, Any] | None,
- ) -> None:
- worker = _make_worker(mocker, response_body={**_SOURCED_ANSWER, "usage": usage_block})
- job = _make_search_job(mocker)
- usage = mocker.MagicMock()
- empty_categories: NbTokensByCategoryDict = {}
- usage.nb_tokens_by_category = empty_categories
- job.job_report.search_tokens_usage = usage
-
- await worker._search_sourced_answer(job) # ruff: ignore[private-member-access] # pyright: ignore[reportPrivateUsage]
-
- assert usage.nb_tokens_by_category == {}
diff --git a/tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_service_error_codes_boot.py b/tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_service_error_codes_boot.py
deleted file mode 100644
index 02c4e6d10..000000000
--- a/tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_service_error_codes_boot.py
+++ /dev/null
@@ -1,20 +0,0 @@
-"""The session's boot installs the Pipelex service's refusal codes on the hub, where classification reads them.
-
-The package's other tests hand the classifier the hosted vocabulary through the autouse fixture, which
-patches the classifier's binding; this one reads the hub's own accessor, which that fixture leaves alone,
-so it fails if the plugin stops contributing its codes or the boot stops installing them.
-"""
-
-from __future__ import annotations
-
-from pipelex.providers.pipelex_hosted.pipelex_hosted_error_codes import PIPELEX_HOSTED_SERVICE_ERROR_CODES
-from pipelex.runtime_hub import get_optional_service_error_vocabulary
-
-
-class TestPipelexHostedServiceErrorCodesBoot:
- def test_boot_installs_every_pipelex_hosted_code_on_the_hub(self) -> None:
- vocabulary = get_optional_service_error_vocabulary()
-
- assert vocabulary is not None
- missing = {entry.code for entry in PIPELEX_HOSTED_SERVICE_ERROR_CODES} - set(vocabulary.codes)
- assert not missing, f"The booted vocabulary lacks the Pipelex service's codes: {sorted(missing)}"
diff --git a/tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_spi_imports.py b/tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_spi_imports.py
deleted file mode 100644
index ba8ec0f48..000000000
--- a/tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_spi_imports.py
+++ /dev/null
@@ -1,76 +0,0 @@
-"""The package reaches core only through the published Inference SPI.
-
-Every `pipelex.*` name the package imports, at module level, deferred or for type checking alone, must
-be a row of the SPI table in `docs/under-the-hood/inference-backend-plugins.md`, unless it is the
-package's own. Deny by default: a new import of anything else turns this red, and the fix is either to
-publish the symbol in the table, under a role that names no consumer, or to give the package its own
-copy of it. The scan is what lets the package be copied out of this repository as a plugin of its own
-and keep working against a published surface.
-"""
-
-from __future__ import annotations
-
-import ast
-import re
-from pathlib import Path
-
-_TESTS_ROOT = next(parent for parent in Path(__file__).resolve().parents if parent.name == "tests")
-_REPO_ROOT = _TESTS_ROOT.parent
-_PACKAGE_DIR = _REPO_ROOT / "pipelex" / "providers" / "pipelex_hosted"
-_PACKAGE_MODULE = "pipelex.providers.pipelex_hosted"
-_SPI_PAGE = _REPO_ROOT / "docs" / "under-the-hood" / "inference-backend-plugins.md"
-
-_SPI_ROW = re.compile(r"^\| (?P<symbols>`[^|]+`) \| `(?P<module>[\w.]+)` \| ")
-_BACKTICKED = re.compile(r"`([A-Za-z_][\w]*)`")
-
-
-def _published_symbols() -> set[tuple[str, str]]:
- section = _SPI_PAGE.read_text(encoding="utf-8").split("## The Inference SPI", maxsplit=1)[1].split("\n## ", maxsplit=1)[0]
- published: set[tuple[str, str]] = set()
- for line in section.splitlines():
- if row := _SPI_ROW.match(line):
- published.update((row["module"], symbol) for symbol in _BACKTICKED.findall(row["symbols"]))
- return published
-
-
-def _core_imports() -> list[tuple[str, str, str]]:
- """Every `(file, module, symbol)` the package imports from `pipelex` outside itself."""
- imports: list[tuple[str, str, str]] = []
- for path in sorted(_PACKAGE_DIR.glob("*.py")):
- for node in ast.walk(ast.parse(path.read_text(encoding="utf-8"))):
- if isinstance(node, ast.ImportFrom) and node.module is not None and node.module.split(".")[0] == "pipelex":
- if node.module == _PACKAGE_MODULE or node.module.startswith(f"{_PACKAGE_MODULE}."):
- continue
- imports.extend((path.name, node.module, alias.name) for alias in node.names)
- elif isinstance(node, ast.Import):
- imports.extend((path.name, alias.name, "*") for alias in node.names if alias.name.split(".")[0] == "pipelex")
- return imports
-
-
-class TestPipelexHostedReachesCoreOnlyThroughTheSpi:
- def test_the_spi_table_parses(self) -> None:
- """Guards the guard: a table the regex stopped reading would let every import through."""
- published = _published_symbols()
-
- assert ("pipelex.plugins.registrar", "PluginRegistrar") in published
- assert ("pipelex.cogt.inference.service_error_vocabulary", "ServiceErrorCode") in published
-
- def test_the_package_imports_something_from_core(self) -> None:
- """Guards the guard the other way: a scan that found nothing would pass vacuously."""
- assert _core_imports()
-
- def test_every_core_import_is_published(self) -> None:
- published = _published_symbols()
-
- unpublished = sorted(
- f"{file}: from {module} import {symbol}" for file, module, symbol in _core_imports() if (module, symbol) not in published
- )
-
- assert not unpublished, "Imports outside the Inference SPI table; publish them there or copy them into the package:\n" + "\n".join(
- unpublished
- )
-
- def test_no_backend_name_constant_is_imported(self) -> None:
- """The package names its own backend; it reads no core constant that does."""
- backend_module = "pipelex.cogt.model_backends.backend"
- assert not [(file, symbol) for file, module, symbol in _core_imports() if module == backend_module and symbol != "InferenceBackend"]
diff --git a/tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_unresolved_references.py b/tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_unresolved_references.py
deleted file mode 100644
index 00288e657..000000000
--- a/tests/unit/pipelex/providers/pipelex_hosted/test_pipelex_hosted_unresolved_references.py
+++ /dev/null
@@ -1,470 +0,0 @@
-"""The Pipelex service's unresolvable-reference refusals, from the wire code to the rendered advice.
-
-A request may name a file rather than carry it — a ``pipelex-storage://`` key the
-Pipelex service resolves for the caller, or a document URL it fetches on
-their behalf. When it cannot turn that reference into bytes it refuses the request
-itself, with codes of its own: ``pig-09`` on the LLM routes, where its ``pig-0N``
-family has one fail-closed slot for "cannot resolve" and the message carries the
-difference, and a named ``pipelex_*`` contract code on the native
-``/v1/pipelex/*`` routes for each distinct cause.
-
-These codes are the service's wire contract, so the hosted plugin owns them: each
-is a ``GatewayUnresolvedReference`` member in ``pipelex_hosted_error_codes``, contributed
-as one entry of the service error vocabulary that ``classify_inference_error``
-consults ahead of the status ladder (the package's ``conftest.py`` hands the
-classifier that vocabulary). Without that entry the Classify step falls through to
-the generic status ladder — every one of these arrives on 400 — so a caller who mistyped a storage
-key, pointed at an object this deployment cannot read, or aimed a URL at a host the
-SSRF guard refuses reads "the provider rejected the request — review the prompt,
-parameters, and inputs". These tests pin the whole chain: the code is in the vocabulary,
-it survives every Extract hop that can carry it, it classifies as a caller error
-that is never retried, and the Render step says which reference failed and what to
-do about it.
-
-**Grouped by remedy, not by wire code.** Two codes share a ``GatewayUnresolvedReference``
-member only when the caller's next move is the same — which is why the three
-document-URL refusals are one member and ``pipelex_document_host_refused`` is its
-own: the caller can act on all four, but only the host refusal has to be stated as
-the deliberate security policy it is, rather than as a fault to work around.
-
-**And one member is not the caller's at all.** ``pipelex_storage_uri_unsupported``
-means no bucket is configured, so this deployment does not serve the scheme —
-nothing about the inputs causes it and no input avoids it. It is the family's one
-``CONTACT_SUPPORT`` arm, the same call ``BODY_LENGTH_REQUIRED`` gets among the
-request limits.
-"""
-
-from __future__ import annotations
-
-import json
-from typing import TYPE_CHECKING, Any
-
-import anthropic
-import httpx
-import pytest
-from openai import OpenAI
-from portkey_ai import Portkey
-
-from pipelex.cogt.exceptions import InferenceErrorCategory
-from pipelex.cogt.inference.error_classification import (
- ProviderErrorMetadata,
- UserActionKind,
- extract_anthropic_metadata,
- extract_gateway_metadata,
- extract_openai_metadata,
-)
-from pipelex.cogt.inference.error_classify import ClassificationResult, classify_inference_error
-from pipelex.cogt.inference.error_render import InferenceErrorFamily, render_inference_error
-from pipelex.cogt.inference.provider_name import ProviderName
-from pipelex.providers.pipelex_hosted.pipelex_hosted_error_codes import (
- _GATEWAY_REQUEST_LIMIT_BY_CODE, # pyright: ignore[reportPrivateUsage]
- _GATEWAY_UNRESOLVED_REFERENCE_BY_CODE, # pyright: ignore[reportPrivateUsage]
- GatewayRequestLimit,
- GatewayUnresolvedReference,
-)
-from pipelex.providers.pipelex_hosted.pipelex_hosted_error_metadata import extract_pipelex_hosted_metadata
-
-if TYPE_CHECKING:
- from pipelex.cogt.inference.service_error_vocabulary import ServiceErrorVocabulary
-
-_ORIGIN = "https://pipelex_hosted.example.com"
-
-# Every code in the family, paired with the member it must reach. Reused by the
-# recognition, classification and rendering cases so a code added to the map
-# without an arm — or an arm added without a code — cannot pass unnoticed.
-_EVERY_CODE_AND_MEMBER: list[tuple[str, GatewayUnresolvedReference]] = [
- ("pig-09", GatewayUnresolvedReference.REFERENCE_UNRESOLVED),
- ("pipelex_storage_uri_invalid", GatewayUnresolvedReference.STORAGE_REFERENCE_INVALID),
- ("pipelex_storage_unreadable", GatewayUnresolvedReference.STORAGE_OBJECT_UNREADABLE),
- ("pipelex_storage_uri_unsupported", GatewayUnresolvedReference.STORAGE_NOT_SERVED),
- ("pipelex_unsupported_uri_scheme", GatewayUnresolvedReference.DOCUMENT_URL_REFUSED),
- ("pipelex_document_scheme_refused", GatewayUnresolvedReference.DOCUMENT_URL_REFUSED),
- ("pipelex_document_address_refused", GatewayUnresolvedReference.DOCUMENT_URL_REFUSED),
- ("pipelex_document_redirect_refused", GatewayUnresolvedReference.DOCUMENT_URL_REFUSED),
- ("pipelex_document_host_refused", GatewayUnresolvedReference.DOCUMENT_HOST_REFUSED),
- ("pipelex_document_unreachable", GatewayUnresolvedReference.DOCUMENT_UNREACHABLE),
- ("pipelex_document_empty", GatewayUnresolvedReference.DOCUMENT_CONTENT_UNUSABLE),
- ("pipelex_document_unsupported_type", GatewayUnresolvedReference.DOCUMENT_CONTENT_UNUSABLE),
- ("pipelex_document_bad_data_url", GatewayUnresolvedReference.DOCUMENT_CONTENT_UNUSABLE),
-]
-
-# The same codes as a flat list, for the cases that only need the wire code.
-_EVERY_CODE: list[str] = [pair[0] for pair in _EVERY_CODE_AND_MEMBER]
-
-# Every code whose remedy is the caller's own, i.e. all of them but the one that
-# says this deployment serves no storage at all.
-_CALLER_FIXABLE_CODES: list[str] = [code for code, member in _EVERY_CODE_AND_MEMBER if member is not GatewayUnresolvedReference.STORAGE_NOT_SERVED]
-
-_GENERIC_ADVICE = "The provider rejected the request — review the prompt, parameters, and inputs."
-
-
-def _fail_closed_refusal_body(message: str, code: str) -> dict[str, Any]:
- """The body the gateway's ``generateApiErrorResponse`` renders, verbatim in shape.
-
- ``{status, message, error: {message, code}}`` — the code lives only under
- ``error.code``, and there is no ``error.type`` beside it. This is how the LLM
- routes speak, so it is the envelope ``pig-09`` arrives in.
- """
- beautified = f"Portkey Error: {message}. Error Code: {code}"
- return {"status": "failure", "message": beautified, "error": {"message": beautified, "code": code}}
-
-
-def _native_route_refusal_body(message: str, code: str) -> dict[str, Any]:
- """The body pig's native ``/v1/pipelex/*`` routes render, verbatim in shape.
-
- ``providerErrorResponse`` puts a generic ``invalid_request_error`` in
- ``error.type`` and the frozen contract code in ``error.code``, which is why the
- two Pipelex-service Extract hops read ``code`` before ``type``. Every
- ``pipelex_*`` code in this family arrives in this envelope.
- """
- return {
- "error": {"message": message, "type": "invalid_request_error", "param": None, "code": code},
- "provider": "linkup",
- }
-
-
-_UNRESOLVED_BODY = _fail_closed_refusal_body(
- "The request refers to 'pipelex-storage://nope/missing.pdf', which this gateway cannot resolve",
- "pig-09",
-)
-
-
-def _as_the_portkey_sdk_raises_it(*, status_code: int, body: dict[str, Any]) -> BaseException:
- """Build the exception through Portkey's own factory rather than by hand.
-
- The constructor accepts any ``body`` you give it; the SDK's factory does not —
- it sets ``body`` to ``json.loads(text)["error"]["message"]``, a string. Only the
- factory reproduces what the Extract step actually receives in production.
- """
- request = httpx.Request("POST", f"{_ORIGIN}/v1/chat/completions")
- response = httpx.Response(
- status_code=status_code,
- request=request,
- content=json.dumps(body).encode(),
- headers={"content-type": "application/json"},
- )
- client = Portkey(api_key="unused-in-this-test", base_url=f"{_ORIGIN}/v1")
- return client._make_status_error_from_response(request=request, response=response) # ruff: ignore[private-member-access] # pyright: ignore[reportPrivateUsage]
-
-
-def _as_the_openai_sdk_raises_it(*, status_code: int, body: dict[str, Any]) -> BaseException:
- """Build the exception through the OpenAI SDK's own factory, for the same reason as above.
-
- This is the hop a gateway or hosted *chat* call actually takes: both plugins
- build an ``OpenAICompletionsLLMWorker`` / ``OpenAIResponsesLLMWorker`` over a
- client pointed at the service, so an LLM-route refusal is distilled by
- ``extract_openai_metadata`` and never by ``extract_gateway_metadata``.
- """
- request = httpx.Request("POST", f"{_ORIGIN}/v1/chat/completions")
- response = httpx.Response(
- status_code=status_code,
- request=request,
- content=json.dumps(body).encode(),
- headers={"content-type": "application/json"},
- )
- client = OpenAI(api_key="unused-in-this-test", base_url=f"{_ORIGIN}/v1")
- return client._make_status_error_from_response(response) # ruff: ignore[private-member-access] # pyright: ignore[reportPrivateUsage]
-
-
-def _envelope(code: str | None, *, status_code: int = 400, provider: ProviderName = ProviderName.GATEWAY) -> ProviderErrorMetadata:
- return ProviderErrorMetadata(
- provider=provider,
- sdk_exception_type="BadRequestError",
- message="Portkey Error: refused",
- status_code=status_code,
- provider_error_code=code,
- )
-
-
-def _unresolved_reference(code: str | None) -> GatewayUnresolvedReference | None:
- """The family member a wire code names, if it names one."""
- return _GATEWAY_UNRESOLVED_REFERENCE_BY_CODE.get(code) if code is not None else None
-
-
-def _request_limit(code: str | None) -> GatewayRequestLimit | None:
- """The neighbouring family's member a wire code names, if it names one."""
- return _GATEWAY_REQUEST_LIMIT_BY_CODE.get(code) if code is not None else None
-
-
-def _classified_code(result: ClassificationResult) -> str | None:
- """The wire code of the vocabulary entry the classifier matched, if it matched one."""
- return result.service_error_code.code if result.service_error_code is not None else None
-
-
-def _rendered_detail(metadata: ProviderErrorMetadata, *, family: InferenceErrorFamily = InferenceErrorFamily.LLM) -> str:
- rendered = render_inference_error(
- metadata=metadata,
- classification=classify_inference_error(metadata),
- family=family,
- model_desc="claude-fake",
- model_handle="fake-handle",
- )
- assert rendered.user_action is not None
- return rendered.user_action.detail
-
-
-class TestTheCodeIsRecognized:
- """Each code is in the hosted vocabulary, under the family member that names its remedy."""
-
- @pytest.mark.parametrize(("code", "expected"), _EVERY_CODE_AND_MEMBER)
- def test_each_code_maps_to_its_member(
- self, code: str, expected: GatewayUnresolvedReference, pipelex_hosted_service_error_vocabulary: ServiceErrorVocabulary
- ) -> None:
- assert _unresolved_reference(code) == expected
- assert pipelex_hosted_service_error_vocabulary.lookup(code=code) is not None
-
- @pytest.mark.parametrize("member", list(GatewayUnresolvedReference))
- def test_every_member_is_reachable_from_a_wire_code(self, member: GatewayUnresolvedReference) -> None:
- """A member no code reaches is dead advice — it would never render for anyone."""
- assert member in {expected for _, expected in _EVERY_CODE_AND_MEMBER}
-
- def test_the_table_covers_the_whole_production_map(self) -> None:
- """The other direction, which the per-code cases cannot see.
-
- Every case in this module walks the table above into the map. Without this
- one, a code added to the map and forgotten here would be classified and
- rendered in production and exercised by nothing.
- """
- assert set(_EVERY_CODE) == set(_GATEWAY_UNRESOLVED_REFERENCE_BY_CODE)
-
- @pytest.mark.parametrize(
- "code",
- [None, "pig-01", "pig-07", "pig-10", "invalid_request_error", "PIG-09", "pipelex_storage_object_too_large", ""],
- )
- def test_any_other_code_is_not_an_unresolved_reference(self, code: str | None) -> None:
- """The routing codes, the request-shape limits, and a vendor's own code are all other families."""
- assert _unresolved_reference(code) is None
- assert _unresolved_reference(_classified_code(classify_inference_error(_envelope(code)))) is None
-
- @pytest.mark.parametrize("provider", list(ProviderName))
- def test_the_code_is_read_whichever_provider_reported_it(self, provider: ProviderName) -> None:
- """Claude reaches the gateway on the Anthropic driver, so the refusal is not always reported as GATEWAY."""
- result = classify_inference_error(_envelope("pipelex_document_host_refused", provider=provider))
-
- assert _unresolved_reference(_classified_code(result)) == GatewayUnresolvedReference.DOCUMENT_HOST_REFUSED
-
-
-class TestTheCodeSurvivesEveryExtractHop:
- """The refusal body the gateway actually emits, through each SDK that can carry it."""
-
- def test_through_the_portkey_substrate(self) -> None:
- exc = _as_the_portkey_sdk_raises_it(status_code=400, body=_UNRESOLVED_BODY)
-
- metadata = extract_gateway_metadata(exc)
-
- assert metadata.provider_error_code == "pig-09"
- assert _unresolved_reference(metadata.provider_error_code) == GatewayUnresolvedReference.REFERENCE_UNRESOLVED
-
- def test_the_portkey_substrate_discards_the_payload_and_the_code_survives_anyway(self) -> None:
- """The reason the hop above is built through the SDK rather than by hand.
-
- Portkey's ``_make_status_error_from_response`` puts the *message string* on
- ``exc.body``, never the document — so a test that hands the constructor a
- nested dict passes on a shape production never produces, while the real path
- recovers no code at all.
- """
- exc = _as_the_portkey_sdk_raises_it(status_code=400, body=_UNRESOLVED_BODY)
-
- assert isinstance(getattr(exc, "body", None), str)
- assert _unresolved_reference(extract_gateway_metadata(exc).provider_error_code) == GatewayUnresolvedReference.REFERENCE_UNRESOLVED
-
- def test_the_native_envelope_survives_the_portkey_substrate_too(self) -> None:
- """A gateway extract reaches Azure Document Intelligence in the chat costume.
-
- The refusal is rendered by ``providerErrorResponse`` — the ``type``-bearing
- native envelope — and then raised by Portkey's factory, which replaces the
- payload with the message string. Recovering the code needs the response
- fallback *and* the ``code``-first precedence.
- """
- body = _native_route_refusal_body("that host is refused", "pipelex_document_host_refused")
- exc = _as_the_portkey_sdk_raises_it(status_code=400, body=body)
-
- metadata = extract_gateway_metadata(exc)
-
- assert metadata.provider_error_code == "pipelex_document_host_refused"
- assert _unresolved_reference(metadata.provider_error_code) == GatewayUnresolvedReference.DOCUMENT_HOST_REFUSED
-
- @pytest.mark.parametrize(
- ("code", "expected"),
- [
- ("pipelex_storage_uri_invalid", GatewayUnresolvedReference.STORAGE_REFERENCE_INVALID),
- ("pipelex_storage_unreadable", GatewayUnresolvedReference.STORAGE_OBJECT_UNREADABLE),
- ("pipelex_document_unsupported_type", GatewayUnresolvedReference.DOCUMENT_CONTENT_UNUSABLE),
- ],
- )
- def test_through_plain_httpx_on_the_native_routes(self, code: str, expected: GatewayUnresolvedReference) -> None:
- """Where the ``pipelex_*`` codes are actually raised: ``/v1/pipelex/extract`` and its siblings."""
- request = httpx.Request("POST", f"{_ORIGIN}/v1/pipelex/extract")
- response = httpx.Response(status_code=400, request=request, json=_native_route_refusal_body("refused", code))
- exc = httpx.HTTPStatusError("Client error '400 Bad Request'", request=request, response=response)
-
- metadata = extract_pipelex_hosted_metadata(exc)
-
- assert metadata.provider_error_code == code
- assert _unresolved_reference(metadata.provider_error_code) == expected
-
- def test_through_the_shared_anthropic_driver(self) -> None:
- """Claude travels on the vendor's own SDK, which recovers the code from the body it kept."""
- request = httpx.Request("POST", f"{_ORIGIN}/v1/messages")
- response = httpx.Response(status_code=400, request=request)
- exc = anthropic.BadRequestError(message="error", response=response, body=_UNRESOLVED_BODY)
-
- metadata = extract_anthropic_metadata(exc)
-
- assert metadata.provider_error_code == "pig-09"
- assert _unresolved_reference(metadata.provider_error_code) == GatewayUnresolvedReference.REFERENCE_UNRESOLVED
-
- def test_through_the_openai_substrate_that_carries_every_chat_call(self) -> None:
- """The hop a gateway or hosted LLM call actually takes.
-
- That hop reads ``type`` before ``code``, which is right for the vendor it
- also serves — it recovers ``pig-09`` because the fail-closed envelope
- carries no ``type`` at all. That is a property of the gateway's envelope, so
- it is checked here rather than assumed.
- """
- exc = _as_the_openai_sdk_raises_it(status_code=400, body=_UNRESOLVED_BODY)
-
- metadata = extract_openai_metadata(exc)
-
- assert _unresolved_reference(metadata.provider_error_code) == GatewayUnresolvedReference.REFERENCE_UNRESOLVED
-
-
-class TestClassification:
- """An unresolvable reference is a caller error the runtime must not retry."""
-
- @pytest.mark.parametrize(("code", "expected"), _EVERY_CODE_AND_MEMBER)
- def test_each_code_classifies_as_its_member_and_is_never_retried(self, code: str, expected: GatewayUnresolvedReference) -> None:
- result = classify_inference_error(_envelope(code))
-
- assert _unresolved_reference(_classified_code(result)) == expected
- assert result.category.is_retryable is False
- assert result.is_model_not_found is False
- assert _classified_code(result) == code
- assert _request_limit(_classified_code(result)) is None
-
- @pytest.mark.parametrize("code", _CALLER_FIXABLE_CODES)
- def test_a_reference_the_caller_can_repair_asks_them_to_change_the_input(self, code: str) -> None:
- result = classify_inference_error(_envelope(code))
-
- assert result.category == InferenceErrorCategory.CONTENT
- assert result.user_action_kind == UserActionKind.CHANGE_INPUT
-
- def test_a_deployment_that_serves_no_storage_is_an_operators_problem(self) -> None:
- """No bucket configured is not something any input can avoid, so the caller is not asked to try."""
- result = classify_inference_error(_envelope("pipelex_storage_uri_unsupported"))
-
- assert _unresolved_reference(_classified_code(result)) == GatewayUnresolvedReference.STORAGE_NOT_SERVED
- assert result.category == InferenceErrorCategory.CONFIGURATION
- assert result.user_action_kind == UserActionKind.CONTACT_SUPPORT
- assert result.category.is_retryable is False
-
- def test_a_plain_400_without_a_recognized_code_still_takes_the_status_ladder(self) -> None:
- """Only the gateway's own codes name a reference; a bare 400 from a vendor does not."""
- result = classify_inference_error(_envelope("something-else"))
-
- assert _classified_code(result) is None
- assert result.category == InferenceErrorCategory.CONTENT
- assert result.user_action_kind == UserActionKind.CHANGE_INPUT
-
-
-class TestRenderedAdvice:
- """Each member gets advice naming what to do about the reference, not the generic rejection line."""
-
- @pytest.mark.parametrize("code", _EVERY_CODE)
- def test_no_member_renders_the_generic_rejection_line(self, code: str) -> None:
- """The whole point: every one of these used to read as a prompt to revise."""
- assert _rendered_detail(_envelope(code)) != _GENERIC_ADVICE
-
- @pytest.mark.parametrize(
- ("code", "expected_phrase"),
- [
- ("pig-09", "could not be resolved"),
- ("pipelex_storage_uri_invalid", "malformed"),
- ("pipelex_storage_unreadable", "does not exist or cannot be read"),
- ("pipelex_storage_uri_unsupported", "contact support"),
- ("pipelex_unsupported_uri_scheme", "pipelex-storage:// reference"),
- ("pipelex_document_scheme_refused", "https:// URL"),
- ("pipelex_document_host_refused", "security policy"),
- ("pipelex_document_unreachable", "publicly reachable"),
- ("pipelex_document_empty", "fetched but cannot be used"),
- ],
- )
- def test_the_detail_names_the_remedy(self, code: str, expected_phrase: str) -> None:
- assert expected_phrase in _rendered_detail(_envelope(code))
-
- def test_the_host_refusal_is_stated_as_a_security_policy(self) -> None:
- """The distinction the whole ``DOCUMENT_HOST_REFUSED`` member exists to keep.
-
- The SSRF guard refused deliberately. Advice that reads as a fault to work
- around — revise the prompt, use a smaller file — sends the caller looking
- for a problem in a document that is perfectly fine.
- """
- detail = _rendered_detail(_envelope("pipelex_document_host_refused"))
-
- assert "security policy" in detail
- assert "prompt" not in detail
- assert "smaller" not in detail
-
- def test_the_unserved_scheme_does_not_ask_the_caller_to_fix_their_input(self) -> None:
- detail = _rendered_detail(_envelope("pipelex_storage_uri_unsupported"))
-
- assert "contact support" in detail
- assert "prompt" not in detail
-
- def test_the_two_storage_reference_failures_are_told_apart(self) -> None:
- """A key that is malformed and an object that is not there need different checks."""
- malformed = _rendered_detail(_envelope("pipelex_storage_uri_invalid"))
- unreadable = _rendered_detail(_envelope("pipelex_storage_unreadable"))
-
- assert malformed != unreadable
-
- def test_the_url_shape_refusals_share_one_remedy(self) -> None:
- """They are one member precisely because the caller's next move is the same."""
- details = {
- _rendered_detail(_envelope(code))
- for code in (
- "pipelex_unsupported_uri_scheme",
- "pipelex_document_scheme_refused",
- "pipelex_document_address_refused",
- "pipelex_document_redirect_refused",
- )
- }
-
- assert len(details) == 1
-
- def test_a_host_refusal_reaching_an_extract_reads_the_same(self) -> None:
- """The document-fetch codes arrive on extract calls, so the advice must not assume an LLM family."""
- metadata = _envelope("pipelex_document_host_refused")
-
- assert _rendered_detail(metadata, family=InferenceErrorFamily.EXTRACT) == _rendered_detail(metadata)
-
-
-class TestTheTwoGatewayFamiliesDoNotShadowEachOther:
- """One bounds the request's shape, the other says a reference could not be resolved.
-
- The same middleware raises ``pig-09`` and ``pig-10``, and the native routes'
- storage codes sit in one frozen contract — so the two maps are neighbours in the
- same namespace and a code landing in both would silently give one family's
- advice to the other's refusal.
- """
-
- @pytest.mark.parametrize("code", _EVERY_CODE)
- def test_no_unresolved_reference_code_is_also_a_request_limit(self, code: str) -> None:
- assert _request_limit(code) is None
-
- @pytest.mark.parametrize("code", ["pig-07", "pig-08", "pig-10", "pig-11", "pipelex_storage_object_too_large", "pipelex_document_too_large"])
- def test_no_request_limit_code_is_also_an_unresolved_reference(self, code: str) -> None:
- assert _unresolved_reference(code) is None
-
- def test_the_storage_codes_are_split_between_the_two_families_on_the_same_route(self) -> None:
- """Both arrive from ``/v1/pipelex/extract``, and each must reach its own family."""
- too_large = _envelope("pipelex_storage_object_too_large", status_code=413)
- unreadable = _envelope("pipelex_storage_unreadable")
-
- too_large_code = _classified_code(classify_inference_error(too_large))
- unreadable_code = _classified_code(classify_inference_error(unreadable))
-
- assert _request_limit(too_large_code) == GatewayRequestLimit.OBJECT_TOO_LARGE
- assert _unresolved_reference(too_large_code) is None
- assert _unresolved_reference(unreadable_code) == GatewayUnresolvedReference.STORAGE_OBJECT_UNREADABLE
- assert _request_limit(unreadable_code) is None
diff --git a/tests/unit/pipelex/providers/test_instructor_retry_shapes.py b/tests/unit/pipelex/providers/test_instructor_retry_shapes.py
index 74ea60ba7..8a6b369c4 100644
--- a/tests/unit/pipelex/providers/test_instructor_retry_shapes.py
+++ b/tests/unit/pipelex/providers/test_instructor_retry_shapes.py
@@ -257,7 +257,7 @@ class TestInstructorRetryShapes:
inference_model = mocker.MagicMock()
inference_model.name = _MODEL_HANDLE
inference_model.model_id = _WIRE_ID
- inference_model.desc = f"{_MODEL_HANDLE} → SDK[manifold_completions]•Backend[pipelex_manifold]•Model[{_WIRE_ID}]"
+ inference_model.desc = f"{_MODEL_HANDLE} → SDK[portkey_completions]•Backend[portkey]•Model[{_WIRE_ID}]"
inference_model.thinking_mode = None
inference_model.listed_constraints = []
worker.inference_model = inference_model