generated from amazon-archives/__template_Apache-2.0
    
        
        - 
                Notifications
    You must be signed in to change notification settings 
- Fork 453
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Checks
- I have updated to the latest 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.12
Operating System
AL2
Installation Method
pip
Steps to Reproduce
import copy
from strands.tools import normalize_tool_spec
def test_schema():
    schema = {
      "name": "sleep",
      "description": "Pause execution for the specified number of seconds.\n\nThis tool pauses the execution flow for the given number of seconds.\nIt can be interrupted with SIGINT (Ctrl+C).\n\nArgs:\n    seconds (Union[int, float]): Number of seconds to sleep.\n        Must be a positive number greater than 0 and less than or equal to\n        the maximum allowed value (default: 300 seconds, configurable via\n        MAX_SLEEP_SECONDS environment variable).\n\nReturns:\n    str: A message indicating the sleep completed or was interrupted.\n\nRaises:\n    ValueError: If seconds is not positive, exceeds the maximum allowed value,\n               or is not a number.\n\nExamples:\n    >>> sleep(5)  # Sleeps for 5 seconds\n    'Started sleep at 2025-05-30 11:30:00, slept for 5.0 seconds'\n\n    >>> sleep(0.5)  # Sleeps for half a second\n    'Started sleep at 2025-05-30 11:30:00, slept for 0.5 seconds'",
      "inputSchema": {
        "json": {
          "properties": {
            "seconds": {
              "anyOf": [
                {
                  "type": "integer"
                },
                {
                  "type": "number"
                }
              ],
              "description": "Number of seconds to sleep.\nMust be a positive number greater than 0 and less than or equal to\nthe maximum allowed value (default: 300 seconds, configurable via\nMAX_SLEEP_SECONDS environment variable)."
            }
          },
          "required": [
            "seconds"
          ],
          "type": "object"
        }
      }
    }
    assert normalize_tool_spec(copy.deepcopy(schema)) == schemaExpected Behavior
don't add default type "string" in case there is "anyOf". maybe never add it.
Actual Behavior
There is a bug in _normalize_property, in particular: 
sdk-python/src/strands/tools/tools.py
Line 91 in 071f89f
| normalized_prop.setdefault("type", "string") | 
pytest output:
                        'equal to\n'
                        'the maximum allowed value (default: 300 seconds, '
                        'configurable via\n'
                        'MAX_SLEEP_SECONDS environment variable).',
+                       'type': 'string',
                    },
                },
                'required': [
                    'seconds',
                ],
                'type': 'object',
            },
        },
        'name': 'sleep',
    }Additional Context
No response
Possible Solution
No response
Related Issues
No response
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working