Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
ekzhu committed Feb 13, 2025
1 parent b7ddcd3 commit 9246ee7
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions python/packages/autogen-core/src/autogen_core/tools/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,19 +89,21 @@ def schema(self) -> ToolSchema:
type="object",
properties=model_schema["properties"],
required=model_schema.get("required", []),
additionalProperties=model_schema.get("additionalProperties", False),
)

# If strict is enabled, the tool schema should list all properties as required.
assert "required" in parameters
if self._strict and set(parameters["required"]) != set(parameters["properties"].keys()):
raise ValueError(
"Strict mode is enabled, but not all input arguments are marked as required. Default arguments are not allowed in strict mode."
)

if "additionalProperties" in model_schema:
parameters["additionalProperties"] = model_schema["additionalProperties"]
elif self._strict:
# If strict is enabled, we don't allow additional properties.
parameters["additionalProperties"] = False
assert "additionalProperties" in parameters
if self._strict and parameters["additionalProperties"]:
raise ValueError(
"Strict mode is enabled but additional argument is also enabled. This is not allowed in strict mode."
)

tool_schema = ToolSchema(
name=self._name,
Expand Down

0 comments on commit 9246ee7

Please sign in to comment.