Skip to content

Commit fae5d3c

Browse files
committed
Apply suggestions
1 parent 783d2ee commit fae5d3c

6 files changed

Lines changed: 114 additions & 85 deletions

File tree

modules/ai-agents/examples/agents/fraud-agent-prompt.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ You are the fraud detection agent for ACME Bank's dispute resolution system. You
1010
## Available Tools
1111

1212
1. **calculate_fraud_score**: Multi-factor fraud scoring
13-
- Input: Transaction data, customer data, merchant reputation
14-
- Returns: Fraud score, breakdown by factor, recommendation
13+
- Input: transaction_id, customer_id
14+
- Returns: Fraud score (0-100), risk level, breakdown by factor, recommendation
1515

1616
2. **get_risk_indicators**: Detailed fraud signal detection
1717
- Input: transaction_id

modules/ai-agents/examples/mcp-tools/processors/calculate_fraud_score.yaml

Lines changed: 90 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,77 +1,102 @@
11
label: calculate_fraud_score
22
mapping: |
3-
let location_risk = match {
4-
this.transaction.location.country != this.customer.location_country => 35,
5-
this.transaction.location.city != this.customer.primary_city => 15,
6-
_ => 0
7-
}
8-
9-
let merchant_risk = match {
10-
this.merchant_reputation < 40 => 30,
11-
this.merchant_reputation < 70 => 15,
12-
_ => 0
13-
}
14-
15-
let amount_risk = match {
16-
this.transaction.amount > (this.customer.avg_transaction * 10) => 25,
17-
this.transaction.amount > (this.customer.avg_transaction * 5) => 15,
18-
this.transaction.amount > (this.customer.avg_transaction * 2) => 5,
19-
_ => 0
20-
}
21-
22-
let velocity_risk = match {
23-
this.recent_transactions_count > 10 => 15,
24-
this.recent_transactions_count > 5 => 8,
25-
_ => 0
26-
}
27-
28-
let category_risk = match {
29-
this.transaction.merchant.category == "jewelry" && this.customer.typical_categories.contains("jewelry").not() => 20,
30-
this.transaction.merchant.category == "electronics" && this.customer.typical_categories.contains("electronics").not() => 15,
31-
this.transaction.merchant.category == "luxury_goods" && this.customer.typical_categories.contains("luxury_goods").not() => 15,
32-
_ => 0
33-
}
34-
35-
let total_score = $location_risk + $merchant_risk + $amount_risk + $velocity_risk + $category_risk
36-
37-
let risk_level = match {
38-
$total_score >= 80 => "critical",
39-
$total_score >= 60 => "high",
40-
$total_score >= 40 => "medium",
41-
$total_score >= 20 => "low",
42-
_ => "minimal"
43-
}
44-
45-
root = {
46-
"transaction_id": this.transaction.transaction_id,
47-
"fraud_score": $total_score,
48-
"risk_level": $risk_level,
49-
"score_breakdown": {
50-
"location_risk": $location_risk,
51-
"merchant_risk": $merchant_risk,
52-
"amount_risk": $amount_risk,
53-
"velocity_risk": $velocity_risk,
54-
"category_risk": $category_risk
3+
root = match {
4+
this.transaction_id == "TXN-89012" && this.customer_id == "CUST-1001" => {
5+
"transaction_id": "TXN-89012",
6+
"customer_id": "CUST-1001",
7+
"fraud_score": 95,
8+
"risk_level": "critical",
9+
"score_breakdown": {
10+
"location_risk": 35,
11+
"merchant_risk": 30,
12+
"amount_risk": 25,
13+
"velocity_risk": 0,
14+
"category_risk": 20
15+
},
16+
"factors_detected": [
17+
"unusual_location",
18+
"questionable_merchant",
19+
"unusual_amount",
20+
"unusual_category"
21+
],
22+
"reasoning": "International transaction from Singapore with no customer history of international purchases. High-value jewelry purchase (14.5x customer average). Merchant has significant fraud indicators.",
23+
"recommendation": "block_and_investigate"
24+
},
25+
this.transaction_id == "TXN-89013" && this.customer_id == "CUST-1001" => {
26+
"transaction_id": "TXN-89013",
27+
"customer_id": "CUST-1001",
28+
"fraud_score": 8,
29+
"risk_level": "minimal",
30+
"score_breakdown": {
31+
"location_risk": 0,
32+
"merchant_risk": 0,
33+
"amount_risk": 0,
34+
"velocity_risk": 0,
35+
"category_risk": 0
36+
},
37+
"factors_detected": [],
38+
"reasoning": "Local transaction from trusted merchant in customer's typical spending category and amount range.",
39+
"recommendation": "approve"
40+
},
41+
this.transaction_id == "TXN-89014" && this.customer_id == "CUST-1002" => {
42+
"transaction_id": "TXN-89014",
43+
"customer_id": "CUST-1002",
44+
"fraud_score": 52,
45+
"risk_level": "medium",
46+
"score_breakdown": {
47+
"location_risk": 0,
48+
"merchant_risk": 15,
49+
"amount_risk": 0,
50+
"velocity_risk": 8,
51+
"category_risk": 0
52+
},
53+
"factors_detected": [
54+
"questionable_merchant",
55+
"high_velocity"
56+
],
57+
"reasoning": "Recurring subscription service with known billing issues. Multiple charges detected from same merchant. Moderate merchant reputation score.",
58+
"recommendation": "monitor_closely"
59+
},
60+
this.transaction_id == "TXN-89015" && this.customer_id == "CUST-1003" => {
61+
"transaction_id": "TXN-89015",
62+
"customer_id": "CUST-1003",
63+
"fraud_score": 12,
64+
"risk_level": "minimal",
65+
"score_breakdown": {
66+
"location_risk": 0,
67+
"merchant_risk": 0,
68+
"amount_risk": 5,
69+
"velocity_risk": 0,
70+
"category_risk": 0
71+
},
72+
"factors_detected": [
73+
"slightly_elevated_amount"
74+
],
75+
"reasoning": "International hotel charge consistent with customer's frequent travel patterns. Amount within expected range for lodging category.",
76+
"recommendation": "approve"
5577
},
56-
"factors_detected": [
57-
if $location_risk > 0 { "unusual_location" },
58-
if $merchant_risk > 0 { "questionable_merchant" },
59-
if $amount_risk > 0 { "unusual_amount" },
60-
if $velocity_risk > 0 { "high_velocity" },
61-
if $category_risk > 0 { "unusual_category" }
62-
].filter(f -> f != null),
63-
"recommendation": match {
64-
$total_score >= 80 => "block_and_investigate",
65-
$total_score >= 60 => "hold_for_review",
66-
$total_score >= 40 => "monitor_closely",
67-
_ => "approve"
78+
_ => {
79+
"transaction_id": this.transaction_id,
80+
"customer_id": this.customer_id,
81+
"fraud_score": 50,
82+
"risk_level": "medium",
83+
"score_breakdown": {
84+
"location_risk": 0,
85+
"merchant_risk": 0,
86+
"amount_risk": 0,
87+
"velocity_risk": 0,
88+
"category_risk": 0
89+
},
90+
"factors_detected": [],
91+
"reasoning": "Insufficient data to calculate accurate fraud score for this transaction/customer combination.",
92+
"recommendation": "monitor_closely"
6893
}
6994
}
7095
7196
meta:
7297
mcp:
7398
enabled: true
74-
description: "Calculate fraud risk score based on transaction patterns and risk indicators. Returns risk level and recommendation."
99+
description: "Calculate fraud risk score based on transaction patterns and risk indicators. Use TXN-89012 through TXN-89015 with corresponding customer IDs for testing."
75100
properties:
76101
- name: transaction_id
77102
type: string

modules/ai-agents/examples/mcp-tools/processors/check_regulatory_requirements.yaml

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -108,17 +108,9 @@ mapping: |
108108
meta:
109109
mcp:
110110
enabled: true
111-
description: "Check regulatory requirements for dispute resolution based on transaction type, amount, and jurisdiction."
111+
description: "Check regulatory requirements for dispute resolution based on dispute type."
112112
properties:
113-
- name: transaction_type
113+
- name: dispute_type
114114
type: string
115-
description: "Type of transaction (card_not_present, international, recurring, travel)"
116-
required: true
117-
- name: amount
118-
type: number
119-
description: "Transaction amount in USD"
120-
required: true
121-
- name: jurisdiction
122-
type: string
123-
description: "Geographic jurisdiction (USA, EU, APAC)"
115+
description: "Type of dispute (fraud, billing_error, service_not_received)"
124116
required: true

modules/ai-agents/examples/mcp-tools/processors/get_merchant_category.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,9 @@ mapping: |
8282
meta:
8383
mcp:
8484
enabled: true
85-
description: "Retrieve merchant category information including MCC code, fraud risk level, and common patterns. Use LUXURY WATCHES INT, EXAMPLE STREAMING, or HOTEL PARIS for testing."
85+
description: "Retrieve merchant category information including fraud risk level and common patterns based on MCC code."
8686
properties:
87-
- name: merchant_name
87+
- name: mcc
8888
type: string
89-
description: "Merchant name as it appears on transaction"
89+
description: "Merchant Category Code (5944 for jewelry, 5942 for books, 4899 for streaming, 7011 for hotels)"
9090
required: true

modules/ai-agents/examples/mcp-tools/processors/log_audit_event.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,18 @@ meta:
3333
type: string
3434
description: "Dispute resolution decision (approve_refund, deny_claim, etc.)"
3535
required: true
36+
- name: risk_score
37+
type: number
38+
description: "Calculated fraud risk score (0-100)"
39+
required: true
40+
- name: evidence
41+
type: object
42+
description: "Evidence reviewed during investigation"
43+
required: true
44+
- name: outcome
45+
type: string
46+
description: "Final outcome of the dispute (approved, denied, escalated, pending)"
47+
required: true
3648
- name: escalated
3749
type: boolean
3850
description: "Whether case was escalated for manual review"

modules/ai-agents/examples/pipelines/test-pipelines.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,10 @@ for file in *.yaml; do
7878
echo "$output" | sed 's/^/ /'
7979
FAILED=$((FAILED + 1))
8080
else
81-
# Other lint error
82-
echo -e "${YELLOW}WARNING${NC}"
83-
echo "$output" | sed 's/^/ /' | head -5
84-
CLOUD_PROCESSOR_ERRORS=$((CLOUD_PROCESSOR_ERRORS + 1))
81+
# Other lint error (unexpected)
82+
echo -e "${RED}FAILED${NC}"
83+
echo "$output" | sed 's/^/ /'
84+
FAILED=$((FAILED + 1))
8585
fi
8686
fi
8787
done

0 commit comments

Comments
 (0)