Compliance KYC Multi-Tool Agent Orchestration Script
Develop an automated Python script coordinating multi-tool calls across identity verification, sanctions checks, and audit logging.
Use this template when implementing customer onboarding agents that must query external identity providers sequentially. It establishes resilient tool calling with fallback mechanisms and audit trails.
Role: Lead Compliance Systems Architect specializing in automated identity verification and regulatory technology.
Context
- Banking Entity: {{bank_entity_name}}
- Sanctions Watchlist API: {{sanctions_database_vendor}}
- Credit Bureau Service: {{credit_bureau_api}}
- Document Extraction Tool: {{ocr_service_provider}}
- Immutable Audit Store: {{audit_logging_database}}
- Max Tool Retry Attempts: {{retry_limit}}
Task
Construct an end-to-end Python script configuring agent tools that extract identity data via {{ocr_service_provider}}, screen against {{sanctions_database_vendor}}, query {{credit_bureau_api}}, and write immutable verification events to {{audit_logging_database}} on behalf of {{bank_entity_name}}.
Method
- Define tool schemas for identity document optical parsing and extraction.
- Define tool schemas for Politically Exposed Persons (PEP) and sanctions list matching.
- Define tool schemas for real-time credit profile verification and address confirmation.
- Write the agent controller loop that parses tool call requests and routes them to specific API clients.
- Integrate exponential backoff retry logic constrained by {{retry_limit}} for all network calls.
- Construct a deterministic fallback strategy whenever a third-party KYC provider returns an outage code.
- Build a telemetry writer recording every tool invocation timestamp and payload digest to {{audit_logging_database}}.
Constraints
- Code MUST redact Personally Identifiable Information (PII) before printing standard out logs.
- Tool calls MUST NOT execute in parallel if sanctions screening yields an unverified match.
- Script MUST strictly adhere to Python asynchronous programming (
asyncioandhttpx). - Every tool response MUST return a normalized boolean approval status code.
Output format
1. Tool Definitions Block
List of agent tool definitions with parameters, required fields, and type annotations.
2. Async Orchestration Script
Executable async Python program with tool handlers, retry decorators, and fallback logic.
3. Verification Test Harness
Async test runner demonstrating a successful onboarding pass and a sanctions match trigger.
Self-review
- Confirm that PII masking logic is active across all console logging statements.
- Verify that {{retry_limit}} is referenced and parameterized in the retry handler.
- Ensure audit logs are queued for every single tool invocation regardless of success or failure.
Explicit role, a named task, and discrete steps the model can follow.
Background, inputs and variables the model needs before it starts.
Hard boundaries — what the model must and must not do.
A named, field-level shape for the response.
Ordered work items that force analysis before an answer.
Length and structure that travel across frontier models.
Signal density — instruction weight without padding.
Documented variables so the scaffold adapts to new inputs.
Quality bar, assumptions and behaviour when inputs are thin.
How much real usage the template has behind it.