Build custom code-based evaluators in Amazon Bedrock AgentCore

๐กLearn how to build custom validation logic for your AI agents using AWS Lambda and Amazon Bedrock AgentCore.
โก 30-Second TL;DR
What Changed
Implement four Lambda-based custom code evaluators for specialized agent tasks.
Why It Matters
This feature significantly improves the reliability of AI agents by allowing developers to inject domain-specific validation logic. It bridges the gap between generic evaluation metrics and the nuanced requirements of enterprise financial applications.
What To Do Next
Implement a custom Lambda evaluator for your agent's output to enforce domain-specific constraints or PII masking.
Key Points
- โขImplement four Lambda-based custom code evaluators for specialized agent tasks.
- โขSupport for both on-demand and online execution modes within AgentCore.
- โขIntegrate with AWS services for PII detection, fact-checking, and real-time alerting.
๐ง Deep Insight
Web-grounded analysis with 22 cited sources.
๐ Enhanced Key Takeaways
- โขCustom code evaluators in Amazon Bedrock AgentCore allow for deterministic checks, external API calls, regex matching, and custom metric computation, offering full control over evaluation logic beyond traditional LLM-as-a-judge methods.
- โขBeyond custom evaluators, AgentCore Evaluations provides 13 pre-built evaluators covering essential quality dimensions such as correctness, helpfulness, tool selection accuracy, safety, and goal success rate.
- โขEvaluations can be configured to operate at granular levels, including session-level (entire conversations), trace-level (individual responses), or tool-call level (specific tool usage), enabling precise diagnosis of agent behavior.
- โขAmazon Bedrock AgentCore is designed to be framework-agnostic and model-agnostic, supporting integration with popular open-source frameworks like CrewAI, LangGraph, and LlamaIndex, and various foundation models from different providers, including OpenAI, Google's Gemini, and Anthropic's Claude.
- โขPricing for custom code evaluators is consumption-based at $1.50 per 1,000 evaluations, which is distinct from the token-based pricing for built-in LLM-as-a-judge evaluators.
๐ Competitor Analysisโธ Show
While Amazon Bedrock AgentCore provides a comprehensive platform for building and evaluating AI agents, several specialized platforms offer competitive features in the evaluation space:
| Feature / Platform | Amazon Bedrock AgentCore Evaluations | Maxim AI | LangSmith | Langfuse |
|---|---|---|---|---|
| Evaluation Types | Built-in (LLM-as-a-Judge), Custom Code (Lambda), Ground Truth | Pre-built, Custom (deterministic, statistical, LLM-based), Conversation-level | Scenario-based, Batch scoring, RAG support | Rule-based, LLM judge custom metrics, Human labeling |
| Observability | Integrated with CloudWatch, detailed visualizations of agent workflow, OpenTelemetry/OpenInference instrumentation | End-to-end lifecycle coverage, connects pre-production experimentation with post-deployment monitoring | Tracing, monitoring, prompt comparisons | Real-time traces, prompt comparisons, integrations |
| Integration/Flexibility | Framework-agnostic (CrewAI, LangGraph, LlamaIndex), Model-agnostic (OpenAI, Gemini, Claude, etc.), Lambda for custom logic | Full-stack approach for multi-agent systems, Playground++ for prompt iteration | Deep LangChain integration | Open-source, MIT-licensed, self-hosting supported, integrates with LangChain |
| Deployment Model | Fully managed service | Managed service, with open-source gateway | Managed service | Open-source, self-hosting available |
| Primary Focus | Securely deploy, operate, and continuously evaluate AI agents at scale with custom and built-in tools | End-to-end AI quality platform, simulation, evaluation, observability | Workflow testing, debugging, and monitoring for LangChain applications | Tracing, evaluation, and prompt management for LLM applications |
๐ ๏ธ Technical Deep Dive
- Custom code evaluators are implemented as AWS Lambda functions.
- These Lambda functions receive OpenTelemetry (OTel) spans as structured events, which contain detailed information about the agent's reasoning, tool calls, and responses.
- The Lambda function is expected to return a JSON response that includes a score, a label, and an explanation for the evaluation.
- AgentCore Runtime, which hosts the AI agents and tools, operates in a secure, serverless environment, similar to AWS Lambda, and packages agent code into Docker images for deployment to Amazon ECR.
- Each user session within AgentCore Runtime runs in its own dedicated microVM, providing complete session isolation for enhanced security and data protection.
- AgentCore supports OpenTelemetry and OpenInference instrumentation libraries for collecting detailed traces of agent interactions.
- The evaluation process can be applied at three levels: session (entire conversation), trace (individual turns/responses), and tool-call (specific tool invocations), with varying contextual information available at each level for the evaluators.
- AgentCore Gateway facilitates secure access to tools by transforming existing APIs and Lambda functions into agent-compatible tools using the Model Context Protocol (MCP).
๐ฎ Future ImplicationsAI analysis grounded in cited sources
โณ Timeline
๐ Sources (22)
Factual claims are grounded in the sources below. Forward-looking analysis is AI-generated interpretation.
Weekly AI Recap
Read this week's curated digest of top AI events โ
๐Related Updates
Same topic
Explore #aws
Same product
More on amazon-bedrock-agentcore
Same source
Latest from AWS Machine Learning Blog

OpenAI agent escaped due to preventable human errors
Anthropic and OpenAI disclose AI systems breaching external networks

GM triples pull requests by redesigning workflows around AI agents

First Agentic Diffusion Model with 128K Context
AI-curated news aggregator. All content rights belong to original publishers.
Original source: AWS Machine Learning Blog โ