Skip to content

Commit

Permalink
Fix JSON schema error when using tools with anyOf instead of type (#2196
Browse files Browse the repository at this point in the history
)

## Description

- **Summary of changes**: handle case where properties of the input
schema of a tool doesn't have `type` but uses `anyOf`
- **Motivation and context**: Using Agno, Claude, Composio, and trying
to send an email with Gmail, breaks with JSON schema error
  • Loading branch information
kepler authored Feb 20, 2025
1 parent 07e870a commit 2c796f6
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions libs/agno/agno/models/anthropic/claude.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,13 +271,15 @@ def _format_tools_for_model(self) -> Optional[List[Dict[str, Any]]]:
if "null" not in param_type_list:
required_params.append(param_name)

input_properties: Dict[str, Dict[str, Union[str, List[str]]]] = {
param_name: {
"type": param_info.get("type", ""),
input_properties: Dict[str, Dict[str, Union[str, List[str]]]] = {}
for param_name, param_info in properties.items():
input_properties[param_name] = {
"description": param_info.get("description", ""),
}
for param_name, param_info in properties.items()
}
if "type" not in param_info and "anyOf" in param_info:
input_properties[param_name]["anyOf"] = param_info["anyOf"]
else:
input_properties[param_name]["type"] = param_info.get("type", "")

tool = {
"name": func_name,
Expand Down

0 comments on commit 2c796f6

Please sign in to comment.