Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions src/agents/run_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,12 @@ class ToolExecutionConfig:
"""

def __post_init__(self) -> None:
if self.max_function_tool_concurrency is not None and (
self.max_function_tool_concurrency < 1
):
value = self.max_function_tool_concurrency
if value is not None and (isinstance(value, bool) or not isinstance(value, int)):
raise TypeError(
"tool_execution.max_function_tool_concurrency must be a positive integer or None"
)
if value is not None and value < 1:
raise ValueError("tool_execution.max_function_tool_concurrency must be at least 1")
if not isinstance(self.pre_approval_tool_input_guardrails, bool):
raise ValueError("tool_execution.pre_approval_tool_input_guardrails must be a bool")
Expand Down
11 changes: 11 additions & 0 deletions tests/test_run_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,17 @@ def test_tool_execution_config_rejects_invalid_function_tool_concurrency() -> No
ToolExecutionConfig(max_function_tool_concurrency=0)


@pytest.mark.parametrize("value", [True, 1.5])
def test_tool_execution_config_rejects_non_integer_function_tool_concurrency(
value: object,
) -> None:
with pytest.raises(
TypeError,
match="tool_execution.max_function_tool_concurrency must be a positive integer or None",
):
ToolExecutionConfig(max_function_tool_concurrency=cast(Any, value))


def test_tool_execution_config_is_public_from_agents_package() -> None:
config = RunConfig(tool_execution=ToolExecutionConfig(max_function_tool_concurrency=2))

Expand Down