Service teams lose time and trust when policy answers are fast but wrong. This repository delivers a scratch-org-ready Agentforce pattern that forces grounded citations, blocks unsafe responses when policy grounding is weak, and emits traceable response metadata for audit and operations.
Generated from scripts/run-tests.sh and scripts/eval/run_eval.sh into docs/benchmarks.json:
- Apex coverage (CI gate): 90.0%
- Citation coverage: 94.0%
- Unsupported-claim rate: 4.5%
- Grounded-answer rate: 94.0%
- Prompt Builder template (
PolicyAnswer) defines tone, refusal behavior, and citation contract. PolicyRAGActionretrieves matchingPolicy__crecords and builds structured citations.PolicyRAGActioncallscallout:SteeringAPI/v1/steerthrough Named Credential before returning.- Response payload always includes
answer,citations[],confidenceScore,safetyFlags[], andcorrelationId.
# Authenticate your Dev Hub once per machine
sf org login sfdx-url --sfdx-url-file ./SFDX_AUTH_URL.txt --alias devhub --set-default-dev-hub
# Create, deploy, assign perm set, and seed sample policy records
bash scripts/setup-scratch-org.sh agentforce-rag
# Run Apex tests with coverage gating (fails below 85%)
bash scripts/run-tests.sh agentforce-rag
# Run offline eval and regenerate docs/benchmarks.json + docs/benchmarks.md
bash scripts/eval/run_eval.sh
# Delete scratch org
bash scripts/teardown-scratch-org.sh agentforce-rag- Named Credentials:
SteeringAPIisolates the Steering endpoint; use org-managed secret strategy when moving beyondNoAuthentication. - Least privilege:
AgentforceRAGUsergrants read-only access toPolicy__cand access only toPolicyRAGAction. - PII handling: response logging stores redacted session suffix, flags, and
correlationId; no raw question text is logged. - Logging boundaries: outbound payload contains query + citations for steering, while platform logs keep operational metadata only.
- Architecture:
docs/architecture.md - Threat model:
docs/threat-model.md - Benchmarks:
docs/benchmarks.md - Developer handoff checklist:
docs/handoff-checklist.md