Skip to content

feat: add relevancy steering handler with LLM judge + Bedrock Guardra… - #30

Open
rajjayaaws wants to merge 1 commit into
aws-samples:bedrock_sizer_integfrom
rajjayaaws:pr/relevancy-steering
Open

feat: add relevancy steering handler with LLM judge + Bedrock Guardra…#30
rajjayaaws wants to merge 1 commit into
aws-samples:bedrock_sizer_integfrom
rajjayaaws:pr/relevancy-steering

Conversation

@rajjayaaws

Copy link
Copy Markdown

Add a Strands SDK steering plugin that validates agent responses for relevancy and grounding using two complementary approaches:

  1. LLM Judge (Steering Hook): Checks KB query intent before tool calls and evaluates response faithfulness after generation
  2. Bedrock Guardrails (ApplyGuardrail API): Scores contextual grounding and relevance against KB source data

Both run inside a single steering handler, log scores to S3, and support passive (log only) or active (auto-retry) modes via environment variables.

Includes:

  • relevancy_steering_handler.py: SteeringHandler with steer_before_tool and steer_after_model hooks
  • relevancy_logger.py: S3 score logger with local fallback
  • eval_runner.py + eval_test_cases.py: 50-case evaluation suite across L100-L400 user levels with Strands Evals integration
  • CFN: Bedrock Guardrail (contextual grounding) + S3 logging bucket
  • Updated README with steering config, log structure, and eval docs

Issue #, if available:

Description of changes:

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

…ils scoring

Add a Strands SDK steering plugin that validates agent responses for
relevancy and grounding using two complementary approaches:

1. LLM Judge (Steering Hook): Checks KB query intent before tool calls
   and evaluates response faithfulness after generation
2. Bedrock Guardrails (ApplyGuardrail API): Scores contextual grounding
   and relevance against KB source data

Both run inside a single steering handler, log scores to S3, and support
passive (log only) or active (auto-retry) modes via environment variables.

Includes:
- relevancy_steering_handler.py: SteeringHandler with steer_before_tool
  and steer_after_model hooks
- relevancy_logger.py: S3 score logger with local fallback
- eval_runner.py + eval_test_cases.py: 50-case evaluation suite across
  L100-L400 user levels with Strands Evals integration
- CFN: Bedrock Guardrail (contextual grounding) + S3 logging bucket
- Updated README with steering config, log structure, and eval docs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant