Modeling Agentic Workflows for Finance

Moving from individual prompts to production systems requires thinking architecturally. Financial workflows aren’t just chains of prompts - they’re coordinated systems where multiple specialized agents work together. Understanding how to model these workflows is essential for building reliable, maintainable financial AI systems.

From Automation to Agentic Systems

Most organizations start with simple automation - fixed scripts that follow predetermined paths. The evolution toward agentic systems happens when you need flexibility: handling varied inputs, adapting to exceptions, and making decisions that weren’t explicitly programmed.

flowchart TB
    subgraph Deterministic["Deterministic Automation"]
        direction LR
        I1[Input] --> S1[Step 1]
        S1 --> S2[Step 2]
        S2 --> S3[Step 3]
        S3 --> O1[Output]
    end

    subgraph Agentic["Agentic Workflow"]
        direction LR
        I2[Input] --> P[Planning Agent]
        P --> R{Router}
        R -->|Path A| A1[Agent 1]
        R -->|Path B| A2[Agent 2]
        A1 --> E[Evaluator]
        A2 --> E
        E -->|Revise| P
        E -->|Approve| O2[Output]
    end

    classDef blueClass fill:#4A90E2,stroke:#333,stroke-width:2px,color:#fff

    class Agentic blueClass

The Generalization Leap

Consider a simple loan application processor that checks three things in order: credit score, income verification, and debt-to-income ratio. That’s deterministic automation.

The agentic version generalizes this:

  • A planning agent understands the application type and decides what checks are needed
  • Specialized agents handle each verification type
  • A routing mechanism directs work based on application characteristics
  • An evaluation loop catches issues and requests revisions

This generalization means the same system can handle different loan types, adapt when requirements change, and learn from edge cases.

Two Approaches to Workflow Modeling

Process-Centric (Deterministic)

Focus on the rigid connection between tasks:

  1. Identify all tasks
  2. Map their sequence and dependencies
  3. Define inputs/outputs for each
  4. Note decision points (usually simple if/else rules)
  5. Visualize as a flowchart

Agent-Centric (Agentic)

Focus on the agents themselves:

  • Agent capabilities: What can each agent do?
  • Goal structure: What objectives, how is success measured?
  • Decision-making frameworks: How do agents evaluate options?
  • Adaptation rules: How do agents learn from feedback?
  • Environment constraints: What boundaries exist?
  • Feedback loops: How does information flow back for improvement?

The Agent Complexity Spectrum

Not all agents are equal. They exist on a spectrum of complexity and autonomy:

Agent Type Description Use Case
Direct Prompting Send query directly to LLM Simple Q&A
Augmented Prompting Add system message defining persona Role-specific responses
Knowledge Augmented Persona + curated knowledge base Domain-specific expertise
RAG Agent Dynamic retrieval before answering Large knowledge bases
Evaluation Agent Assess outputs against criteria Quality control
Routing Agent Direct tasks to appropriate specialists Multi-domain systems
Planning Agent Break goals into executable steps Complex task execution

Choosing the Right Agent Type

flowchart TD
    Q1{Need domain
expertise?}
    Q1 -->|No| DP[Direct Prompting]
    Q1 -->|Yes| Q2{Static or
dynamic knowledge?}
    Q2 -->|Static| KA[Knowledge Augmented]
    Q2 -->|Dynamic| RAG[RAG Agent]

    Q3{Need quality
control?}
    Q3 -->|Yes| EVAL[Evaluation Agent]

    Q4{Multiple
domains?}
    Q4 -->|Yes| ROUTE[Routing Agent]

    Q5{Complex
goals?}
    Q5 -->|Yes| PLAN[Planning Agent]

    classDef blueClass fill:#4A90E2,stroke:#333,stroke-width:2px,color:#fff
    classDef orangeClass fill:#F39C12,stroke:#333,stroke-width:2px,color:#fff
    classDef greenClass fill:#27AE60,stroke:#333,stroke-width:2px,color:#fff

    class RAG blueClass
    class EVAL orangeClass
    class PLAN greenClass

Visual Workflow Modeling

When designing agentic workflows, visual representation helps communicate complex systems clearly.

Modeling Guidelines

Use Standard Symbols

  • Rectangles for tasks/agents
  • Diamonds for decisions
  • Arrows for flow direction
  • Circles for start/end points

Label Clearly
Each node needs a descriptive name:

  • “Validate BIC Code” instead of “Validate”
  • “Assess Credit Risk” instead of “Check Risk”
  • “Route by Transaction Type” instead of “Route”

Show Data Flow
Make explicit what data each agent uses and produces:

flowchart LR
    A["Application
Parser
──────
In: Raw PDF
Out: Structured Data"] --> B["Credit
Checker
──────
In: SSN, Income
Out: Score, Report"]
    B --> C["Risk
Assessor
──────
In: Credit Report
Out: Risk Level"]

Choose Appropriate Granularity
High-level for stakeholder communication:

flowchart LR
    A[Receive Application] --> B[Validate & Enrich]
    B --> C[Assess Risk]
    C --> D[Make Decision]

Detailed for implementation:

flowchart TD
    A[Parse PDF] --> B[Extract Fields]
    B --> C[Validate Format]
    C --> D{Valid?}
    D -->|Yes| E[Lookup External Data]
    D -->|No| F[Request Corrections]
    E --> G[Calculate Metrics]
    G --> H[Run Risk Model]

Applied Example: SWIFT Message Processing

SWIFT (Society for Worldwide Interbank Financial Telecommunication) messages are the backbone of international banking. Processing them requires multiple specialized capabilities - perfect for an agentic workflow.

The Multi-Agent Architecture

flowchart TD
    MSG[SWIFT Message] --> VAL[Validator Agent]
    VAL --> COR[Correction Agent]
    COR --> OPT[Optimized Message]
    OPT --> SCR[Initial Screener]
    SCR --> TECH[Technical Analyzer]
    TECH --> RISK[Risk Assessor]
    RISK --> COMP[Compliance Checker]
    COMP --> REV[Final Reviewer]
    REV --> DEC{Decision}
    DEC -->|Approve| OUT[Process Transaction]
    DEC -->|Flag| FLAG[Manual Review Queue]
    DEC -->|Reject| REJ[Rejection Handler]

    classDef blueClass fill:#4A90E2,stroke:#333,stroke-width:2px,color:#fff
    classDef orangeClass fill:#F39C12,stroke:#333,stroke-width:2px,color:#fff
    classDef greenClass fill:#27AE60,stroke:#333,stroke-width:2px,color:#fff

    class VAL blueClass
    class COR blueClass
    class SCR orangeClass
    class REV greenClass

Agent Responsibilities

Validator Agent: Checks message structure and field validity

1
2
3
4
5
6
7
8
9
10
11
12
validator_prompt = """
You are a SWIFT message validator. Check:
1. BIC codes are valid format (8 or 11 characters)
2. Required fields are present (sender, receiver, amount, currency)
3. Date formats are correct (YYMMDD)
4. Amount fields contain valid numbers

Message: {swift_message}

Report validation errors as JSON:
{{"errors": [{"field": "...", "issue": "...", "severity": "high|medium|low"}]}}
"""

Correction Agent: Attempts to fix identified issues

1
2
3
4
5
6
7
8
9
10
11
12
13
correction_prompt = """
You are a SWIFT message correction specialist.

Original message: {message}
Validation errors: {errors}

Analyze each error and provide corrections where possible.
For unfixable errors, explain why manual intervention is needed.

Response format:
{{"corrections": [{"field": "...", "original": "...", "corrected": "..."}],
"unfixable": [{"field": "...", "reason": "..."}]}}
"""

Initial Screener: Quick triage for obvious issues

1
2
3
4
5
6
7
8
9
10
11
12
13
screener_prompt = """
You are an experienced transaction screener with 15 years in banking.
Quickly triage this SWIFT message:

{message}

Assign threat level:
- RED: Block immediately (invalid BIC, sanctioned entity, format corruption)
- YELLOW: Flag for review (unusual patterns, high amounts, new counterparty)
- GREEN: Clear to proceed

Provide brief reasoning for your decision.
"""

Technical Analyzer: Deep format validation

1
2
3
4
5
6
7
8
9
10
11
12
13
technical_prompt = """
You are a SWIFT technical specialist. Analyze:

1. Message type validity (MT103, MT202, etc.)
2. Field tag correctness
3. Character set compliance
4. Mandatory field presence
5. Conditional field logic

Message: {message}

Provide technical assessment with specific field references.
"""

Risk Assessor: Evaluate transaction risk

1
2
3
4
5
6
7
8
9
10
11
12
13
14
risk_prompt = """
You are a financial risk analyst. Assess:

1. Transaction amount vs typical patterns
2. Geographic risk (sender/receiver locations)
3. Timing patterns (after hours, weekends)
4. Counterparty risk
5. Historical relationship

Message: {message}
Bank registry: {registry}

Provide risk score (1-10) with justification.
"""

Compliance Checker: Regulatory validation

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
compliance_prompt = """
You are a compliance officer. Verify:

1. Sanctions list screening
2. Anti-money laundering indicators
3. Know Your Customer requirements
4. Regulatory reporting needs
5. Transaction limits

Message: {message}
Sanctions list: {sanctions}
Compliance rules: {rules}

Flag any compliance concerns with required actions.
"""

Final Reviewer: Synthesize all assessments

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
final_review_prompt = """
You are the senior transaction reviewer. Given:

Screening result: {screening}
Technical analysis: {technical}
Risk assessment: {risk}
Compliance check: {compliance}

Make final decision:
- APPROVE: Process immediately
- FLAG: Route to manual review (specify concerns)
- REJECT: Block with reason

Provide executive summary for audit trail.
"""

Workflow Execution

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
class SWIFTProcessor:
def __init__(self):
self.validator = Agent(validator_prompt)
self.corrector = Agent(correction_prompt)
self.screener = Agent(screener_prompt)
self.technical = Agent(technical_prompt)
self.risk = Agent(risk_prompt)
self.compliance = Agent(compliance_prompt)
self.reviewer = Agent(final_review_prompt)

def process(self, swift_message: str, max_corrections: int = 3):
# Stage 1: Validation and Correction Loop
message = swift_message
for attempt in range(max_corrections):
errors = self.validator.run(message)
if not errors:
break
corrections = self.corrector.run(message, errors)
message = apply_corrections(message, corrections)

# Stage 2: Sequential Analysis Pipeline
screening = self.screener.run(message)
if screening.level == "RED":
return {"decision": "REJECT", "reason": screening.reason}

technical = self.technical.run(message)
risk = self.risk.run(message)
compliance = self.compliance.run(message)

# Stage 3: Final Review
decision = self.reviewer.run(
screening=screening,
technical=technical,
risk=risk,
compliance=compliance
)

return {
"decision": decision.action,
"optimized_message": message,
"audit_trail": {
"screening": screening,
"technical": technical,
"risk": risk,
"compliance": compliance,
"final_review": decision
}
}

Deterministic vs Agentic: When to Use Which

Factor Deterministic Agentic
Input Variability Low - structured, predictable High - varied formats, edge cases
Decision Complexity Simple rules suffice Requires judgment, context
Error Tolerance Fail fast is acceptable Need graceful degradation
Auditability Full trace is easy Requires explicit logging
Maintenance Update code for rule changes Update prompts, potentially self-adapting
Cost Lower (no LLM calls) Higher (API costs)

Hybrid Approach

Often the best solution combines both:

flowchart LR
    I[Input] --> D1{Structured
format?}
    D1 -->|Yes| DET[Deterministic
Validation]
    D1 -->|No| AG1[Agentic
Parser]
    AG1 --> DET
    DET --> D2{Pass basic
checks?}
    D2 -->|Yes| AG2[Agentic
Risk Assessment]
    D2 -->|No| REJ[Reject]
    AG2 --> DET2[Deterministic
Routing]
    DET2 --> OUT[Output]

    classDef orangeClass fill:#F39C12,stroke:#333,stroke-width:2px,color:#fff
    classDef blueClass fill:#4A90E2,stroke:#333,stroke-width:2px,color:#fff

    class DET orangeClass
    class AG1 blueClass
    class AG2 blueClass

Use deterministic processing for:

  • Format validation (regex, schema checking)
  • Simple routing rules
  • Threshold-based decisions
  • Compliance with known rules

Use agentic processing for:

  • Unstructured input parsing
  • Context-dependent decisions
  • Edge case handling
  • Quality assessment

Design Principles for Financial Workflows

1. Define Clear Agent Boundaries

Each agent should have:

  • Single, well-defined responsibility
  • Clear inputs and outputs
  • Explicit success/failure criteria

2. Build in Observability

Every agent action should be logged:

1
2
3
4
5
6
7
8
9
def run_agent(agent, input_data):
start_time = time.time()
try:
result = agent.execute(input_data)
log_success(agent.name, input_data, result, time.time() - start_time)
return result
except Exception as e:
log_failure(agent.name, input_data, e, time.time() - start_time)
raise

3. Design for Failure

Assume any agent can fail:

  • Define fallback behaviors
  • Set maximum retry limits
  • Establish escalation paths to human review

4. Separate Policy from Mechanism

Keep business rules external:

1
2
3
4
5
6
7
8
9
10
# config/swift_rules.yaml
risk_thresholds:
low: 3
medium: 6
high: 10

amount_limits:
standard: 100000
elevated_review: 500000
senior_approval: 1000000

5. Version Everything

Prompts, configurations, and agent definitions should all be versioned:

1
2
3
4
5
6
7
8
@dataclass
class AgentConfig:
name: str
version: str
prompt_template: str
model: str
temperature: float
created_at: datetime

Takeaways

  1. Agentic workflows generalize automation by adding planning, routing, and evaluation capabilities that adapt to varied inputs

  2. Agent-centric modeling focuses on capabilities, goals, and decision frameworks rather than rigid task sequences

  3. Visual modeling with standard symbols and clear labeling helps communicate complex systems to stakeholders

  4. Agent types form a spectrum from simple direct prompting to autonomous planning agents - choose based on task complexity

  5. Hybrid approaches combine deterministic processing for structured tasks with agentic processing for judgment-requiring decisions

  6. Financial workflows benefit from multiple specialized agents working together with clear responsibilities and explicit handoffs


This is the fourth post in my Applied Agentic AI for Finance series. Next: Prompt Chaining and Routing in Trading Systems where we’ll explore sequential and branching workflow patterns for trading operations.

Building Financial Prompt Pipelines Prompt Chaining and Routing in Trading Systems

Comments

Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×