generated from amazon-archives/__template_Apache-2.0
-
Notifications
You must be signed in to change notification settings - Fork 465
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Checks
- I have updated to the lastest minor and patch version of Strands
- I have checked the documentation and this is not expected behavior
- I have searched ./issues and there are no duplicates of my issue
Strands Version
Latest
Python Version
3.10.18
Operating System
Mac os
Installation Method
other
Steps to Reproduce
import json
from typing import Optional
from strands import tool
@tool
def my_tool(param1: str, param2: Optional[int]) -> dict:
"""
Tool description - explain what it does.
#Args:
param1: Description of first parameter.
param2: Description of second parameter (default: 42).
#Returns:
A dictionary with the results.
"""
result = f"{param1} + {param2}"
return {"status": "success", "content": [{"text": f"Result: {result}"}]}
@tool
def my_tool2(param1: str, param2: int | None) -> dict:
"""
Tool description - explain what it does.
#Args:
param1: Description of first parameter.
param2: Description of second parameter (default: 42).
#Returns:
A dictionary with the results.
"""
result = f"{param1} + {param2}"
return {"status": "success", "content": [{"text": f"Result: {result}"}]}
@tool
def my_tool3(param1: str, param2: Optional[int] = None) -> dict:
"""
Tool description - explain what it does.
#Args:
param1: Description of first parameter.
param2: Description of second parameter (default: 42).
#Returns:
A dictionary with the results.
"""
result = f"{param1} + {param2}"
return {"status": "success", "content": [{"text": f"Result: {result}"}]}
if __name__ == "__main__":
print(
json.dumps(
my_tool.tool_spec,
indent=4,
)
)
print(
json.dumps(
my_tool2.tool_spec,
indent=4,
)
)
print(
json.dumps(
my_tool3.tool_spec,
indent=4,
)
)Expected Behavior
I expect that @tool decorator respects python's type annotation.
It is clear that it doesn't.
Actual Behavior
{
"name": "my_tool",
"description": "Tool description - explain what it does.\n\n#Args:\n param1: Description of first parameter.\n param2: Description of second parameter (default: 42).\n\n#Returns:\n A dictionary with the results.",
"inputSchema": {
"json": {
"properties": {
"param1": {
"description": "Parameter param1",
"type": "string"
},
"param2": {
"description": "Parameter param2",
"type": "integer"
}
},
"required": [
"param1",
"param2"
],
"type": "object"
}
}
}
{
"name": "my_tool2",
"description": "Tool description - explain what it does.\n\n#Args:\n param1: Description of first parameter.\n param2: Description of second parameter (default: 42).\n\n#Returns:\n A dictionary with the results.",
"inputSchema": {
"json": {
"properties": {
"param1": {
"description": "Parameter param1",
"type": "string"
},
"param2": {
"description": "Parameter param2",
"type": "integer"
}
},
"required": [
"param1",
"param2"
],
"type": "object"
}
}
}
{
"name": "my_tool3",
"description": "Tool description - explain what it does.\n\n#Args:\n param1: Description of first parameter.\n param2: Description of second parameter (default: 42).\n\n#Returns:\n A dictionary with the results.",
"inputSchema": {
"json": {
"properties": {
"param1": {
"description": "Parameter param1",
"type": "string"
},
"param2": {
"default": null,
"description": "Parameter param2",
"type": "integer"
}
},
"required": [
"param1"
],
"type": "object"
}
}
}Additional Context
One can see that required does not respect python's type annotation but only checks if a default value is set.
Possible Solution
No response
Related Issues
No response
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working