Generated banner for Agents Optimize
Generated logo for Agents Optimize

Agents Optimize

AWSOfficialCreated by aws-agentcore

  • Skill
  • Tool integration
  • Cloud and DevOps
  • Apache-2.0
  • No issues found

From the author

Use when measuring or improving agent quality and performance — set up evaluators, online monitoring, CI/CD quality gates, observability, or cost optimization. Triggers on: "evaluate my agent", "add evaluator", "measure quality", "quality gate", "run evals", "agent too slow", "why is it slow", "reduce latency", "set up observability", "CloudWatch dashboard", "how much does my agent cost", "cost optimization", "logs not showing up", "logs missing", "spans not found", "eval failing", "eval error", "dev traces", "local traces", "agentcore dev traces", "traces to CloudWatch". Not for debugging errors or crashes — use agents-debug. Slow but correct routes here; broken routes to debug.
— the description by aws-agentcore

AutoGineer summary

Written by AutoGineer from the skill’s own files, not by the author

The agents-optimize skill provides a structured approach to monitoring and refining AgentCore agents. It guides developers through setting up evaluators, configuring continuous monitoring, implementing CI/CD quality gates, and analyzing agent costs. The skill leverages project context to determine whether to focus on evaluation workflows, observability setups like CloudWatch and X-Ray, or cost optimization strategies.

What it does

  • Configures evaluators for assessing agent responses
  • Sets up continuous online monitoring for live traffic
  • Generates CI/CD quality gate scripts to validate agent performance
  • Provides guidance on setting up CloudWatch dashboards and X-Ray tracing
  • Analyzes cost drivers for AgentCore runtimes and memory usage
  • Facilitates local evaluation loops using dev traces

When to use it

  • When you need to verify if your agent is providing accurate responses
  • When you want to implement automated quality checks in your deployment pipeline
  • When you need to gain visibility into agent behavior via logs and metrics
  • When you need to understand and control the costs associated with your agent

Advantages

  • Supports local iteration on evaluators without requiring full deployments
  • Integrates with standard AWS observability tools like CloudWatch
  • Provides clear paths for both development-time and production-time monitoring
  • Helps identify specific cost drivers within the AgentCore architecture

Usage examples

“evaluate my agent”
The skill initiates an interactive session to determine if you want to run a one-time evaluation, set up monitoring, or add a CI/CD quality gate.
“set up observability”
The skill loads the observability reference and guides you through configuring CloudWatch dashboards and X-Ray tracing for your agent.
“how much does my agent cost”
The skill provides a breakdown of cost components such as runtime compute, memory events, and model usage to help you optimize your spending.
“quality gate”
The skill generates a script to integrate a quality gate into your CI/CD pipeline, ensuring builds fail if performance thresholds are not met.

Install

  1. Download the skill as a ZIP:

    https://autogineer.com/agent-skills/aws/agents-optimize/download
  2. Unzip it into the cross-client skills folder of your project:

    mkdir -p .agents/skills && unzip agents-optimize.zip -d .agents/skills

Documentation by aws-agentcore

optimize

Measure and improve your AgentCore agent's quality through evaluation, monitoring, and observability.

When to use

  • You want to know if your agent is giving good answers

  • You want to set up continuous quality monitoring in production

  • You want to add a quality gate to your CI/CD pipeline

  • You want to understand agent behavior through logs, metrics, and traces

  • You want to set up CloudWatch dashboards or X-Ray tracing

Do NOT use for:

  • Debugging a specific broken agent (wrong answers, errors) → use agents-debug

  • Production security hardening (IAM, auth) → use agents-harden

Input

$ARGUMENTS can be:

  • An eval goal: "add a quality gate", "set up monitoring"

  • An observability goal: "set up CloudWatch dashboard", "understand my traces"

  • A specific evaluator: "llm-as-a-judge", "code-based"

  • Empty — the skill will guide based on project context

Process

Step 0: Verify CLI version

Run agentcore --version. This skill requires v0.9.0 or later.

Step 1: Read project context

Read agentcore/agentcore.json to understand existing evaluators, online eval configs, and agent setup.

If agentcore/agentcore.json is not found:

"This skill requires an AgentCore project. Use agents-get-started to create one."

Step 2: Determine the workflow
Developer intentAction
Measure quality, add evaluator, run eval, CI/CD gate, online monitoringLoad references/evals.md and follow its workflow
Set up observability, CloudWatch, X-Ray, logs, metrics, dashboardsLoad references/observability.md and follow its workflow
Understand or reduce AgentCore costsLoad references/cost.md
Both — "I want to understand and improve my agent"Start with observability setup, then add evals
Step 3: Follow the loaded reference

The reference file contains the full procedure. Follow it step by step.

Cross-references
  • After setting up evals, suggest agents-harden for production readiness

  • If eval results reveal agent issues, suggest agents-debug for root cause analysis

  • If the developer needs to add capabilities first, suggest agents-build

Output

Depends on the workflow — see the loaded reference for specific outputs.

Quality criteria

  • Evaluator configuration uses only valid CLI flags

  • Online eval sampling rate is appropriate (not 100% in production without discussion)

  • CI/CD quality gate has a clear pass/fail threshold

  • Observability setup includes both tracing and logging

  • The developer understands the eval data delay: ~10 seconds put-to-get, end-to-end — one ingestion step covers both trace reads and eval queries; there is no separate indexing wait

Files

references/cost.md

Cost Optimization

Understand what drives AgentCore costs and how to control them. Pricing values are volatile — always verify against the AgentCore pricing page.

Cost components

AgentCore charges for several things independently:

ComponentWhat you pay forPublished rate (verify for current)Biggest cost drivers
Runtime computevCPU-hours + GB-hours while session is active$0.0895/vCPU-hr, $0.00945/GB-hrSession length, idle timeout, cold starts
Memory eventsCreating events (writes)$0.25 per 1,000 new eventsSession volume, number of strategies
Memory storageLong-term memory records stored$0.75 per 1,000 records/month (built-in); $0.25 (override/self-managed)Number of strategies, expiry duration
Memory retrievalRetrieving memory records$0.50 per 1,000 retrievalsRetrieval frequency, top_k value
Gateway tool callsPer tool invocation routed through gateway$0.005 per 1,000 (ListTools/InvokeTool/Ping); $0.025 per 1,000 (Search)Tool call volume
Evaluator model callsBedrock model usage for LLM-as-judge evaluatorsBuilt-in: $0.0024/10K input tokens, $0.012/10K output tokens; Custom: $1.50/10K evalsOnline eval sampling rate × session volume
Bedrock model usageInput/output tokens for every model callVaries by model — check Bedrock pricingModel choice (Sonnet vs Haiku), conversation length
Policy authorizationPer authorization request + input tokens$0.000025/request, $0.13/10K input tokensTool call volume with policy engine attached
IdentityToken/API key requests for non-AWS resources$0.010 per 1,000 requestsCredential fetch frequency
CloudWatch logs/tracesIngestion and storageStandard CloudWatch pricingLog verbosity, retention policy
ECR storage (Container builds only)Image storageStandard ECR pricingImage size, build frequency

Rates above are published as of the time of writing. Always verify against the AgentCore pricing page — pricing changes between releases.

First-day cost questions

"How much will my agent cost per invocation?"

There's no single number — it depends on:

  • Which model (Haiku is ~10x cheaper than Sonnet per token)

  • How long the session stays active (Runtime bills by vCPU-hour and GB-hour, not per request — idle sessions cost money)

  • Whether it uses tools (gateway calls are $0.005 per 1,000 + any Lambda/API costs)

  • Whether memory extraction is running (async, billed separately at $0.25 per 1,000 events)

  • How long conversations run (more tokens = more model cost, and longer active sessions = more compute cost)

A simple Haiku-based agent with no memory and no tools costs very little per request — Runtime compute is billed by vCPU-hour ($0.0895) and GB-hour ($0.00945), so a sub-second request on a small environment costs fractions of a cent. A Sonnet agent with semantic memory, 5 gateway tools, and online evals at 10% sampling costs significantly more per request — the model token costs alone can be 10–30x higher, plus memory extraction ($0.25 per 1,000 events), gateway tool calls ($0.005 per 1,000 invocations), and eval model usage. These are published rates as of the time of writing — verify against the AgentCore pricing page for current numbers. If the awsknowledge MCP server is available, use the aws___search_documentation tool to look up current AgentCore pricing.

"How much will this demo/prototype cost me?"

Use the --defaults flags (Strands, Bedrock, no memory) during development. Stay under the free tier where possible. The biggest surprises come from:

  • Idle sessions burning compute — Runtime bills by vCPU-hour while the session is active, including idle time before idleRuntimeSessionTimeout reclaims it. Default timeout is 15 minutes. Call StopRuntimeSession when done, or lower the timeout. See agents-harden Session lifecycle management.

  • Leaving an online eval config running at 100% sampling

  • Forgetting to set CloudWatch log retention (defaults to indefinite)

  • Keeping a test memory resource with an expensive strategy (SEMANTIC or EPISODIC)

Cost reduction levers

Model selection

AgentCore supports four model providers — pick the right one for the task, not just the default:

Model tierExamplesGood for
Cheapest / simplestamazon.nova-micro-v1:0, claude-3-5-haiku-*, Gemini Flash, GPT-5-nanoClassification, extraction, simple routing, short responses
Mid-tieramazon.nova-lite-v1:0, Gemini 2.5 FlashMost general-purpose agents with light reasoning
Premium / reasoninganthropic.claude-sonnet-4-5-*, GPT-5, Gemini 2.5 ProComplex reasoning, code generation, multi-step planning

Rules of thumb:

  • Haiku or Nova Micro for simple extractive tasks (10–30x cheaper than Sonnet per token)

  • Reserve Sonnet/Opus/GPT-5 for reasoning-heavy workflows

  • Use different models for agent vs evaluator — a Haiku-based evaluator grading a Sonnet agent is a common cost-effective pattern

  • For cost-sensitive customer support or classification agents, start with Nova Lite or Gemini Flash and only upgrade if quality is insufficient

Memory
  • Only enable strategies you actually use — each LTM strategy runs extraction on every session

  • SEMANTIC is the most expensive strategy. If you only need session summaries, use SUMMARIZATION alone.

  • Tune relevance_score up so fewer memory records retrieve per query

  • Set --expiry to the shortest duration that serves your use case (default is 30 days)

Online evals
  • Start at 1–5% sampling in production, not 100%

  • Use agentcore pause online-eval <name> when debugging or iterating — resume when you're ready to measure

  • Pick the smallest evaluator set that gives signal

Logs and traces
  • Set retention policies on log groups:

    aws logs put-retention-policy \
      --log-group-name /aws/bedrock-agentcore/runtimes/<AGENT_ID>-DEFAULT \
      --retention-in-days 30
  • Don't log entire payloads — log structured events with just what you need

  • X-Ray sampling is configured automatically; no dial to turn there

Gateway
  • Tool calls are per-invocation, not per byte. Volume matters, not payload size.

  • If a tool is called on every invocation for the same static data, consider baking that data into the system prompt instead

Container builds
  • If you don't need Container, use CodeZip — no ECR storage charge

  • If you need Container, keep the image small (see agents-harden Initialization time section)

Cross-references

  • For model selection decisions, see references/evals.md Path A (evaluator model choice applies the same way)

  • For memory strategy decisions, see agents-build/references/memory.md

  • For log retention (a harden concern), see agents-harden Observability section

Requirements and compatibility

Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Kiro, OpenCode, Goose, Amp, Roo Code, JetBrains Junie, Factory Droid, Devin (ex-Windsurf), Mistral Vibe, OpenHands, Letta

“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.

Needs: Declares allowed tools

Security

No issues found by our static scan· No issues found

A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.

Attribution and licence

Created by
aws-agentcore
Publisher
AWS (Official)
Source
aws/agent-toolkit-for-aws · plugins/aws-agents/skills/agents-optimize · commit 0a218f8
Licence
Apache License 2.0 (redistribution allowed)
  • LICENSE (added by AutoGineer from LICENSE)
  • NOTICE (added by AutoGineer from NOTICE)
  • ATTRIBUTION.md (written by AutoGineer)
Synced

AutoGineer is not affiliated with or endorsed by aws-agentcore or AWS.

Download ZIP

The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download agents-optimize.zip