Foundation Model Integration, Data Management, and Compliance · Topic 8 of 9

Prompt Instructions, Conversation Context and Governance

Control FM behavior with Bedrock Prompt Management and Guardrails, keep chat context in DynamoDB, and govern prompts with versions and CloudTrail.

  • 5 min
In a nutshell
  • Prompt Management: templates with {{variables}}, variants, immutable versions, referenced by ARN.
  • Bedrock Guardrails: content filters, denied topics, word filters, sensitive information filters, contextual grounding, Automated Reasoning checks.
  • ApplyGuardrail checks any text, even for models outside Bedrock.

What it is

A prompt is code for an FM. It defines the model's role, rules and output format, and it changes behavior just as much as a code change. Prompts scattered as strings across applications cannot be reviewed, versioned or audited.

This page covers three linked ideas: instruction frameworks that make the model behave, interactive systems that remember context across turns, and governance that controls who changes prompts and records how they are used.

Prompt templatePrompt Managementfills variablesRequestrole, rules, contextchecked byBedrock GuardrailspolicyinvokesFMlogged toCloudWatch Logsaudit

How it works

Model instruction frameworks

Amazon Bedrock Prompt Management stores prompts as managed resources. A prompt holds the instructions, variables written in double braces such as {{customer_name}}, the chosen model and inference settings.

  • Role definitions live in the system prompt, such as "You are a support agent for product X. Answer only from the provided context."
  • Template configurations fix the response format, such as a required JSON shape, headings or a length limit.
  • Variants let you compare alternative wordings or models for the same prompt.
  • Versions are immutable snapshots that applications reference, so a draft edit never changes production.

Applications can reference a prompt version by its ARN in the Converse or InvokeModel call and pass values for the variables, so the template text never appears in code.

Amazon Bedrock Guardrails enforce responsible AI rules that prompt wording alone cannot guarantee.

Guardrail policyWhat it does
Content filtersBlock harmful categories and prompt attacks at configurable strengths
Denied topicsRefuse topics you define, such as investment advice
Word filtersBlock specific words or phrases, including profanity
Sensitive information filtersBlock or mask PII and custom regex patterns
Contextual grounding checkFlag responses not grounded in the source or not relevant to the query
Automated Reasoning checksValidate responses against formal rules you define

A guardrail is applied by ID and version on model calls, or to any text through the ApplyGuardrail API, which also works for models outside Bedrock.

Exam tip

"The model must never discuss topic X, even if the user insists" is a guardrail denied topic, not a stronger sentence in the system prompt. Instructions can be overridden; guardrails are enforced outside the model.

Interactive systems that keep context

FMs are stateless. Every turn must carry the context the model needs.

User turnclassify intentAmazon Comprehendcustom classifierload historyDynamoDBsession tablebuild promptFMsave turnDynamoDBsession table

Amazon DynamoDB for conversation history. Use the session ID as the partition key and a timestamp as the sort key. A time to live (TTL) attribute expires old sessions automatically. Long histories should be trimmed or summarized to fit the context window.

Amazon Comprehend for intent recognition. A custom classification model labels each message with an intent, such as billing or cancel. The app routes to the right prompt, knowledge base or workflow, and can detect PII before storing history.

AWS Step Functions for clarification workflows. When a request is ambiguous, the workflow asks a follow up question and pauses. With the wait for task token pattern, the execution waits until the user's answer arrives, then continues with complete information.

Amazon Bedrock AgentCore Memory is the managed option when agents need short term and long term memory without building the store yourself.

NeedUse
Durable chat history per sessionDynamoDB with TTL
Route by what the user wantsComprehend custom classification
Ask follow up questions mid workflowStep Functions with a task token
Managed memory for agentsAgentCore Memory

Prompt management and governance

Governance means consistent prompts, controlled changes and a record of use.

  1. Parameterized templates in Prompt Management keep one approved prompt with variables, instead of many hand edited copies.
  2. Approval workflows build on versions: authors edit the draft, and only reviewers with IAM permission to create prompt versions can publish one for production use. A CI/CD pipeline with a manual approval step can add a formal sign off.
  3. Amazon S3 template repositories store prompt templates as files with S3 Versioning, useful for review in pull requests and as a backup source of truth.
  4. AWS CloudTrail records Bedrock API calls, such as who created, changed or retrieved a prompt and who invoked a model.
  5. Amazon CloudWatch Logs receives model invocation logs, recording request and response content for auditing.
Authoredits draftsubmitsReviewertests variantapprovesPrompt versionimmutableused byApplicationsrecorded byCloudTrail and CloudWatch Logs

How the exam asks about this

  • "Many apps share a support prompt and changes must be reviewed before release" -> Prompt Management versions with an approval step, referenced by ARN.
  • "Mask customer phone numbers in responses" -> Bedrock Guardrails sensitive information filter.
  • "Who changed the production prompt last week?" -> AWS CloudTrail.
  • "Chatbot forgets earlier answers in the session" -> Store and reload history in DynamoDB keyed by session ID.

Common mistakes

Relying on the system prompt for safety. Prompt injection can override instructions. Add Bedrock Guardrails.

Pointing production at the draft prompt. Drafts change. Reference a numbered version.

Confusing CloudTrail with invocation logging. CloudTrail records API activity; model invocation logging captures prompt and response content.

Keeping full history forever in the prompt. Context windows and cost grow with every turn. Summarize or trim, and expire sessions with TTL.

Watch out

Conversation history and invocation logs can hold PII. Mask it with guardrails or Comprehend, and restrict access to the log groups.

What to remember for the exam

  • Prompt Management: templates with {{variables}}, variants, immutable versions, referenced by ARN.
  • Bedrock Guardrails: content filters, denied topics, word filters, sensitive information filters, contextual grounding, Automated Reasoning checks.
  • ApplyGuardrail checks any text, even for models outside Bedrock.
  • DynamoDB with session ID and TTL for history; Comprehend for intent; Step Functions task tokens for clarification.
  • CloudTrail for who did what; CloudWatch Logs for invocation content.

Check yourself

  • How do you stop an assistant from giving legal advice even when users try prompt tricks?

    Configure a Bedrock Guardrails denied topic for legal advice and apply the guardrail to every model call.

  • How can a workflow pause to ask the user a clarifying question?

    Use Step Functions with the wait for task token pattern, which resumes when the user's answer is returned.

  • Which service shows who modified a managed prompt?

    AWS CloudTrail, which records Amazon Bedrock API calls including prompt changes.

Topic 8 of 9 in Foundation Model Integration, Data Management, and Compliance

Test yourself on Foundation Model Integration, Data Management, and Compliance

The full AWS AIP-C01 question bank has 827 questions, with timed practice exams and an explanation for every answer.

This study guide is independent and is not affiliated with, endorsed by, or sponsored by AWS. Vendor names, certification names and exam codes are trademarks of their respective owners and are used for identification only.