(aws_bedrockagentcore): Python version of ToolSchema.from_inline does not accept a dictionary
Describe the bug
When I was trying to work out the correct way to specify an inline tool schema, I got the error
TypeError: type of argument schema[0] must be one of (aws_cdk.aws_bedrockagentcore.ToolDefinition, Dict[str, Any]); got str insteadI took this to indicate that the Python version of ToolSchema.from_inline will accept a list of dictionaries, as the Typescript version does. However, when I tried:
aws_bedrockagentcore.ToolSchema.from_inline([{
"name": "get_time",
"description": "Get time for a timezone",
"inputSchema": {
"type": "object",
"properties": {
"timezone": {
"type": "string",
},
},
"required": [
"timezone",
],
},
}])I got the error
@jsii/kernel.RuntimeError: @jsii/kernel.SerializationError: Passed to parameter schema of static method aws-cdk-lib.aws_bedrockagentcore.ToolSchema.fromInline: Unable to deserialize value as array<aws-cdk-lib.aws_bedrockagentcore.ToolDefinition>
├── Failing value is an array
│ [ [Object] ]
╰── Failure reason(s):
╰─ Index 0: Unable to deserialize value as aws-cdk-lib.aws_bedrockagentcore.ToolDefinition
├── Failing value is an object
│ { '$jsii.map': [Object] }
╰── Failure reason(s):
╰─ Key 'inputSchema': Unable to deserialize value as aws-cdk-lib.aws_bedrockagentcore.SchemaDefinition
├── Failing value is an object
│ { '$jsii.map': [Object] }
╰── Failure reason(s):
╰─ Key 'type': Unable to deserialize value as aws-cdk-lib.aws_bedrockagentcore.SchemaDefinitionType
├── Failing value is a string
│ 'object'
╰── Failure reason(s):
╰─ Value does not have the "$jsii.byref" keyWhich if I understand correctly, means that actually it will not allow you to use a dictionary, and you have to use a typed object.
Either it should only accept a typed object, and the documentation and error messages be fixed, or it should accept a dict.
Regression Issue
- Select this option if this issue appears to be a regression.
Last Known Working CDK Library Version
No response
Expected Behavior
To be able to specify a tool schema using a list containing a dictionary.
Current Behavior
I get an error because I'm not provided JSII objects.
Reproduction Steps
aws_bedrockagentcore.ToolSchema.from_inline([{
"name": "get_time",
"description": "Get time for a timezone",
"inputSchema": {
"type": "object",
"properties": {
"timezone": {
"type": "string",
},
},
"required": [
"timezone",
],
},
}])In a Python CDK project should do it.
Possible Solution
No response
Additional Information/Context
No response
AWS CDK Library version (aws-cdk-lib)
2.268.0
AWS CDK CLI version
2.1142.0 (build a73eebf)
Node.js Version
v24.13.0
OS
Linux Mint 22.3 - Cinnamon 64-bit
Language
Python
Language Version
3.11.14
Other information
No response
Source: aws/aws-cdk