opensite-ai/opensite-skills / amazon-bedrock
amazon-bedrock
FlaggedBuilds generative AI applications on Amazon Bedrock. Covers model invocation (Converse API, InvokeModel), RAG with Knowledge Bases, Bedrock Agents, Guardrails, and AgentCore (including the Harness managed agent loop). Applies when invoking models, setting up Knowledge Bases, creating agents, applying guardrails, deploying to AgentCore, migrating/porting/converting a Bedrock Agent (including inline agents) to an AgentCore Harness, troubleshooting Bedrock errors (ThrottlingException, AccessDeniedException), or choosing Bedrock models (Claude, Llama, Nova, Titan). Also for prompt caching, quota and throttling diagnosis, cost tracking, migrating between Claude model generations, chunking strategies, and Bedrock model selection. Covers AgentCore Payments (x402, microtransactions, Payment Manager, Connector, Instrument, Coinbase CDP, Stripe Privy, paid endpoints, agent payments). NOT for custom model training, Rekognition, or Comprehend. For SageMaker model discovery, customization, or endpoints, use aws-ai-ml.
references/agentcore-memory-observability.md
View on GitHub# AgentCore Memory & Observability
## Table of Contents
- Memory Service
- Observability (AgentCore-Specific)
## Memory Service
Provides conversation state persistence for agents deployed on AgentCore Runtime.
### When to Enable
- Agents that need conversation context across multiple invocations (multi-turn chat)
- Agents that accumulate knowledge during a session
- Per-session lifecycle agents (see [runtime reference](agentcore-runtime.md))
- NOT needed for stateless per-request agents
### Runtime Integration
The key non-obvious behavior: Runtime passes session IDs to the Memory service automatically when configured. You don't call Memory directly from your agent code — Runtime handles the plumbing.
**Configuration:**
- Session TTL: how long sessions persist after last activity (default varies). Set to the minimum required for your use case — longer TTLs increase the window of exposure for sensitive conversation data
- Memory types: session memory (conversation history), semantic memory (long-term knowledge)
- Refer to the latest AWS documentation on AgentCore Memory service configuration for current options
### Common Failures
**Session not found (expired TTL):**
Session expired between invocations. Increase TTL or handle gracefully in agent logic.
**Session ID not passed from Runtime:**
Agent loses context between requests. Verify Memory service is enabled in Runtime configuration and the client passes `sessionId` in invocation requests.
**Memory capacity exceeded:**
Session has too much accumulated context. Configure memory capacity limits or implement context summarization in agent logic.
## Observability (AgentCore-Specific)
Only the AgentCore-specific parts — agents already know generic OTEL/CloudWatch patterns.
### Required Trace Attributes for Evaluations
This is the key non-obvious requirement. AgentCore Evaluations service reads specific OTEL trace attributes to score agent quality. Without these, Evaluations can't work.
**Required attributes:**
- Agent input (user query)
- Agent output (response)
- Tool calls (which tools were invoked, with inputs/outputs)
- Latency per step
**Instrumentation:**
- Use AWS Distro for OpenTelemetry (ADOT) SDK (or the AWS Lambda Layer for OpenTelemetry) — the ADOT Collector is not supported for AgentCore agent observability
- You MUST use an IAM role (not access keys) for the ADOT SDK / execution environment authentication — attach to the ECS task role, EC2 instance profile, or pod service account
- You MUST NOT hardcode AWS credentials in ADOT SDK configuration files
- Configure sampling rate for evaluation (not every invocation needs evaluation)
- Refer to the latest AWS documentation on AgentCore observability OTEL instrumentation for current attribute names and SDK configuration
### AgentCore-Specific CloudWatch Metrics
AgentCore publishes these metrics automatically (you don't need to instrument):
| Metric | What It Measures |
|--------|-----------------|
| Invocations | Number of agent invocations |
| Latency | End-to-end response time (p50/p90/p99) |
| System/User Errors | Failed invocations |
| Throttles | Throttled invocations |
| Session Count | Number of sessions |
> Note: Token / GenAI usage metrics are NOT published automatically. To capture token usage (input/output tokens consumed), you must instrument your agent code with the ADOT SDK.
**Recommended alarms:**
- Error rate > 5% for 5 minutes
- p99 latency > SLA threshold
- Token usage approaching quota (80%)
Create alarms — first discover the exact namespace (CloudWatch namespaces are case-sensitive):
1. `aws cloudwatch list-metrics --namespace "Bedrock-AgentCore"` — if no results, try `--namespace "bedrock-agentcore"`
2. Use the namespace that returns metrics in subsequent commands:
`aws cloudwatch put-metric-alarm --alarm-name <name> --metric-name <metric> --namespace "<discovered-namespace>" --statistic Average --period 300 --threshold <value> --comparison-operator GreaterThanThreshold --evaluation-periods 3 --dimensions "Name=Resource,Value=<resource-arn>" --alarm-actions "<sns-topic-arn>"`
### Common Failures
**Traces not appearing:**
ADOT SDK not configured for AgentCore Runtime. Verify ADOT SDK instrumentation in Runtime settings.
**Evaluations can't score:**
Missing required trace attributes. Verify instrumentation includes input, output, and tool call attributes.
## Security Considerations
**Encryption:**
- Enable KMS encryption at rest for Memory resources — customer-managed keys preferred for compliance workloads (HIPAA, GDPR)
- Memory data is encrypted in transit via TLS by default — do not disable TLS
- Encrypt CloudWatch Logs log groups receiving trace data with a KMS key
**Sensitive data:**
- Session memory stores conversation history which may contain PII, credentials, or business-sensitive data
- Trace attributes capture user queries and agent responses — treat as sensitive
- You MUST NOT log raw API keys, secrets, or credentials in trace attributes — sanitize tool call inputs before instrumentation
- Configure CloudWatch Logs retention limits — do not retain trace data indefinitely
**IAM — least privilege:**
- Scope Memory permissions to specific actions (`bedrock-agentcore:CreateMemory`, `bedrock-agentcore:GetMemory`) — avoid `bedrock-agentcore:*`
- Scope CloudWatch permissions to specific alarm and log group ARNs — avoid `cloudwatch:*` or `logs:*`
- Use IAM roles (not IAM users) for all service access
**Alarm notifications:**
- Encrypt SNS topics used for alarm actions with a KMS key
- Restrict SNS topic subscriptions to authorized personnel
- Include `aws:SourceAccount` condition in the SNS topic access policy
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| writing-skillsobra/superpowersUse when creating new skills, editing existing skills, or verifying skills work before deployment | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| xlsxanthropics/skillsUse this skill any time a spreadsheet file is the primary input or output. This means any task where the user wants to: open, read, edit, or fix an existing .xlsx, .xlsm, .xltx, .csv, or .tsv file (e.g., adding columns, computing formulas, formatting, charting, cleaning messy data); create a new spreadsheet from scratch or from other data sources; or convert between tabular file formats. Trigger especially when the user references a spreadsheet file by name or path — even casually (like "the xlsx in my downloads") — and wants something done to it or produced from it. Also trigger for cleaning or restructuring messy tabular data files (malformed rows, misplaced headers, junk data) into proper spreadsheets. The deliverable must be a spreadsheet file. Do NOT trigger when the primary deliverable is a Word document, HTML report, standalone Python script, database pipeline, or Google Sheets API integration, even if tabular data is involved. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| shipping-and-launchaddyosmani/agent-skillsPrepares production launches. Use when preparing to deploy to production, or when asking what needs to be in place before shipping. Use when you need a pre-launch checklist, when setting up monitoring, when planning a staged rollout, or when you need a rollback strategy. | Stars: 119k | Updated | Claude CodeCodex | Verified | Install |
| childhoodthedotmack/claude-memBabysit a shipped release after merge, publication, or deployment. Verify published packages, production behavior, installed plugins, and late CI or user reports until the observation window is clean; use babysit for PR readiness before release. | Stars: 118k | Updated | Claude CodeCodex | Verified | Install |