Skip to content

Bedrock InvokeInlineAgentCommand triggers server error if action groups parameters required attribute is not set #6772

@maximelebastard

Description

@maximelebastard

Checkboxes for prior research

Describe the bug

In InvokeInlineAgentCommandInput, the attribute actionGroups.functionSchema.functions.parameters.my_parameter.required is typed as optional. However, the command crashes if it is not explicitely set to true or false.

Regression Issue

  • Select this option if this issue appears to be a regression.

SDK version number

@aws-sdk/[email protected]

Which JavaScript Runtime is this issue in?

Node.js

Details of the browser/Node.js/ReactNative version

v20.18.1

Reproduction Steps

// This works
await this.bedrockClient.send(new InvokeInlineAgentCommand({
    foundationModel: "anthropic.claude-3-5-sonnet-20241022-v2:0",
    instruction: "Translate the user input text to Spanish. Only do that, noting more.",
    actionGroups: [
        {
            actionGroupName: "profile-management",
            description: "Functions to manage user profiles including loading and saving profile information.",
            actionGroupExecutor: {
                customControl: "RETURN_CONTROL"
            },
            functionSchema: {
                functions: [
                    {
                        name: "save_profile",
                        description: "Save or update the user's profile",
                        parameters: {
                            name: { type: "string", "required": true }, // <-- Required is explicitely set
                        },
                    }
                ]
            }
        }],
    inputText: "Bonjour",
    // (Other arguments ommited for clarity...)
}));

// This doesn't work
await this.bedrockClient.send(new InvokeInlineAgentCommand({
    foundationModel: "anthropic.claude-3-5-sonnet-20241022-v2:0",
    instruction: "Translate the user input text to Spanish. Only do that, noting more.",
    actionGroups: [
        {
            actionGroupName: "profile-management",
            description: "Functions to manage user profiles including loading and saving profile information.",
            actionGroupExecutor: {
                customControl: "RETURN_CONTROL"
            },
            functionSchema: {
                functions: [
                    {
                        name: "save_profile",
                        description: "Save or update the user's profile",
                        parameters: {
                            name: { type: "string" }, // <-- Required is not set
                        },
                    }
                ]
            }
        }],
    inputText: "Bonjour",
    // (Other arguments ommited for clarity...)
}));

When it does not work, I get this error

 ERROR  Error: InternalServerException: Internal Server Exception
/Users/maxime/workspace/project/app/node_modules/@aws-sdk/client-bedrock-agent-runtime/dist-cjs/index.js:2706
  const exception = new InternalServerException({
                    ^

InternalServerException: Internal Server Exception
    at de_InternalServerExceptionRes (/Users/maxime/workspace/project/app/node_modules/@aws-sdk/client-bedrock-agent-runtime/dist-cjs/index.js:2706:21)
    at de_CommandError (/Users/maxime/workspace/project/app/node_modules/@aws-sdk/client-bedrock-agent-runtime/dist-cjs/index.js:2619:19)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async /Users/maxime/workspace/project/app/node_modules/@smithy/middleware-serde/dist-cjs/index.js:35:20
    at async /Users/maxime/workspace/project/app/node_modules/@smithy/core/dist-cjs/index.js:168:18
    at async /Users/maxime/workspace/project/app/node_modules/@smithy/middleware-retry/dist-cjs/index.js:320:38
    at async /Users/maxime/workspace/project/app/node_modules/@aws-sdk/middleware-logger/dist-cjs/index.js:34:22
    at async BedrockAgent.run (/Users/maxime/workspace/project/app/src/bedrock-agent.ts:381:26)
    at async main (/Users/maxime/workspace/project/app/src/debugger.ts:44:30) {
  '$fault': 'server',
  '$metadata': {
    httpStatusCode: 500,
    requestId: 'ade3e9b7-xxxx-xxxx-xxxx-33ef997c7b7c',
    extendedRequestId: undefined,
    cfId: undefined,
    attempts: 3,
    totalRetryDelay: 95
  }
}

Observed Behavior

Not explicitely setting the optional attribute actionGroups.functionSchema.functions.parameters.my_parameter.requiredtriggers a cryptic Internal Server Error

Expected Behavior

Being able to not set required OR having it typed as not optional

Possible Solution

No response

Additional Information/Context

No response

Metadata

Metadata

Assignees

Labels

bugThis issue is a bug.p2This is a standard priority issueservice-apiThis issue is due to a problem in a service API, not the SDK implementation.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions