market-trends-agent: add code-based evaluators + observability wiring#1413
Merged
BharathiSrini merged 4 commits intoawslabs:mainfrom Apr 30, 2026
Merged
Conversation
- Add 5 Lambda-backed code-based evaluators (schema_validator, stock_price_drift, pii_regex, pii_comprehend, workflow_contract_gsr) with online evaluation config - Add evaluator deploy/invoke/results scripts under evaluators/scripts/ - Enable LangchainInstrumentor so gen_ai.tool.* spans flow to AgentCore Observability - Replace hardcoded us-east-1 with AWS_REGION env var fallback across agent and tests - Rewrite deploy.py to use CodeBuild + bedrock-agentcore-control directly (no starter toolkit dep) - Pin boto3 >= 1.42.0 for Evaluations control-plane APIs - Update README: evaluator documentation, IAM split, troubleshooting, cleanup ordering - Update architecture diagram to reflect evaluator layer - Remove Dockerfile and .dockerignore (container built by CodeBuild, no local Docker needed)
|
Latest scan for commit: Security Scan ResultsScan Metadata
SummaryScanner ResultsThe table below shows findings by scanner, with status based on severity thresholds and dependencies: Column Explanations: Severity Levels (S/C/H/M/L/I):
Other Columns:
Scanner Results:
Severity Thresholds (Thresh Column):
Threshold Source: Values in parentheses indicate where the threshold is configured:
Statistics calculation:
|
Collaborator
BharathiSrini
left a comment
There was a problem hiding this comment.
Please run linters
- test_broker_card.py: add 'import os' (F821 from linter) - stock_price_drift/lambda_function.py: reject non-https reference URLs before urlopen() and annotate with nosec B310 / noqa S310 (Bandit)
BharathiSrini
approved these changes
Apr 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds 5 custom code-based evaluators to the Market Trends Agent sample, along with end-to-end deploy / invoke / results tooling, and updates the agent itself to emit the telemetry required for evaluation.
Tested end-to-end in
us-west-2with all 5 evaluators firing correctly and zero Lambda errors across two full traffic rounds.What changed
New — custom code-based evaluators (
evaluators/)mt_schema_validatormt_stock_price_driftmt_pii_regexmt_pii_comprehendmt_workflow_contract_gsrShips with:
evaluators/scripts/deploy.py— idempotent end-to-end deploy (IAM roles, Lambdas, evaluator registration, online eval config)evaluators/scripts/invoke.py— 4 built-in traffic scenarios (broker intro, returning broker, PII bait, anonymous chitchat)evaluators/scripts/results.py— CloudWatch eval-results viewerevaluators/iam/— trust + permissions policy templatesAgent updates
market_trends_agent.pysogen_ai.tool.*spans flow toaws/spanswhere evaluators can read them.deploy.pyrewritten to usebedrock-agentcore-controlboto3 client + CodeBuild directly — no dependency onbedrock-agentcore-starter-toolkit. Matches the post-GA (2026-03-31) deployment path for code-based evaluators.pyproject.toml— pinsboto3 >= 1.42.0(required forlist_evaluators/create_evaluator/create_online_evaluation_config); addsopentelemetry-instrumentation-langchainwithwrapt<1.16.0to avoid a known instrumentation TypeError."us-east-1"intest_agent.py,test_broker_card.py,tools/browser_tool.py,tools/broker_card_tools.pyreplaced withos.getenv("AWS_REGION", "us-east-1").Docs
CHANGELOG.mdadded.Removed
Dockerfile,.dockerignore— container is built by AWS CodeBuild at deploy time, no local Docker required.How to test
Notes for reviewers
MarketTrends*,market-trends-eval-*) so deploy/cleanup scripts won't collide with other resources in the account.mt_pii_comprehendwhich callscomprehend:DetectPiiEntities.cleanup.pyonly covers agent-side resources; the README now documents that theCleanup Evaluatorsblock must run first.