Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
3 of 4 tasks
maximelebastard opened this issue Jan 2, 2025 · 2 comments
Assignees
Labels
bug This issue is a bug. p2 This is a standard priority issue service-api This issue is due to a problem in a service API, not the SDK implementation.

Comments

@maximelebastard
Copy link

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

@maximelebastard maximelebastard added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Jan 2, 2025
@zshzbh
Copy link
Contributor

zshzbh commented Jan 7, 2025

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
Copy link
Contributor

zshzbh commented Jan 7, 2025

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.

@zshzbh zshzbh self-assigned this Jan 7, 2025
@zshzbh zshzbh added p2 This is a standard priority issue service-api This issue is due to a problem in a service API, not the SDK implementation. and removed needs-triage This issue or PR still needs to be triaged. labels Jan 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug. p2 This is a standard priority issue service-api This issue is due to a problem in a service API, not the SDK implementation.
Projects
None yet
Development

No branches or pull requests

2 participants