avinash-rai commited on
Commit
deeaf96
·
1 Parent(s): 84ae2d0

Clean agentNotes: human-readable format per GUVI spec Section 12

Browse files
Files changed (1) hide show
  1. app/utils/guvi_handler.py +61 -28
app/utils/guvi_handler.py CHANGED
@@ -342,36 +342,69 @@ class GUVIHandler:
342
  if agg_intel.get("is_synthetic"):
343
  ethics_note = " [NOTE: Synthetic identifiers injected for sandbox visibility]"
344
 
345
- # [SCORING] Include orchestrator-level summary
346
- orch_summary = result.get("agent_notes", "")
347
- if orch_summary:
348
- orch_summary = f" | Summary: {orch_summary}"
349
-
350
- agent_notes = (
351
- f"[{result.get('threat_level', 'LOW')} RISK] {scam_type.upper()} attempt detected. "
352
- f"Tactics identified: {', '.join(tactics[:3])}. "
353
- f"Intelligence: {'Captured ' + str(len(guvi_intel.upiIds)) + ' identifiers' if guvi_intel.upiIds else 'Awaiting identifiers'}."
354
- f" [AGITATION: {current_agitation}]{ethics_note}{orch_summary}"
355
- f"{reasoning_snippet}"
356
- f" | INTEL_COUNT: UPI={len(guvi_intel.upiIds)}, PHONES={len(guvi_intel.phoneNumbers)}, URLS={len(guvi_intel.phishingLinks)}"
357
- f" | ENGAGEMENT_DEPTH: {total_messages // 2} turns"
358
- )
 
 
 
 
 
 
 
 
359
 
360
- # [SCORING BOOST] Add visible extracted data for judges
 
361
  if guvi_intel.upiIds:
362
- agent_notes += f" | EXTR: {', '.join(guvi_intel.upiIds[:1])}..."
363
-
364
- try:
365
- # [PERFORMANCE] Telemetry Latency Guard
366
- # Only run forensic lookup if Risk is HIGH or scams are clearly detected
367
- if (result.get("threat_level") == "HIGH" or result.get("is_scam")) and telemetry_collector:
368
- client_ip = result.get("analysis", {}).get("client_ip", "Unknown")
369
- forensics = telemetry_collector.tracked_ips.get(client_ip, {}).get("forensics")
370
- if forensics:
371
- fid = telemetry_collector.tracked_ips.get(client_ip, {}).get("fingerprint_id", "N/A")
372
- agent_notes += f"[FORENSIC ID: {fid}] TZ: {forensics.get('timezone')}. "
373
- except ImportError:
374
- pass # Telemetry optional for crash safety
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
375
 
376
  # Evaluation Flags
377
  is_scam = result.get("is_scam", False)
 
342
  if agg_intel.get("is_synthetic"):
343
  ethics_note = " [NOTE: Synthetic identifiers injected for sandbox visibility]"
344
 
345
+ # [SCORING] Build CLEAN human-readable agentNotes (per GUVI spec Section 12)
346
+ # Example: "Scammer used urgency tactics and payment redirection"
347
+
348
+ # Map tactics to readable descriptions
349
+ tactic_descriptions = {
350
+ "urgency": "urgency pressure",
351
+ "authority": "authority impersonation",
352
+ "fear": "fear tactics",
353
+ "greed": "fake reward promises",
354
+ "social_proof": "social proof manipulation",
355
+ "reciprocity": "reciprocity manipulation",
356
+ "scarcity": "scarcity pressure",
357
+ "time_pressure": "time-based coercion",
358
+ "identity_theft": "identity theft attempt",
359
+ "phishing": "phishing attempt",
360
+ "credential_harvesting": "credential harvesting"
361
+ }
362
+
363
+ # Build readable tactics list
364
+ readable_tactics = []
365
+ for t in tactics[:3]:
366
+ readable_tactics.append(tactic_descriptions.get(t.lower(), t.replace("_", " ")))
367
 
368
+ # Determine primary scam vector
369
+ scam_vectors = []
370
  if guvi_intel.upiIds:
371
+ scam_vectors.append("UPI payment redirect")
372
+ if guvi_intel.bankAccounts:
373
+ scam_vectors.append("bank account harvesting")
374
+ if guvi_intel.phishingLinks:
375
+ scam_vectors.append("phishing link distribution")
376
+ if guvi_intel.phoneNumbers:
377
+ scam_vectors.append("phone number collection")
378
+ if any(k in ["OTP", "otp"] for k in guvi_intel.suspiciousKeywords):
379
+ scam_vectors.append("OTP theft attempt")
380
+
381
+ # Build clean agent notes
382
+ tactics_str = " and ".join(readable_tactics) if readable_tactics else "social engineering"
383
+ vectors_str = " and ".join(scam_vectors[:2]) if scam_vectors else "credential extraction"
384
+
385
+ agent_notes = f"Scammer used {tactics_str}. Detected {vectors_str}."
386
+
387
+ # Add intel summary if available
388
+ intel_items = []
389
+ if guvi_intel.upiIds:
390
+ intel_items.append(f"{len(guvi_intel.upiIds)} UPI ID(s)")
391
+ if guvi_intel.bankAccounts:
392
+ intel_items.append(f"{len(guvi_intel.bankAccounts)} bank account(s)")
393
+ if guvi_intel.phoneNumbers:
394
+ intel_items.append(f"{len(guvi_intel.phoneNumbers)} phone number(s)")
395
+ if guvi_intel.phishingLinks:
396
+ intel_items.append(f"{len(guvi_intel.phishingLinks)} phishing link(s)")
397
+
398
+ if intel_items:
399
+ agent_notes += f" Extracted: {', '.join(intel_items)}."
400
+
401
+ # Add engagement depth
402
+ turns = total_messages // 2
403
+ if turns >= 5:
404
+ agent_notes += f" Successfully engaged for {turns} turns."
405
+
406
+ # Add ethics note if applicable
407
+ agent_notes += ethics_note
408
 
409
  # Evaluation Flags
410
  is_scam = result.get("is_scam", False)