# User authorized actions

Best practices for building experiences where AI needs user authorization to invoke tools, run commands, or carry out a consequential action during a session.

## Key UX concepts

### Match authorization to risk level

Present the level of friction appropriate to the action's potential impact. Routine tool calls and commands use a scope selector. A single consequential action uses an explicit approve or reject decision. Irreversible actions add a confirmation input.

### Reduce repeated friction

When an agent calls the same tool repeatedly, let users grant trust once so the agent can proceed without prompting again. Scope that trust to a single call, the current conversation, or all conversations.

### Communicate consequences

Before authorization, clearly communicate whether changes can be reversed, what happens if something goes wrong, and any long-term impacts of the change. This helps users decide how much trust to grant.

### Keep users in control

Always provide clear scoped access, full access or exit. If the user declines, make sure the agent acknowledges it.

### Record the outcome

An authorization request is a decision the user made, so its outcome belongs in the conversation. Leave a resolved state in the transcript showing what was decided and at what scope.

## Building blocks

A B C D E F G H I
#### A. Authorization dialog

Display a dialog above the prompt input to allow users to authorize tool or command calls when an AI invokes it.

#### B. Title

Describes what the agent wants to do. For example, use *Allow * *tool-name** ? * for tool authorization, use *Allow this command? * for command authorization.

#### C. Description - optional

A short explanation of what this tool or command does. Use regular body text. When builders need to provide additional context that is secondary for the user, show an expandable section below the description.

#### D. Command body  - optional

When a command is too long to fit in the title of the dialog, the complete command string appears in a code block underneath the title.

#### E. Expandable section - optional

When additional details are needed (such as parameters, metadata, or output), use an expandable section below the description. This keeps the dialog compact by default while allowing users to inspect details when needed.

#### F. Scope selector

A compact [Select](/components/select/index.html.md) component that determines how long the permission persists. Options vary by use case.

- **Allow this time:**   Grants permission for this single invocation only. The next time the agent calls the same tool or command, the authorization dialog appears again.
- **Allow for this chat: **   Grants permission for all subsequent invocations of the same tool or command within the current conversation. The agent runs the tool automatically without prompting again.
- **Always allow:**   Grants persistent permission for all future invocations of the same tool or command, across all conversations.

#### G. Action buttons

- **Cancel:**   Dismisses the dialog. Agent then acknowledges the dismissal in the conversation. For example: *Got it, skipping that step.*
- **Allow: **   Approves the action at the selected scope. dialog dismisses immediately.
- **Skip: **   Skip is used for bulk authorization. For example, when the agent needs authorization for multiple tools, it allows user to selectively deny individual tools while continuing to review the remaining ones.

#### H. Pagination - optional

Pagination is used for bulk tool authorization, for example, when the agent needs authorization for multiple tools, the dialog shows one tool at a time with pagination controls in the header. Users can navigate between tools, approve or skip each one individually.

#### I. Close button

Always present in the top-right corner of the dialog. Dismisses the entire authorization flow. The close button is always visible regardless of use case to maintain consistency.

## Common use cases

## Tool authorization

Use when an agent needs to invoke a tool (MCP server, API integration) during a workflow. The user sees the tool name and decides whether to allow it. When the user first invokes the tool, the authorization dialog appears with the tool name. The user selects a permission scope and approves or cancels. When the same tool is invoked subsequently in the current session, and if the user previously selected "Allow for this chat", the tool runs automatically. Display an inline confirmation in the conversation. For example, if the MCP is involved during the [thinking](/gen-ai/patterns/thinking/index.html.md) stages of the agent, display a step stating the tool name and requisite details.

## Single tool authorization

#### Single tool authorization

The agent requests permission to invoke a certain tool. The title shows the tool name in inline code format.

JD Which pull requests are still open on the pipeline repository? Finding open pull requests [1/3]
1. Located the pipeline repository
2. Requesting authorization for `list_pull_requests`
3. Read the open pull requests

Allow `list_pull_requests` ? Reads the open pull requests on aws/pipeline-tooling. This tool only reads, so nothing in the repository changes.

Request details| `{
` |
| `  "server": "source-control-mcp",
` |
| `  "tool": "list_pull_requests",
` |
| `  "arguments": {
` |
| `    "repository": "aws/pipeline-tooling",
` |
| `    "state": "open"
` |
| `  }
` |
| `}` |

Allow this time Permission scope Cancel Allow Use of this service is subject to the [AWS Responsible AI Policy](https://aws.amazon.com/machine-learning/responsible-ai/policy/)
```user-authorized-actions-tool.tsx
import React, { useState } from 'react';
import Box from '@cloudscape-design/components/box';
import Button from '@cloudscape-design/components/button';
import ChatBubble from '@cloudscape-design/chat-components/chat-bubble';
import { CodeView } from '@cloudscape-design/code-view';
import jsonHighlight from '@cloudscape-design/code-view/highlight/json';
import Container from '@cloudscape-design/components/container';
import Dialog from '@cloudscape-design/components/dialog';
import ExpandableSection from '@cloudscape-design/components/expandable-section';
import Select, { SelectProps } from '@cloudscape-design/components/select';
import SpaceBetween from '@cloudscape-design/components/space-between';
import Steps from '@cloudscape-design/components/steps';
import PromptInput from '@cloudscape-design/components/prompt-input';
import ButtonGroup from '@cloudscape-design/components/button-group';
import Link from '@cloudscape-design/components/link';
import { IconProps } from '@cloudscape-design/components/icon';
import Avatar from '@cloudscape-design/chat-components/avatar';

const CustomGenAIChatFooter = ({
  actionButtonIconName,
  actionButtonAriaLabel,
  message,
  onSendMessage,
  onAction,
}: {
  actionButtonIconName: IconProps.Name;
  actionButtonAriaLabel: string;
  message?: string;
  onSendMessage?: (text: string) => void;
  onAction?: (text: string) => void;
}) => {
  return (
    <SpaceBetween size="xs">
      <PromptInput
        value={message ?? ''}
        onChange={({ detail }) => onSendMessage?.(detail.value)}
        onAction={({ detail }) => onAction?.(detail.value)}
        disableSecondaryActionsPaddings
        actionButtonAriaLabel={actionButtonAriaLabel}
        actionButtonIconName={actionButtonIconName}
        secondaryActions={
          <Box padding={{ left: 'xxs', top: 'xs' }}>
            <ButtonGroup
              ariaLabel="Additional chat input actions"
              items={[
                {
                  type: 'icon-button',
                  id: 'upload-files',
                  iconName: 'upload',
                  text: 'Upload files',
                },
                {
                  type: 'icon-button',
                  id: 'add-reference',
                  iconName: 'at-symbol',
                  text: 'Add reference or citation',
                },
              ]}
              variant="icon"
            />
          </Box>
        }
      />
      <Box fontSize="body-s" color="text-body-secondary">
        Use of this service is subject to the{' '}
        <Link external variant="primary" href="https://aws.amazon.com/machine-learning/responsible-ai/policy/">
          AWS Responsible AI Policy
        </Link>
      </Box>
    </SpaceBetween>
  );
};

const userName = 'John Doe';
const genAiName = 'AI assistant';
const genAiAvatarAriaLabel = 'Avatar of AI assistant';

const userAvatar = <Avatar ariaLabel={`Avatar of ${userName}`} initials="JD" tooltipText={userName} />;

const genAiAvatar = (
  <Avatar ariaLabel={genAiAvatarAriaLabel} color="gen-ai" iconName="gen-ai" tooltipText={genAiName} />
);

const scopeOptions: SelectProps.Option[] = [
  { label: 'Allow this time', value: 'once' },
  { label: 'Allow for this chat', value: 'chat' },
  { label: 'Always allow', value: 'always' },
];

const request = `{
  "server": "source-control-mcp",
  "tool": "list_pull_requests",
  "arguments": {
    "repository": "aws/pipeline-tooling",
    "state": "open"
  }
}`;

export default function UserAuthorizedActionsToolAuthorization() {
  const [scope, setScope] = useState<SelectProps.Option>(scopeOptions[0]);
  const [showDialog, setShowDialog] = useState(true);

  return (
    <Container
      footer={
        <SpaceBetween size="xs">
          {showDialog && (
            <Dialog
              header={
                <>
                  Allow <Box variant="awsui-inline-code">list_pull_requests</Box>?
                </>
              }
              onDismiss={() => setShowDialog(false)}
              i18nStrings={{ dismissAriaLabel: 'Close dialog' }}
              footer={
                <>
                  <Box float="left">
                    <Select
                      selectedOption={scope}
                      onChange={({ detail }) => setScope(detail.selectedOption)}
                      options={scopeOptions}
                      ariaLabel="Permission scope"
                    />
                  </Box>
                  <Box float="right">
                    <SpaceBetween direction="horizontal" size="xs">
                      <Button variant="link">Cancel</Button>
                      <Button variant="primary">Allow</Button>
                    </SpaceBetween>
                  </Box>
                </>
              }
            >
              <SpaceBetween size="m">
                <Box variant="p">
                  Reads the open pull requests on aws/pipeline-tooling. This tool only reads, so nothing in the
                  repository changes.
                </Box>
                <ExpandableSection headerText={<Box fontSize="body-m">Request details</Box>}>
                  <CodeView content={request} highlight={jsonHighlight} ariaLabel="Tool request" wrapLines={true} />
                </ExpandableSection>
              </SpaceBetween>
            </Dialog>
          )}
          <CustomGenAIChatFooter actionButtonIconName="send" actionButtonAriaLabel="Send message" />
        </SpaceBetween>
      }
    >
      <SpaceBetween size="xs">
        <ChatBubble avatar={userAvatar} type="outgoing" ariaLabel={`${userName} at 05:37:30pm`}>
          Which pull requests are still open on the pipeline repository?
        </ChatBubble>
        <ChatBubble avatar={genAiAvatar} type="incoming" ariaLabel={`${genAiName} at 05:37:35pm`}>
          <ExpandableSection headerText="Finding open pull requests [1/3]" defaultExpanded={true}>
            <Steps
              ariaLabel="Pull request lookup progress"
              steps={[
                { status: 'success', statusIconAriaLabel: 'Success', header: 'Located the pipeline repository' },
                {
                  status: 'in-progress',
                  statusIconAriaLabel: 'In progress',
                  header: (
                    <>
                      Requesting authorization for <Box variant="awsui-inline-code">list_pull_requests</Box>
                    </>
                  ),
                },
                { status: 'pending', statusIconAriaLabel: 'Pending', header: 'Read the open pull requests' },
              ]}
            />
          </ExpandableSection>
        </ChatBubble>
      </SpaceBetween>
    </Container>
  );
}
```

## Bulk authorization (multiple tools)

#### Bulk authorization (multiple tools)

The agent needs to run several tools. Instead of grouping them into a single approval, the dialog shows one tool at a time with pagination. The user can Allow or Skip each tool individually, selecting different scope settings per tool if desired.

JD Right-size the node groups on my development clusters To do that I need to call three tools. Review each one and allow the ones you want me to use. Allow `list_clusters` ?
- 1 of 3

Reads the EKS clusters in the account. This tool only reads, so nothing changes.

Allow this time Permission scope Skip Allow Use of this service is subject to the [AWS Responsible AI Policy](https://aws.amazon.com/machine-learning/responsible-ai/policy/)
```user-authorized-actions-bulk.tsx
import React, { useState } from 'react';
import Box from '@cloudscape-design/components/box';
import Button from '@cloudscape-design/components/button';
import ChatBubble from '@cloudscape-design/chat-components/chat-bubble';
import Container from '@cloudscape-design/components/container';
import Dialog from '@cloudscape-design/components/dialog';
import Pagination from '@cloudscape-design/components/pagination';
import Select, { SelectProps } from '@cloudscape-design/components/select';
import SpaceBetween from '@cloudscape-design/components/space-between';
import PromptInput from '@cloudscape-design/components/prompt-input';
import ButtonGroup from '@cloudscape-design/components/button-group';
import Link from '@cloudscape-design/components/link';
import { IconProps } from '@cloudscape-design/components/icon';
import Avatar from '@cloudscape-design/chat-components/avatar';

const CustomGenAIChatFooter = ({
  actionButtonIconName,
  actionButtonAriaLabel,
  message,
  onSendMessage,
  onAction,
}: {
  actionButtonIconName: IconProps.Name;
  actionButtonAriaLabel: string;
  message?: string;
  onSendMessage?: (text: string) => void;
  onAction?: (text: string) => void;
}) => {
  return (
    <SpaceBetween size="xs">
      <PromptInput
        value={message ?? ''}
        onChange={({ detail }) => onSendMessage?.(detail.value)}
        onAction={({ detail }) => onAction?.(detail.value)}
        disableSecondaryActionsPaddings
        actionButtonAriaLabel={actionButtonAriaLabel}
        actionButtonIconName={actionButtonIconName}
        secondaryActions={
          <Box padding={{ left: 'xxs', top: 'xs' }}>
            <ButtonGroup
              ariaLabel="Additional chat input actions"
              items={[
                {
                  type: 'icon-button',
                  id: 'upload-files',
                  iconName: 'upload',
                  text: 'Upload files',
                },
                {
                  type: 'icon-button',
                  id: 'add-reference',
                  iconName: 'at-symbol',
                  text: 'Add reference or citation',
                },
              ]}
              variant="icon"
            />
          </Box>
        }
      />
      <Box fontSize="body-s" color="text-body-secondary">
        Use of this service is subject to the{' '}
        <Link external variant="primary" href="https://aws.amazon.com/machine-learning/responsible-ai/policy/">
          AWS Responsible AI Policy
        </Link>
      </Box>
    </SpaceBetween>
  );
};

const userName = 'John Doe';
const genAiName = 'AI assistant';
const genAiAvatarAriaLabel = 'Avatar of AI assistant';

const userAvatar = <Avatar ariaLabel={`Avatar of ${userName}`} initials="JD" tooltipText={userName} />;

const genAiAvatar = (
  <Avatar ariaLabel={genAiAvatarAriaLabel} color="gen-ai" iconName="gen-ai" tooltipText={genAiName} />
);

const scopeOptions: SelectProps.Option[] = [
  { label: 'Allow this time', value: 'once' },
  { label: 'Allow for this chat', value: 'chat' },
  { label: 'Always allow', value: 'always' },
];

const tools = [
  {
    name: 'list_clusters',
    description: 'Reads the EKS clusters in the account. This tool only reads, so nothing changes.',
  },
  {
    name: 'describe_node_group',
    description: 'Reads the configuration of a node group, including its scaling limits.',
  },
  {
    name: 'update_node_group',
    description: 'Changes the scaling limits on a node group. The previous limits can be restored afterwards.',
  },
];

export default function UserAuthorizedActionsBulkAuthorization() {
  const [scopes, setScopes] = useState<Record<string, SelectProps.Option>>({});
  const [pageIndex, setPageIndex] = useState(1);
  const [showDialog, setShowDialog] = useState(true);
  const tool = tools[pageIndex - 1];
  const scope = scopes[tool.name] ?? scopeOptions[0];

  return (
    <Container
      footer={
        <SpaceBetween size="xs">
          {showDialog && (
            <Dialog
              header={
                <>
                  Allow <Box variant="awsui-inline-code">{tool.name}</Box>?
                </>
              }
              onDismiss={() => setShowDialog(false)}
              i18nStrings={{ dismissAriaLabel: 'Close dialog' }}
              headerActions={
                <Pagination
                  pagesVariant="compact"
                  currentPageIndex={pageIndex}
                  pagesCount={tools.length}
                  onChange={({ detail }) => setPageIndex(detail.currentPageIndex)}
                  i18nStrings={{
                    pagesCompactText: ({ currentPage, pagesCount }) => `${currentPage} of ${pagesCount}`,
                  }}
                  ariaLabels={{
                    nextPageLabel: 'Next tool',
                    previousPageLabel: 'Previous tool',
                    pageLabel: pageNumber => `Tool ${pageNumber} of ${tools.length}`,
                  }}
                />
              }
              footer={
                <>
                  <Box float="left">
                    <Select
                      selectedOption={scope}
                      onChange={({ detail }) => setScopes({ ...scopes, [tool.name]: detail.selectedOption })}
                      options={scopeOptions}
                      ariaLabel="Permission scope"
                    />
                  </Box>
                  <Box float="right">
                    <SpaceBetween direction="horizontal" size="xs">
                      <Button variant="link">Skip</Button>
                      <Button variant="primary">Allow</Button>
                    </SpaceBetween>
                  </Box>
                </>
              }
            >
              <Box variant="p">{tool.description}</Box>
            </Dialog>
          )}
          <CustomGenAIChatFooter actionButtonIconName="send" actionButtonAriaLabel="Send message" />
        </SpaceBetween>
      }
    >
      <SpaceBetween size="xs">
        <ChatBubble avatar={userAvatar} type="outgoing" ariaLabel={`${userName} at 05:37:30pm`}>
          Right-size the node groups on my development clusters
        </ChatBubble>
        <ChatBubble avatar={genAiAvatar} type="incoming" ariaLabel={`${genAiName} at 05:37:35pm`}>
          To do that I need to call three tools. Review each one and allow the ones you want me to use.
        </ChatBubble>
      </SpaceBetween>
    </Container>
  );
}
```

## CLI command authorization

Use when an agent needs to run a command such as a CLI command. Display the command in the authorization dialog so the user can verify what will be executed before approving. For short commands (under ~40 characters) display the command in the title. For long commands, use a generic title with the full command as a code block in the body of the dialog.

#### Short command

The command is brief enough to display in the title. A description explains what the command does.

JD Do the tests still pass after your change? I can run the test suite to check. Allow `npm test` ? Runs the unit test suite in the current package. No files are modified and nothing is published.

Allow this time Permission scope Cancel Allow Use of this service is subject to the [AWS Responsible AI Policy](https://aws.amazon.com/machine-learning/responsible-ai/policy/)
```user-authorized-actions-command-short.tsx
import React, { useState } from 'react';
import Box from '@cloudscape-design/components/box';
import Button from '@cloudscape-design/components/button';
import ChatBubble from '@cloudscape-design/chat-components/chat-bubble';
import Container from '@cloudscape-design/components/container';
import Dialog from '@cloudscape-design/components/dialog';
import Select, { SelectProps } from '@cloudscape-design/components/select';
import SpaceBetween from '@cloudscape-design/components/space-between';
import PromptInput from '@cloudscape-design/components/prompt-input';
import ButtonGroup from '@cloudscape-design/components/button-group';
import Link from '@cloudscape-design/components/link';
import { IconProps } from '@cloudscape-design/components/icon';
import Avatar from '@cloudscape-design/chat-components/avatar';

const CustomGenAIChatFooter = ({
  actionButtonIconName,
  actionButtonAriaLabel,
  message,
  onSendMessage,
  onAction,
}: {
  actionButtonIconName: IconProps.Name;
  actionButtonAriaLabel: string;
  message?: string;
  onSendMessage?: (text: string) => void;
  onAction?: (text: string) => void;
}) => {
  return (
    <SpaceBetween size="xs">
      <PromptInput
        value={message ?? ''}
        onChange={({ detail }) => onSendMessage?.(detail.value)}
        onAction={({ detail }) => onAction?.(detail.value)}
        disableSecondaryActionsPaddings
        actionButtonAriaLabel={actionButtonAriaLabel}
        actionButtonIconName={actionButtonIconName}
        secondaryActions={
          <Box padding={{ left: 'xxs', top: 'xs' }}>
            <ButtonGroup
              ariaLabel="Additional chat input actions"
              items={[
                {
                  type: 'icon-button',
                  id: 'upload-files',
                  iconName: 'upload',
                  text: 'Upload files',
                },
                {
                  type: 'icon-button',
                  id: 'add-reference',
                  iconName: 'at-symbol',
                  text: 'Add reference or citation',
                },
              ]}
              variant="icon"
            />
          </Box>
        }
      />
      <Box fontSize="body-s" color="text-body-secondary">
        Use of this service is subject to the{' '}
        <Link external variant="primary" href="https://aws.amazon.com/machine-learning/responsible-ai/policy/">
          AWS Responsible AI Policy
        </Link>
      </Box>
    </SpaceBetween>
  );
};

const userName = 'John Doe';
const genAiName = 'AI assistant';
const genAiAvatarAriaLabel = 'Avatar of AI assistant';

const userAvatar = <Avatar ariaLabel={`Avatar of ${userName}`} initials="JD" tooltipText={userName} />;

const genAiAvatar = (
  <Avatar ariaLabel={genAiAvatarAriaLabel} color="gen-ai" iconName="gen-ai" tooltipText={genAiName} />
);

const scopeOptions: SelectProps.Option[] = [
  { label: 'Allow this time', value: 'once' },
  { label: 'Allow for this chat', value: 'chat' },
  { label: 'Always allow', value: 'always' },
];

export default function UserAuthorizedActionsCommandShort() {
  const [scope, setScope] = useState<SelectProps.Option>(scopeOptions[0]);
  const [showDialog, setShowDialog] = useState(true);

  return (
    <Container
      footer={
        <SpaceBetween size="xs">
          {showDialog && (
            <Dialog
              header={
                <>
                  Allow <Box variant="awsui-inline-code">npm test</Box>?
                </>
              }
              onDismiss={() => setShowDialog(false)}
              i18nStrings={{ dismissAriaLabel: 'Close dialog' }}
              footer={
                <>
                  <Box float="left">
                    <Select
                      selectedOption={scope}
                      onChange={({ detail }) => setScope(detail.selectedOption)}
                      options={scopeOptions}
                      ariaLabel="Permission scope"
                    />
                  </Box>
                  <Box float="right">
                    <SpaceBetween direction="horizontal" size="xs">
                      <Button variant="link">Cancel</Button>
                      <Button variant="primary">Allow</Button>
                    </SpaceBetween>
                  </Box>
                </>
              }
            >
              <Box variant="p">
                Runs the unit test suite in the current package. No files are modified and nothing is published.
              </Box>
            </Dialog>
          )}
          <CustomGenAIChatFooter actionButtonIconName="send" actionButtonAriaLabel="Send message" />
        </SpaceBetween>
      }
    >
      <SpaceBetween size="xs">
        <ChatBubble avatar={userAvatar} type="outgoing" ariaLabel={`${userName} at 05:37:30pm`}>
          Do the tests still pass after your change?
        </ChatBubble>
        <ChatBubble avatar={genAiAvatar} type="incoming" ariaLabel={`${genAiName} at 05:37:35pm`}>
          I can run the test suite to check.
        </ChatBubble>
      </SpaceBetween>
    </Container>
  );
}
```

### Long command

The command is too long for the title. A generic title is used and the full command is displayed in a code block in the body. A description below explains what the command does.

JD Why is the checkout service throwing errors this morning? I can read the error entries from the function's log group to find out. Allow this command?| `aws logs filter-log-events --log-group-name /aws/lambda/checkout-service \<!-- -->
` |
| `  --start-time 1757000000000 --filter-pattern "ERROR" \<!-- -->
` |
| `  --query "events[*].[timestamp,message]" --output table` |

Reads error entries from the checkout service log group. Reading logs does not change the function or its configuration.

Allow this time Permission scope Cancel Allow Use of this service is subject to the [AWS Responsible AI Policy](https://aws.amazon.com/machine-learning/responsible-ai/policy/)
```user-authorized-actions-command-long.tsx
import React, { useState } from 'react';
import Box from '@cloudscape-design/components/box';
import Button from '@cloudscape-design/components/button';
import ChatBubble from '@cloudscape-design/chat-components/chat-bubble';
import { CodeView } from '@cloudscape-design/code-view';
import shHighlight from '@cloudscape-design/code-view/highlight/sh';
import Container from '@cloudscape-design/components/container';
import Dialog from '@cloudscape-design/components/dialog';
import Select, { SelectProps } from '@cloudscape-design/components/select';
import SpaceBetween from '@cloudscape-design/components/space-between';
import PromptInput from '@cloudscape-design/components/prompt-input';
import ButtonGroup from '@cloudscape-design/components/button-group';
import Link from '@cloudscape-design/components/link';
import { IconProps } from '@cloudscape-design/components/icon';
import Avatar from '@cloudscape-design/chat-components/avatar';

const CustomGenAIChatFooter = ({
  actionButtonIconName,
  actionButtonAriaLabel,
  message,
  onSendMessage,
  onAction,
}: {
  actionButtonIconName: IconProps.Name;
  actionButtonAriaLabel: string;
  message?: string;
  onSendMessage?: (text: string) => void;
  onAction?: (text: string) => void;
}) => {
  return (
    <SpaceBetween size="xs">
      <PromptInput
        value={message ?? ''}
        onChange={({ detail }) => onSendMessage?.(detail.value)}
        onAction={({ detail }) => onAction?.(detail.value)}
        disableSecondaryActionsPaddings
        actionButtonAriaLabel={actionButtonAriaLabel}
        actionButtonIconName={actionButtonIconName}
        secondaryActions={
          <Box padding={{ left: 'xxs', top: 'xs' }}>
            <ButtonGroup
              ariaLabel="Additional chat input actions"
              items={[
                {
                  type: 'icon-button',
                  id: 'upload-files',
                  iconName: 'upload',
                  text: 'Upload files',
                },
                {
                  type: 'icon-button',
                  id: 'add-reference',
                  iconName: 'at-symbol',
                  text: 'Add reference or citation',
                },
              ]}
              variant="icon"
            />
          </Box>
        }
      />
      <Box fontSize="body-s" color="text-body-secondary">
        Use of this service is subject to the{' '}
        <Link external variant="primary" href="https://aws.amazon.com/machine-learning/responsible-ai/policy/">
          AWS Responsible AI Policy
        </Link>
      </Box>
    </SpaceBetween>
  );
};

const userName = 'John Doe';
const genAiName = 'AI assistant';
const genAiAvatarAriaLabel = 'Avatar of AI assistant';

const userAvatar = <Avatar ariaLabel={`Avatar of ${userName}`} initials="JD" tooltipText={userName} />;

const genAiAvatar = (
  <Avatar ariaLabel={genAiAvatarAriaLabel} color="gen-ai" iconName="gen-ai" tooltipText={genAiName} />
);

const scopeOptions: SelectProps.Option[] = [
  { label: 'Allow this time', value: 'once' },
  { label: 'Allow for this chat', value: 'chat' },
  { label: 'Always allow', value: 'always' },
];

const command =
  'aws logs filter-log-events --log-group-name /aws/lambda/checkout-service \\\n  --start-time 1757000000000 --filter-pattern "ERROR" \\\n  --query "events[*].[timestamp,message]" --output table';

export default function UserAuthorizedActionsCommandLong() {
  const [scope, setScope] = useState<SelectProps.Option>(scopeOptions[0]);
  const [showDialog, setShowDialog] = useState(true);

  return (
    <Container
      footer={
        <SpaceBetween size="xs">
          {showDialog && (
            <Dialog
              header="Allow this command?"
              onDismiss={() => setShowDialog(false)}
              i18nStrings={{ dismissAriaLabel: 'Close dialog' }}
              footer={
                <>
                  <Box float="left">
                    <Select
                      selectedOption={scope}
                      onChange={({ detail }) => setScope(detail.selectedOption)}
                      options={scopeOptions}
                      ariaLabel="Permission scope"
                    />
                  </Box>
                  <Box float="right">
                    <SpaceBetween direction="horizontal" size="xs">
                      <Button variant="link">Cancel</Button>
                      <Button variant="primary">Allow</Button>
                    </SpaceBetween>
                  </Box>
                </>
              }
            >
              <SpaceBetween size="m">
                <CodeView content={command} highlight={shHighlight} ariaLabel="Command to run" wrapLines={true} />
                <Box variant="p">
                  Reads error entries from the checkout service log group. Reading logs does not change the function or
                  its configuration.
                </Box>
              </SpaceBetween>
            </Dialog>
          )}
          <CustomGenAIChatFooter actionButtonIconName="send" actionButtonAriaLabel="Send message" />
        </SpaceBetween>
      }
    >
      <SpaceBetween size="xs">
        <ChatBubble avatar={userAvatar} type="outgoing" ariaLabel={`${userName} at 05:37:30pm`}>
          Why is the checkout service throwing errors this morning?
        </ChatBubble>
        <ChatBubble avatar={genAiAvatar} type="incoming" ariaLabel={`${genAiName} at 05:37:35pm`}>
          I can read the error entries from the function&apos;s log group to find out.
        </ChatBubble>
      </SpaceBetween>
    </Container>
  );
}
```

## Short command

The command is brief enough to display in the title. A description explains what the command does.

JD Do the tests still pass after your change? I can run the test suite to check. Allow `npm test` ? Runs the unit test suite in the current package. No files are modified and nothing is published.

Allow this time Permission scope Cancel Allow Use of this service is subject to the [AWS Responsible AI Policy](https://aws.amazon.com/machine-learning/responsible-ai/policy/)
```user-authorized-actions-command-short.tsx
import React, { useState } from 'react';
import Box from '@cloudscape-design/components/box';
import Button from '@cloudscape-design/components/button';
import ChatBubble from '@cloudscape-design/chat-components/chat-bubble';
import Container from '@cloudscape-design/components/container';
import Dialog from '@cloudscape-design/components/dialog';
import Select, { SelectProps } from '@cloudscape-design/components/select';
import SpaceBetween from '@cloudscape-design/components/space-between';
import PromptInput from '@cloudscape-design/components/prompt-input';
import ButtonGroup from '@cloudscape-design/components/button-group';
import Link from '@cloudscape-design/components/link';
import { IconProps } from '@cloudscape-design/components/icon';
import Avatar from '@cloudscape-design/chat-components/avatar';

const CustomGenAIChatFooter = ({
  actionButtonIconName,
  actionButtonAriaLabel,
  message,
  onSendMessage,
  onAction,
}: {
  actionButtonIconName: IconProps.Name;
  actionButtonAriaLabel: string;
  message?: string;
  onSendMessage?: (text: string) => void;
  onAction?: (text: string) => void;
}) => {
  return (
    <SpaceBetween size="xs">
      <PromptInput
        value={message ?? ''}
        onChange={({ detail }) => onSendMessage?.(detail.value)}
        onAction={({ detail }) => onAction?.(detail.value)}
        disableSecondaryActionsPaddings
        actionButtonAriaLabel={actionButtonAriaLabel}
        actionButtonIconName={actionButtonIconName}
        secondaryActions={
          <Box padding={{ left: 'xxs', top: 'xs' }}>
            <ButtonGroup
              ariaLabel="Additional chat input actions"
              items={[
                {
                  type: 'icon-button',
                  id: 'upload-files',
                  iconName: 'upload',
                  text: 'Upload files',
                },
                {
                  type: 'icon-button',
                  id: 'add-reference',
                  iconName: 'at-symbol',
                  text: 'Add reference or citation',
                },
              ]}
              variant="icon"
            />
          </Box>
        }
      />
      <Box fontSize="body-s" color="text-body-secondary">
        Use of this service is subject to the{' '}
        <Link external variant="primary" href="https://aws.amazon.com/machine-learning/responsible-ai/policy/">
          AWS Responsible AI Policy
        </Link>
      </Box>
    </SpaceBetween>
  );
};

const userName = 'John Doe';
const genAiName = 'AI assistant';
const genAiAvatarAriaLabel = 'Avatar of AI assistant';

const userAvatar = <Avatar ariaLabel={`Avatar of ${userName}`} initials="JD" tooltipText={userName} />;

const genAiAvatar = (
  <Avatar ariaLabel={genAiAvatarAriaLabel} color="gen-ai" iconName="gen-ai" tooltipText={genAiName} />
);

const scopeOptions: SelectProps.Option[] = [
  { label: 'Allow this time', value: 'once' },
  { label: 'Allow for this chat', value: 'chat' },
  { label: 'Always allow', value: 'always' },
];

export default function UserAuthorizedActionsCommandShort() {
  const [scope, setScope] = useState<SelectProps.Option>(scopeOptions[0]);
  const [showDialog, setShowDialog] = useState(true);

  return (
    <Container
      footer={
        <SpaceBetween size="xs">
          {showDialog && (
            <Dialog
              header={
                <>
                  Allow <Box variant="awsui-inline-code">npm test</Box>?
                </>
              }
              onDismiss={() => setShowDialog(false)}
              i18nStrings={{ dismissAriaLabel: 'Close dialog' }}
              footer={
                <>
                  <Box float="left">
                    <Select
                      selectedOption={scope}
                      onChange={({ detail }) => setScope(detail.selectedOption)}
                      options={scopeOptions}
                      ariaLabel="Permission scope"
                    />
                  </Box>
                  <Box float="right">
                    <SpaceBetween direction="horizontal" size="xs">
                      <Button variant="link">Cancel</Button>
                      <Button variant="primary">Allow</Button>
                    </SpaceBetween>
                  </Box>
                </>
              }
            >
              <Box variant="p">
                Runs the unit test suite in the current package. No files are modified and nothing is published.
              </Box>
            </Dialog>
          )}
          <CustomGenAIChatFooter actionButtonIconName="send" actionButtonAriaLabel="Send message" />
        </SpaceBetween>
      }
    >
      <SpaceBetween size="xs">
        <ChatBubble avatar={userAvatar} type="outgoing" ariaLabel={`${userName} at 05:37:30pm`}>
          Do the tests still pass after your change?
        </ChatBubble>
        <ChatBubble avatar={genAiAvatar} type="incoming" ariaLabel={`${genAiName} at 05:37:35pm`}>
          I can run the test suite to check.
        </ChatBubble>
      </SpaceBetween>
    </Container>
  );
}
```

## Long command

The command is too long for the title. A generic title is used and the full command is displayed in a code block in the body. A description below explains what the command does.

JD Why is the checkout service throwing errors this morning? I can read the error entries from the function's log group to find out. Allow this command?| `aws logs filter-log-events --log-group-name /aws/lambda/checkout-service \
` |
| `  --start-time 1757000000000 --filter-pattern "ERROR" \
` |
| `  --query "events[*].[timestamp,message]" --output table` |

Reads error entries from the checkout service log group. Reading logs does not change the function or its configuration.

Allow this time Permission scope Cancel Allow Use of this service is subject to the [AWS Responsible AI Policy](https://aws.amazon.com/machine-learning/responsible-ai/policy/)
```user-authorized-actions-command-long.tsx
import React, { useState } from 'react';
import Box from '@cloudscape-design/components/box';
import Button from '@cloudscape-design/components/button';
import ChatBubble from '@cloudscape-design/chat-components/chat-bubble';
import { CodeView } from '@cloudscape-design/code-view';
import shHighlight from '@cloudscape-design/code-view/highlight/sh';
import Container from '@cloudscape-design/components/container';
import Dialog from '@cloudscape-design/components/dialog';
import Select, { SelectProps } from '@cloudscape-design/components/select';
import SpaceBetween from '@cloudscape-design/components/space-between';
import PromptInput from '@cloudscape-design/components/prompt-input';
import ButtonGroup from '@cloudscape-design/components/button-group';
import Link from '@cloudscape-design/components/link';
import { IconProps } from '@cloudscape-design/components/icon';
import Avatar from '@cloudscape-design/chat-components/avatar';

const CustomGenAIChatFooter = ({
  actionButtonIconName,
  actionButtonAriaLabel,
  message,
  onSendMessage,
  onAction,
}: {
  actionButtonIconName: IconProps.Name;
  actionButtonAriaLabel: string;
  message?: string;
  onSendMessage?: (text: string) => void;
  onAction?: (text: string) => void;
}) => {
  return (
    <SpaceBetween size="xs">
      <PromptInput
        value={message ?? ''}
        onChange={({ detail }) => onSendMessage?.(detail.value)}
        onAction={({ detail }) => onAction?.(detail.value)}
        disableSecondaryActionsPaddings
        actionButtonAriaLabel={actionButtonAriaLabel}
        actionButtonIconName={actionButtonIconName}
        secondaryActions={
          <Box padding={{ left: 'xxs', top: 'xs' }}>
            <ButtonGroup
              ariaLabel="Additional chat input actions"
              items={[
                {
                  type: 'icon-button',
                  id: 'upload-files',
                  iconName: 'upload',
                  text: 'Upload files',
                },
                {
                  type: 'icon-button',
                  id: 'add-reference',
                  iconName: 'at-symbol',
                  text: 'Add reference or citation',
                },
              ]}
              variant="icon"
            />
          </Box>
        }
      />
      <Box fontSize="body-s" color="text-body-secondary">
        Use of this service is subject to the{' '}
        <Link external variant="primary" href="https://aws.amazon.com/machine-learning/responsible-ai/policy/">
          AWS Responsible AI Policy
        </Link>
      </Box>
    </SpaceBetween>
  );
};

const userName = 'John Doe';
const genAiName = 'AI assistant';
const genAiAvatarAriaLabel = 'Avatar of AI assistant';

const userAvatar = <Avatar ariaLabel={`Avatar of ${userName}`} initials="JD" tooltipText={userName} />;

const genAiAvatar = (
  <Avatar ariaLabel={genAiAvatarAriaLabel} color="gen-ai" iconName="gen-ai" tooltipText={genAiName} />
);

const scopeOptions: SelectProps.Option[] = [
  { label: 'Allow this time', value: 'once' },
  { label: 'Allow for this chat', value: 'chat' },
  { label: 'Always allow', value: 'always' },
];

const command =
  'aws logs filter-log-events --log-group-name /aws/lambda/checkout-service \\\n  --start-time 1757000000000 --filter-pattern "ERROR" \\\n  --query "events[*].[timestamp,message]" --output table';

export default function UserAuthorizedActionsCommandLong() {
  const [scope, setScope] = useState<SelectProps.Option>(scopeOptions[0]);
  const [showDialog, setShowDialog] = useState(true);

  return (
    <Container
      footer={
        <SpaceBetween size="xs">
          {showDialog && (
            <Dialog
              header="Allow this command?"
              onDismiss={() => setShowDialog(false)}
              i18nStrings={{ dismissAriaLabel: 'Close dialog' }}
              footer={
                <>
                  <Box float="left">
                    <Select
                      selectedOption={scope}
                      onChange={({ detail }) => setScope(detail.selectedOption)}
                      options={scopeOptions}
                      ariaLabel="Permission scope"
                    />
                  </Box>
                  <Box float="right">
                    <SpaceBetween direction="horizontal" size="xs">
                      <Button variant="link">Cancel</Button>
                      <Button variant="primary">Allow</Button>
                    </SpaceBetween>
                  </Box>
                </>
              }
            >
              <SpaceBetween size="m">
                <CodeView content={command} highlight={shHighlight} ariaLabel="Command to run" wrapLines={true} />
                <Box variant="p">
                  Reads error entries from the checkout service log group. Reading logs does not change the function or
                  its configuration.
                </Box>
              </SpaceBetween>
            </Dialog>
          )}
          <CustomGenAIChatFooter actionButtonIconName="send" actionButtonAriaLabel="Send message" />
        </SpaceBetween>
      }
    >
      <SpaceBetween size="xs">
        <ChatBubble avatar={userAvatar} type="outgoing" ariaLabel={`${userName} at 05:37:30pm`}>
          Why is the checkout service throwing errors this morning?
        </ChatBubble>
        <ChatBubble avatar={genAiAvatar} type="incoming" ariaLabel={`${genAiName} at 05:37:35pm`}>
          I can read the error entries from the function&apos;s log group to find out.
        </ChatBubble>
      </SpaceBetween>
    </Container>
  );
}
```

## One-time authorization

Use when the agent needs authorization for a single action rather than for a tool it will call repeatedly. There is no future invocation for a scope to cover, so the scope selector is omitted and the buttons carry the whole decision. How much friction to add depends on the action's impact.

JD Ship the checkout service change once the tests are green The tests passed. The change is ready to go to production. Approve deployment to production? Production traffic moves to the new version over about 10 minutes. You can roll back to the current version for 24 hours.

Service checkout-service Version 2.1.0 Stage Production, us-east-1 Reject Approve Use of this service is subject to the [AWS Responsible AI Policy](https://aws.amazon.com/machine-learning/responsible-ai/policy/)
```user-authorized-actions-one-time-approve.tsx
import React, { useState } from 'react';
import Box from '@cloudscape-design/components/box';
import Button from '@cloudscape-design/components/button';
import ChatBubble from '@cloudscape-design/chat-components/chat-bubble';
import Container from '@cloudscape-design/components/container';
import Dialog from '@cloudscape-design/components/dialog';
import KeyValuePairs from '@cloudscape-design/components/key-value-pairs';
import SpaceBetween from '@cloudscape-design/components/space-between';
import PromptInput from '@cloudscape-design/components/prompt-input';
import ButtonGroup from '@cloudscape-design/components/button-group';
import Link from '@cloudscape-design/components/link';
import { IconProps } from '@cloudscape-design/components/icon';
import Avatar from '@cloudscape-design/chat-components/avatar';

const CustomGenAIChatFooter = ({
  actionButtonIconName,
  actionButtonAriaLabel,
  message,
  onSendMessage,
  onAction,
}: {
  actionButtonIconName: IconProps.Name;
  actionButtonAriaLabel: string;
  message?: string;
  onSendMessage?: (text: string) => void;
  onAction?: (text: string) => void;
}) => {
  return (
    <SpaceBetween size="xs">
      <PromptInput
        value={message ?? ''}
        onChange={({ detail }) => onSendMessage?.(detail.value)}
        onAction={({ detail }) => onAction?.(detail.value)}
        disableSecondaryActionsPaddings
        actionButtonAriaLabel={actionButtonAriaLabel}
        actionButtonIconName={actionButtonIconName}
        secondaryActions={
          <Box padding={{ left: 'xxs', top: 'xs' }}>
            <ButtonGroup
              ariaLabel="Additional chat input actions"
              items={[
                {
                  type: 'icon-button',
                  id: 'upload-files',
                  iconName: 'upload',
                  text: 'Upload files',
                },
                {
                  type: 'icon-button',
                  id: 'add-reference',
                  iconName: 'at-symbol',
                  text: 'Add reference or citation',
                },
              ]}
              variant="icon"
            />
          </Box>
        }
      />
      <Box fontSize="body-s" color="text-body-secondary">
        Use of this service is subject to the{' '}
        <Link external variant="primary" href="https://aws.amazon.com/machine-learning/responsible-ai/policy/">
          AWS Responsible AI Policy
        </Link>
      </Box>
    </SpaceBetween>
  );
};

const userName = 'John Doe';
const genAiName = 'AI assistant';
const genAiAvatarAriaLabel = 'Avatar of AI assistant';

const userAvatar = <Avatar ariaLabel={`Avatar of ${userName}`} initials="JD" tooltipText={userName} />;

const genAiAvatar = (
  <Avatar ariaLabel={genAiAvatarAriaLabel} color="gen-ai" iconName="gen-ai" tooltipText={genAiName} />
);

export default function UserAuthorizedActionsOneTimeApprove() {
  const [showDialog, setShowDialog] = useState(true);

  return (
    <Container
      footer={
        <SpaceBetween size="xs">
          {showDialog && (
            <Dialog
              header="Approve deployment to production?"
              onDismiss={() => setShowDialog(false)}
              i18nStrings={{ dismissAriaLabel: 'Close dialog' }}
              footer={
                <Box float="right">
                  <SpaceBetween direction="horizontal" size="xs">
                    <Button variant="link">Reject</Button>
                    <Button variant="primary">Approve</Button>
                  </SpaceBetween>
                </Box>
              }
            >
              <SpaceBetween size="m">
                <Box variant="p">
                  Production traffic moves to the new version over about 10 minutes. You can roll back to the current
                  version for 24 hours.
                </Box>
                <KeyValuePairs
                  columns={3}
                  items={[
                    { label: 'Service', value: 'checkout-service' },
                    { label: 'Version', value: '2.1.0' },
                    { label: 'Stage', value: 'Production, us-east-1' },
                  ]}
                />
              </SpaceBetween>
            </Dialog>
          )}
          <CustomGenAIChatFooter actionButtonIconName="send" actionButtonAriaLabel="Send message" />
        </SpaceBetween>
      }
    >
      <SpaceBetween size="xs">
        <ChatBubble avatar={userAvatar} type="outgoing" ariaLabel={`${userName} at 05:37:30pm`}>
          Ship the checkout service change once the tests are green
        </ChatBubble>
        <ChatBubble avatar={genAiAvatar} type="incoming" ariaLabel={`${genAiName} at 05:37:35pm`}>
          The tests passed. The change is ready to go to production.
        </ChatBubble>
      </SpaceBetween>
    </Container>
  );
}
```

## Irreversible action

Use when the action can't be undone, such as deleting a database cluster that live services still resolve. Where the action names a single resource, the dialog includes a confirmation input. Where several resources are affected, a warning alert lists them. Use one form or the other, not both. After the action runs, the agent reports what was deleted, what was kept, and for how long.

JD Tear down the staging databases we stopped using I found three clusters with no connections in the last 30 days. Two of them still have services resolving to them. Allow deleting 3 database clusters? Permanently delete **staging-orders** , **staging-inventory** , and **staging-scratch** ? You can't undo this action.

Proceeding with this action deletes each cluster with its data and automated backups. Two of them still have services resolving to them, which can affect those services. [Learn more](about:blank/index.html.md) To avoid accidental deletions, we ask you to provide additional written consent.

To confirm this deletion, type "confirm". Cancel Delete Use of this service is subject to the [AWS Responsible AI Policy](https://aws.amazon.com/machine-learning/responsible-ai/policy/)
## General guidelines

### Do

- Show the tool or command name in `awsui-inline-code`   format to visually distinguish it from surrounding text.
- Dismiss the dialog immediately when the user selects Action buttons. Don't show a loading state or success indicator. "The resolved state belongs in the conversation, not in the dismissed dialog."
- Always show the close button on the authorization dialog.
- Show a description explaining what the tool or command does. This helps users who may not recognize the tool name.
- If the user cancels, have the agent acknowledge in the conversation. For example, *Got it, skipping that step.*
- When a request expires, show the expired resolved state and have the agent report that nothing ran.

### Don't

- Don't show the authorization dialog for a tool that is already trusted for the session. Instead, let the agent execute the tool automatically, and display a confirmation in chat or [thinking](/gen-ai/patterns/thinking/index.html.md)   trace.
- Don't show the scope selector if your system does not support persisting preferences.
- Don't pre-select or auto-focus the approve action for risky operations. A stray enter or click could confirm a consequential action the user didn't intend.
- Don't let a pending request block the UI indefinitely. If the user never responds, cancel and report rather than continuing silently.

## Writing guidelines

### General writing guidelines

- Use sentence case, but continue to capitalize proper nouns and brand names correctly in context.
- Use end punctuation, except in [headers](/components/header/index.html.md)   and [buttons](/components/button/index.html.md)   . Don't use exclamation points.
- Use present-tense verbs and active voice.
- Don't use *please*   , *thank you*   , ellipsis ( *...*   ), ampersand ( *&*   ), *e.g.*   , *i.e.*   , or *etc.*   in writing.
- Avoid directional language.  

  - For example: use *previous*     not *above*     , use *following*     not *below*    .
- Use device-independent language.  

  - For example: use *choose*     or *select*     not *click*    .

### Component-specific guidelines

#### Authorization dialog title

- Use the format: *Allow * *tool-or-command-name* *?*  

  - For example: *Allow * *npm test* *? *

#### Irreversible action title

- name the consequence rather than the verb pair. For example, *Your authorization is needed to delete objects in the S3 bucket*  .

#### One-time decision title:

- *Approve action? *   For example, *Approve deployment to production*

#### Resolved state labels

- past tense, no end punctuation - *Approved, Rejected, Approved automatically, Request expired*

#### Expiry message

- state what didn't happen. For example, *This request expired. Nothing was deployed.*

#### Scope selector options

- Allow this time, Allow for this chat, Always allow

## Accessibility guidelines

### General accessibility guidelines

- Follow the guidelines on alternative text and Accessible Rich Internet Applications (ARIA) regions for each component.
- Make sure to define ARIA labels aligned with the language context of your application.
- Don't add unnecessary markup for roles and landmarks. Follow the guidelines for each component.
- Provide keyboard functionality to all available content in a logical and predictable order. The flow of information should make sense.

### Component-specific guidelines

- When the dialog appears, focus moves to the dialog.
- When a confirmation input is present (critical action variant), Enter triggers form submission only after the confirmation phrase matches. The Allow button remains disabled until the input is validated.
- Focus returns to the chat input when the dialog is dismissed.
- The one-time decision card is not a dialog.  Don't give it a dialog role and don't trap focus in it, the conversation stays reachable while the request is pending.
- Don't set initial focus on the approve action. Move focus to the card's heading.
- Convey the resolved state with text, not color alone. The StatusIndicator label carries the disposition for assistive technology.
- Report an expiry as a message in the conversation, so it appears in reading order rather than only changing the appearance of the card.






## Search Cloudscape