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. |
||
|---|---|---|
| .. | ||
| __init__.py | ||
| conftest.py | ||
| fake_model.py | ||
| README.md | ||
| test_agent_config.py | ||
| test_agent_hooks.py | ||
| test_agent_runner.py | ||
| test_agent_runner_streamed.py | ||
| test_agent_tracing.py | ||
| test_computer_action.py | ||
| test_config.py | ||
| test_doc_parsing.py | ||
| test_extension_filters.py | ||
| test_function_schema.py | ||
| test_function_tool.py | ||
| test_function_tool_decorator.py | ||
| test_global_hooks.py | ||
| test_guardrails.py | ||
| test_handoff_tool.py | ||
| test_items_helpers.py | ||
| test_max_turns.py | ||
| test_openai_chatcompletions.py | ||
| test_openai_chatcompletions_converter.py | ||
| test_openai_chatcompletions_stream.py | ||
| test_openai_responses_converter.py | ||
| test_output_tool.py | ||
| test_pretty_print.py | ||
| test_responses.py | ||
| test_responses_tracing.py | ||
| test_result_cast.py | ||
| test_run_config.py | ||
| test_run_step_execution.py | ||
| test_run_step_processing.py | ||
| test_strict_schema.py | ||
| test_tool_choice_reset.py | ||
| test_tool_converter.py | ||
| test_tool_use_behavior.py | ||
| test_trace_processor.py | ||
| test_tracing.py | ||
| test_tracing_errors.py | ||
| test_tracing_errors_streamed.py | ||
| testing_processor.py | ||
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