Financial Fraud Triage Tool Dispatcher Script Generator
Generate a production-ready Python tool-calling script that parses AML fraud alerts and invokes external financial investigation APIs.
Use this template when building an autonomous agent script to triage high-volume anti-money laundering alerts. It creates structured tool definitions and execution handlers for banking risk pipelines.
Role: Principal FinTech Automation Engineer specializing in agentic middleware and banking API integration.
Context
- Financial Institution: {{institution_name}}
- Alert Source Engine: {{fraud_detection_engine}}
- In-Scope Alert Types: {{supported_alert_types}}
- Agent Framework: {{target_agent_framework}}
- Dispatch Webhook: {{notification_webhook_endpoint}}
- Minimum Triage Risk Score: {{risk_threshold_score}}
Task
Author a modular, production-ready execution script that defines LLM tool schemas and handler functions to triage incoming fraud alerts from {{fraud_detection_engine}}, filter by {{risk_threshold_score}}, and trigger downstream investigations across {{institution_name}} systems.
Method
- Define typed parameter schemas for {{supported_alert_types}} compatible with {{target_agent_framework}} tool specifications.
- Implement a validation function ensuring payload integrity before parsing suspicious transaction metadata.
- Construct the core tool function that queries account history and aggregates prior violation counts.
- Build an autonomous risk-scoring evaluation handler matching criteria against {{risk_threshold_score}}.
- Write a dispatch function forwarding confirmed high-risk payloads to {{notification_webhook_endpoint}}.
- Implement deterministic error handling and circuit breaker logic for downstream banking API timeouts.
- Wrap the tool pipeline in a runnable CLI entrypoint with structured JSON logging.
Constraints
- Code MUST be written in idiomatic Python 3.11+ with strict type hints and Pydantic models.
- MUST NOT expose raw database connection strings, plain-text API keys, or hardcoded secrets.
- Tool schemas MUST enforce strict parameter validation with detailed docstrings.
- Script MUST include unit test mock examples at the bottom.
Output format
1. Tool Declaration & Schema
JSON Schema / Pydantic models for agent function calling (under 40 lines).
2. Main Implementation Script
Fully commented Python script with execution pipeline, error boundaries, and webhook dispatching.
3. Usage & Test Example
Terminal execution command and mock invocation payload.
Self-review
- Confirm all 6 context variables (e.g., {{institution_name}}, {{risk_threshold_score}}) appear and guide code logic.
- Verify script handles network timeouts and malformed JSON payloads gracefully.
- Ensure schema conforms strictly to {{target_agent_framework}} requirements.
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.