(aws_bedrockagentcore): ToolSchema.from_inline 的 Python 版本不接受字典
作者: SamStephens创建于 2026年9月24日更新于 2026年9月28日
标签bugp2@aws-cdk/aws-bedrock-agentcore-alpha
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 instead I 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" key If I understand correctly, this 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.
内容来源: aws/aws-cdk