Python: tests/samples fails to collect because four test modules import samples that no longer exist
Description
python/tests/samples can't be collected on main. Four of its six test modules import sample files that no longer exist:
$ uv run pytest tests/samples --collect-only -q
ERROR tests/samples/getting_started/test_agent_samples.py
ERROR tests/samples/getting_started/test_chat_client_samples.py
ERROR tests/samples/getting_started/test_threads_samples.py
ERROR tests/samples/hosting/test_toolbox_endpoint.py - FileNotFoundError: [Errno 2] No such file or directory: '.../responses/04_foundry_toolbox/main.py'
!!!!!!!!!!!!!!!!!!! Interrupted: 4 errors during collection !!!!!!!!!!!!!!!!!!!!
getting_started/*.py(56 imports) importsamples.getting_started.agents.*,samples.getting_started.client.*andsamples.getting_started.threads.*. That tree was replaced by the01-get-started…05-end-to-endlayout in #3862. Several of the referenced samples also use clients that were later removed, such as the Azure assistants clients removed in #4990. Every import fails withModuleNotFoundError: No module named 'samples.getting_started'.hosting/test_toolbox_endpoint.pyloads04_foundry_toolbox/main.pyand06_files/main.py. #7405 renamed those folders, and the samples no longer defineresolve_toolbox_endpoint. The resolver now lives inagent_framework_foundry_hosting._toolbox._resolve_toolbox_endpoint, andpackages/foundry_hosting/tests/test_toolbox.pytests it.
Pytest stops the whole session on collection errors. So the "Test OpenAI samples" and "Test Azure samples" steps in python-merge-tests.yml (uv run pytest tests/samples/ -m "openai" / -m "azure", gated on RUN_SAMPLES_TESTS) can't run any test, including the two modules that still collect.
Expected behavior
pytest tests/samples collects. The sample integration tests either target samples that exist or are removed.
Proposed fix
hosting/test_toolbox_endpoint.py: delete it. Its cases are covered bypackages/foundry_hosting/tests/test_toolbox.py, and I'm porting the one extra case (several trailing slashes on the project endpoint). I have a PR for this part.getting_started/*.py: this needs a maintainer decision. Either repoint the tests at the current01-get-started/02-agentssamples, or delete them if the sample integration tests aren't maintained any more. I'm happy to do either.
Package Versions
main at c4de86d41
Python Version
3.13
AI Assistance
Claude Code helped find this while checking which sample files the tests reference, and helped draft this report. I reproduced the collection errors locally.
Could you provide a coverage map for the three remaining getting_started test modules, separating cases that map to current maintained samples from cases whose APIs/samples were intentionally removed? That would let us choose repointing versus retirement without silently losing supported-scenario coverage. Existing #9762 is explicitly the hosting-only part and does not resolve those three collection failures.
Here is the coverage map for python/tests/samples on current main (@ b193c1b6), built by parsing all 56 parametrized cases in the three getting_started modules and resolving each against the current samples/ tree.
hosting/test_toolbox_endpoint.py — no longer testable as written
The module tests resolve_toolbox_endpoint() in 04_foundry_toolbox/main.py and 06_files/main.py. Neither function exists anymore: after the #7405 rename the directories are responses/foundry_toolbox/ and responses/files/, and both main.py files were rewritten to build a FoundryToolbox(credential) inside create_agent() — no local endpoint-resolution helper. That logic now lives in the product package and is already covered by python/packages/foundry_hosting/tests/test_toolbox.py (_resolve_toolbox_endpoint, lines 42/329-350). Disposition: delete the module; coverage is subsumed by the package tests.
getting_started modules — 56 param cases
(A) 38 cases map to a maintained sample that exists today (each target verified to still define main):
| Old import family | Count | Current sample |
|---|---|---|
agents.openai.openai_responses_client_* |
9 | 02-agents/providers/openai/client_{basic,reasoning,with_code_interpreter,with_explicit_settings,with_file_search,with_function_tools,with_local_mcp,with_session,with_web_search} |
agents.openai.openai_chat_client_* |
6 | 02-agents/providers/openai/chat_completion_client_{basic,with_explicit_settings,with_function_tools,with_local_mcp,with_session,with_web_search} |
agents.azure_ai.azure_ai_* |
5 | 02-agents/providers/foundry/foundry_agent_basic, foundry_chat_client_{with_code_interpreter,with_local_mcp,with_session} (_with_thread → with_session) |
agents.azure_openai.azure_responses_client_* |
3 | 02-agents/providers/azure/openai_client_{basic,with_function_tools,with_session} |
agents.azure_openai.azure_chat_client_* |
4 | 02-agents/providers/azure/openai_chat_completion_client_{basic,with_explicit_settings,with_function_tools,with_session} |
client.* (non-assistants) |
6 | 02-agents/providers/{openai,azure}/…client_basic, foundry_chat_client_basic, chat_client/chat_response_cancellation |
threads.* |
2 | 02-agents/conversations/{custom_history_provider,suspend_resume_session} |
agents.openai.azure_ai_basic etc. |
3 | (covered in the foundry/azure rows above) |
(B) 15 cases reference removed assistants clients — azure_assistants_* (6), openai_assistants_* (7), client.{azure,openai}_assistants_client (2). The assistants client family was removed in #4990 and has no maintained successor sample. Disposition: drop these param cases.
(C) 3 cases have no current equivalent:
agents.azure_openai.azure_responses_client_with_code_interpreterand…_with_explicit_settings— the Azure Responses-API variants were never recreated underproviders/azure/(onlyopenai_client_{basic,with_function_tools,with_session,with_structured_output}exist). Disposition: either drop, or cover via the plain-openaiequivalents.agents.azure_ai.azure_ai_with_function_tools— the test importsmixed_tools_example/tools_on_agent_level/tools_on_run_level; today'sfoundry_agent_with_function_tools.pydefines a different surface. Disposition: re-point tofoundry_agent_with_function_tools.mainand rewrite the case, or drop.
Caveat + proposal
The map above is filename/symbol-level. Re-pointing (A) still needs each case's mocked-response list re-checked against the new samples' actual call sequences — the old recorded responses were written against the removed API shapes. I'm happy to take this issue: re-point the 38 (A) cases with refreshed mocks, drop the 15 (B) and 2–3 (C) cases per your preference, delete the hosting module, and get pytest tests/samples --collect-only green again.
🤖 This analysis was prepared with AI assistance (ZCode); publishing was confirmed by the human author.
Co-Authored-By: ZCode [email protected]