After you create an agent, you will have a working draft. The working draft is a version of the agent that you can use to iteratively build the agent. Each time you make changes to your agent, the working draft is updated. When you're satisfied with your agent's configurations, you can create a version, which is a snapshot of your agent, and an alias, which points to the version. You can then deploy your agent to your applications by calling the alias. For more information, see Deploy and use an Amazon Bedrock agent in your application.
The following list describes how you test your agent:
-
In the Amazon Bedrock console, you open up the test window on the side and send input for your agent to respond to. You can select the working draft or a version that you've created.
-
In the API, the working draft is the
DRAFT
version. You send input to your agent by using InvokeAgent with the test alias,TSTALIASID
, or a different alias pointing to a static version.
Streaming response
The response from InvokeAgent
call comes in one chunk. You can optionally enable streaming of the response. If streaming is enabled, the response contains multiple events with chunks for each part of the response in order. If your agent is configured with a guardrail, you can also control how often an ApplyGuardrail
call is made on outgoing response characters by specifying the character interval at which the guardrail will be applied when generating text response.
By default, the guardrail interval is set to 50 characters. If a larger interval is specified, the response will be generated in larger chunks with fewer ApplyGuardrail
calls. The following examples show the response generated for Hello, I am an agent input string.
Example response in chunks: Interval set to 3 characters
'Hel', 'lo, ','I am', ' an', ' Age', 'nt'
Each chunk has at least 3 characters except for the last chunk.
Example response in chunks: Interval set to 20 or more characters
Hello, I am an Agent
Tracing agent behavior
To help troubleshoot your agent's behavior, Amazon Bedrock Agents provides the ability to view the trace during a session with your agent. The trace shows the agent's step-by-step reasoning process. For more information about the trace, see Track agent's step-by-step reasoning process using trace.
Test your agent
Following are steps for testing your agent. Choose the tab for your preferred method, and then follow the steps:
To test an agent
-
Sign in to the AWS Management Console using an IAM role with Amazon Bedrock permissions, and open the Amazon Bedrock console at https://console.aws.amazon.com/bedrock/
. -
Select Agents from the left navigation pane. Then, choose an agent in the Agents section.
-
In the Agents section, select the link for the agent that you want to test from the list of agents.
-
The Test window appears in a pane on the right.
Note
If the Test window is closed, you can reopen it by selecting Test at the top of the agent details page or any page within it.
-
After you create an agent, you must package it with the working draft changes by preparing it in one of the following ways:
-
In the Test window, select Prepare.
-
In the Working draft page, select Prepare at the top of the page.
Note
Every time you update the working draft, you must prepare the agent to package the agent with your latest changes. As a best practice, we recommend that you always check your agent's Last prepared time in the Agent overview section of the Working draft page to verify that you're testing your agent with the latest configurations.
-
-
To choose an alias and associated version to test, use the dropdown menu at the top of the Test window. By default, the TestAlias: Working draft combination is selected.
-
(Optional) To select Provisioned Throughput for your alias, the text below the test alias you selected will indicate Using ODT or Using PT. To create a Provisioned Throughput model, select Change. For more information, see Increase model invocation capacity with Provisioned Throughput in Amazon Bedrock.
-
(Optional) To use a prompt from Prompt management, select the options icon (
) in the message box and choose Import prompt. Select the prompt and version. Enter values for the prompt variables in the Test variable values section. For more information about prompts in Prompt management, see Construct and store reusable prompts with Prompt management in Amazon Bedrock.
-
To test the agent, enter a message and choose Run. While you wait for the response to generate or after it is generated, you have the following options:
-
To view details for each step of the agent's orchestration process, including the prompt, inference configurations, and agent's reasoning process for each step and usage of its action groups and knowledge bases, select Show trace. The trace is updated in real-time so you can view it before the response is returned. To expand or collapse the trace for a step, select an arrow next to a step. For more information about the Trace window and details that appear, see Track agent's step-by-step reasoning process using trace.
-
If the agent invokes a knowledge base, the response contains footnotes. To view the link to the S3 object containing the cited information for a specific part of the response, select the relevant footnote.
-
If you set your agent to return control rather than using a Lambda function to handle the action group, the response contains the predicted action and its parameters. Provide an example output value from the API or function for the action and then choose Submit to generate an agent response. See the following image for an example:
You can perform the following actions in the Test window:
-
To start a new conversation with the agent, select the refresh icon.
-
To view the Trace window, select the expand icon. To close the Trace window, select the shrink icon.
-
To close the Test window, select the right arrow icon.
-
You can enable or disable action groups and knowledge bases. Use this feature to troubleshoot your agent by isolating which action groups or knowledge bases need to be updated by assessing its behavior with different settings.
To enable an action group or knowledge base
-
Sign in to the AWS Management Console using an IAM role with Amazon Bedrock permissions, and open the Amazon Bedrock console at https://console.aws.amazon.com/bedrock/
. -
Select Agents from the left navigation pane. Then, choose an agent in the Agents section.
-
In the Agents section. select the link for the agent that you want to test from the list of agents.
-
On the agent's details page, in the Working draft section, select the link for the Working draft.
-
In the Action groups or Knowledge bases section, hover over the State of the action group or knowledge base whose state you want to change.
-
An edit button appears. Select the edit icon and then choose from the dropdown menu whether the action group or knowledge base is Enabled or Disabled.
-
If an action group is Disabled, the agent doesn't use the action group. If a knowledge base is Disabled, the agent doesn't use the knowledge base. Enable or disable action groups or knowledge bases and then use the Test window to troubleshoot your agent.
-
Choose Prepare to apply the changes that you have made to the agent before testing it.