File size: 2,767 Bytes
5774aff
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
"""
Identity Specialist Agent

Probes: name variant analysis, transliteration mismatches,
cross-document identity coherence, passport-to-document name matching.
"""

from __future__ import annotations

import json

from agents.base_agent import BaseSpecialistAgent


class IdentityAgent(BaseSpecialistAgent):
    agent_id = "identity_agent"
    focus_nodes = ["identity"]

    def _build_prompt(self, graph_subset: dict, rule_findings: list[dict], jurisdiction: str) -> str:
        ctx_block = f"\nJURISDICTION CONTEXT:\n{jurisdiction}\n" if jurisdiction else ""
        dossier_ctx = graph_subset.get("_document_context", {})
        partial_note = dossier_ctx.get("partial_dossier_instructions", "")
        return f"""You are an adversarial pre-submission auditor reviewing identity documents.
Your task: identify identity inconsistencies in the PROVIDED documents and flag missing identity documents
as informational gaps β€” NOT as rejection grounds.
{ctx_block}
DOSSIER COMPLETENESS: {partial_note}

IDENTITY DATA:
{json.dumps(graph_subset.get("identity"), indent=2)}

RULE ENGINE FLAGS (already detected):
{json.dumps(rule_findings, indent=2)}

Analyse the following β€” be specific, cite exact field paths:
1. Are all name_variants plausibly the same person? Consider transliteration rules
   (e.g. Japanese: family-first vs given-first, romanisation differences).
2. If cross_doc_name_match is false, is this a genuine mismatch or an expected
   transliteration variation? Rate the severity.
3. Check for date_of_birth consistency β€” is it the same across all documents?
4. Does the passport_number match the identity page expectations for the stated nationality?
5. If passport data is null, classify as 'info' severity β€” the passport document has not been uploaded yet.
   Do NOT treat missing passport as a critical rejection issue.

CRITICAL ROLE RESOLUTION:
Before checking for name mismatches, review Affidavit or Sponsor letters to establish roles.
If Document A (Passport) belongs to the Applicant and Document B (Bank Statement) belongs to a
Sponsor/Parent/Guardian, DO NOT flag this as a name mismatch. They are two distinct, verified
individuals linked by the Affidavit. Different names across documents belonging to DIFFERENT PEOPLE
are expected and correct β€” not fraud.
Only flag mismatches if:
  a) The APPLICANT'S name is spelled differently across the applicant's own documents, OR
  b) The SPONSOR'S name is spelled differently across the sponsor's own documents.
A father's bank statement showing 'SATYANARAYANA' alongside a son's passport showing 'SAI KIRAN'
is a normal sponsor-applicant relationship, NOT an identity discrepancy.

Respond ONLY with the AgentFinding JSON schema. Every anomaly must include the exact field_path."""