Skip to content

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

Closed
@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/client-bedrock-agent-runtime@3.721.0

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

Activity

zshzbh

zshzbh commented on Jan 7, 2025

@zshzbh
Contributor

Hey @maximelebastard ,

I can reproduce this issue -

Code I have

import { BedrockAgentRuntimeClient, InvokeInlineAgentCommand } from "@aws-sdk/client-bedrock-agent-runtime"
const bedrockClient = new BedrockAgentRuntimeClient({
    region: "us-east-1",
});
const res = await bedrockClient.send(new InvokeInlineAgentCommand({
	sessionId: "session_1",
    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"}, // <--Use without "required"
                        },
                    }
                ]
            }
        }],
    inputText: "Bonjour",
    // (Other arguments ommited for clarity...)
}));
console.log(res)

the console log I have -

/Users/zshzbh/Desktop/newProj/Issues6000s/node_modules/@aws-sdk/client-bedrock-agent-runtime/dist-cjs/index.js:2732
  const exception = new InternalServerException({
                    ^

InternalServerException: Internal Server Exception
    at de_InternalServerExceptionRes (/Users/zshzbh/Desktop/newProj/Issues6000s/node_modules/@aws-sdk/client-bedrock-agent-runtime/dist-cjs/index.js:2732:21)
    at de_CommandError (/Users/zshzbh/Desktop/newProj/Issues6000s/node_modules/@aws-sdk/client-bedrock-agent-runtime/dist-cjs/index.js:2645:19)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async /Users/zshzbh/Desktop/newProj/Issues6000s/node_modules/@aws-sdk/client-bedrock-agent-runtime/node_modules/@smithy/middleware-serde/dist-cjs/index.js:35:20
    at async /Users/zshzbh/Desktop/newProj/Issues6000s/node_modules/@aws-sdk/client-bedrock-agent-runtime/node_modules/@smithy/core/dist-cjs/index.js:167:18
    at async /Users/zshzbh/Desktop/newProj/Issues6000s/node_modules/@aws-sdk/client-bedrock-agent-runtime/node_modules/@smithy/middleware-retry/dist-cjs/index.js:321:38
    at async /Users/zshzbh/Desktop/newProj/Issues6000s/node_modules/@aws-sdk/client-bedrock-agent-runtime/node_modules/@aws-sdk/middleware-logger/dist-cjs/index.js:33:22
    at async file:///Users/zshzbh/Desktop/newProj/Issues6000s/6772/index.mjs:5:13 {
  '$fault': 'server',
  '$metadata': {
    httpStatusCode: 500,
    requestId: '9871240b-56d3-4a3f-9d6e-4a034610c802',
    extendedRequestId: undefined,
    cfId: undefined,
    attempts: 3,
    totalRetryDelay: 140
  }
}

Node.js v20.18.0

I will forward this issue to the team.

Thanks for the feedback!

zshzbh

zshzbh commented on Jan 7, 2025

@zshzbh
Contributor

Root cause - This is the interface of ParameterDetail , required is optional in AWS SDK but is required in the runtime.

In service doc - it's also marked as optional. I will contact service team to follow up this issue.

self-assigned this
on Jan 7, 2025
added
p2This is a standard priority issue
service-apiThis issue is due to a problem in a service API, not the SDK implementation.
and removed
needs-triageThis issue or PR still needs to be triaged.
on Jan 7, 2025
zshzbh

zshzbh commented on May 7, 2025

@zshzbh
Contributor

Hey @maximelebastard ,

The fix has been deployed, I'm closing this issue. :) Please let me know if you have any other issues. Thanks for the feedback! Hope you have a nice one!

github-actions

github-actions commented on May 7, 2025

@github-actions

This issue is now closed. Comments on closed issues are hard for our team to see.
If you need more assistance, please open a new issue that references this one.

github-actions

github-actions commented on May 22, 2025

@github-actions

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in this thread.

locked as resolved and limited conversation to collaborators on May 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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

      Participants

      @maximelebastard@zshzbh

      Issue actions

        Bedrock InvokeInlineAgentCommand triggers server error if action groups parameters required attribute is not set · Issue #6772 · aws/aws-sdk-js-v3