openai-agents-python/tests
xianghuijin 6ed0bee672 fix: prevent modifying the original agent's model_settings
This fixes the issue where the original agent's model_settings was being directly modified during the tool choice reset process. The original implementation caused the agent's tool_choice to unintentionally reset to "auto" for subsequent runs, which could be unexpected behavior.

The fix creates new copies of the agent and model settings objects using dataclasses.replace() instead of modifying the original objects. This ensures that the tool choice reset is limited to the current run only, maintaining the expected behavior for sequential runs with the same agent.

Addresses feedback from @baderalfahad about the agent instance being modified when it should maintain its original state between runs.
2025-03-23 17:20:23 +08:00
..
__init__.py Initial commit 2025-03-11 09:42:28 -07:00
conftest.py Initial commit 2025-03-11 09:42:28 -07:00
fake_model.py Initial commit 2025-03-11 09:42:28 -07:00
README.md Pretty print result classes 2025-03-17 11:11:39 -04:00
test_agent_config.py Initial commit 2025-03-11 09:42:28 -07:00
test_agent_hooks.py Initial commit 2025-03-11 09:42:28 -07:00
test_agent_runner.py Introduce tool_use_behavior on agents 2025-03-18 21:55:12 -04:00
test_agent_runner_streamed.py Initial commit 2025-03-11 09:42:28 -07:00
test_agent_tracing.py Stronger tracing tests with inline-snapshot 2025-03-11 22:57:14 +02:00
test_computer_action.py Initial commit 2025-03-11 09:42:28 -07:00
test_config.py make format 2025-03-11 14:54:10 -07:00
test_doc_parsing.py Initial commit 2025-03-11 09:42:28 -07:00
test_extension_filters.py Initial commit 2025-03-11 09:42:28 -07:00
test_function_schema.py Initial commit 2025-03-11 09:42:28 -07:00
test_function_tool.py Introduce tool_use_behavior on agents 2025-03-18 21:55:12 -04:00
test_function_tool_decorator.py Update tests and docs for strict mode decorator 2025-03-17 15:06:57 -04:00
test_global_hooks.py Initial commit 2025-03-11 09:42:28 -07:00
test_guardrails.py Initial commit 2025-03-11 09:42:28 -07:00
test_handoff_tool.py Initial commit 2025-03-11 09:42:28 -07:00
test_items_helpers.py pin to openai 1.66.2, update tests 2025-03-11 15:26:06 -07:00
test_max_turns.py Initial commit 2025-03-11 09:42:28 -07:00
test_openai_chatcompletions.py Initial commit 2025-03-11 09:42:28 -07:00
test_openai_chatcompletions_converter.py refactor: update formatting in test_assistant_messages_in_history 2025-03-13 00:20:59 +05:00
test_openai_chatcompletions_stream.py Fix streaming in chat completions 2025-03-12 17:17:07 -07:00
test_openai_responses_converter.py pin to openai 1.66.2, update tests 2025-03-11 15:26:06 -07:00
test_output_tool.py utils directory 2025-03-16 18:48:45 -04:00
test_pretty_print.py Pretty print result classes 2025-03-17 11:11:39 -04:00
test_responses.py Initial commit 2025-03-11 09:42:28 -07:00
test_responses_tracing.py Stronger tracing tests with inline-snapshot 2025-03-11 22:57:14 +02:00
test_result_cast.py Initial commit 2025-03-11 09:42:28 -07:00
test_run_config.py Initial commit 2025-03-11 09:42:28 -07:00
test_run_step_execution.py Initial commit 2025-03-11 09:42:28 -07:00
test_run_step_processing.py pin to openai 1.66.2, update tests 2025-03-11 15:26:06 -07:00
test_strict_schema.py Initial commit 2025-03-11 09:42:28 -07:00
test_tool_choice_reset.py fix: prevent modifying the original agent's model_settings 2025-03-23 17:20:23 +08:00
test_tool_converter.py Initial commit 2025-03-11 09:42:28 -07:00
test_tool_use_behavior.py Introduce tool_use_behavior on agents 2025-03-18 21:55:12 -04:00
test_trace_processor.py Initial commit 2025-03-11 09:42:28 -07:00
test_tracing.py Initial commit 2025-03-11 09:42:28 -07:00
test_tracing_errors.py Stronger tracing tests with inline-snapshot 2025-03-11 22:57:14 +02:00
test_tracing_errors_streamed.py Stronger tracing tests with inline-snapshot 2025-03-11 22:57:14 +02:00
testing_processor.py mypy 2025-03-17 23:56:42 +02:00

Tests

Before running any tests, make sure you have uv installed (and ideally run make sync after).

Running tests

make tests

Snapshots

We use inline-snapshots for some tests. If your code adds new snapshot tests or breaks existing ones, you can fix/create them. After fixing/creating snapshots, run make tests again to verify the tests pass.

Fixing snapshots

make snapshots-fix

Creating snapshots

make snapshots-update