Enhance agent's accuracy using advanced prompt templates in Amazon Bedrock
After creation, an agent is configured with the following four default base prompt templates, which outline how the agent constructs prompts to send to the foundation model at each step of the agent sequence. For details about what each step encompasses, see Runtime process.
-
Pre-processing
-
Orchestration
-
Knowledge base response generation
-
Post-processing (disabled by default)
Prompt templates define how the agent does the following:
-
Processes user input text and output prompts from foundation models (FMs)
-
Orchestrates between the FM, action groups, and knowledge bases
-
Formats and returns responses to the user
By using advanced prompts, you can enhance your agent's accuracy through modifying these prompt templates to provide detailed configurations. You can also provide hand-curated examples for few-shot prompting, in which you improve model performance by providing labeled examples for a specific task.
Select a topic to learn more about advanced prompts.
Topics
Advanced prompts terminology
The following terminology is helpful in understanding how advanced prompts work.
-
Session – A group of InvokeAgent requests made to the same agent with the same session ID. When you make an
InvokeAgent
request, you can reuse asessionId
that was returned from the response of a previous call in order to continue the same session with an agent. As long as theidleSessionTTLInSeconds
time in the Agent configuration hasn't expired, you maintain the same session with the agent. -
Turn – A single
InvokeAgent
call. A session consists of one or more turns. -
Iteration – A sequence of the following actions:
-
(Required) A call to the foundation model
-
(Optional) An action group invocation
-
(Optional) A knowledge base invocation
-
(Optional) A response to the user asking for more information
An action might be skipped, depending on the configuration of the agent or the agent's requirement at that moment. A turn consists of one or more iterations.
-
-
Prompt – A prompt consists of the instructions to the agent, context, and text input. The text input can come from a user or from the output of another step in the agent sequence. The prompt is provided to the foundation model to determine the next step that the agent takes in responding to user input
-
Base prompt template – The structural elements that make up a prompt. The template consists of placeholders that are filled in with user input, the agent configuration, and context at runtime to create a prompt for the foundation model to process when the agent reaches that step. For more information about these placeholders, see Use placeholder variables in Amazon Bedrock agent prompt templates). With advanced prompts, you can edit these templates.