Build a multi-agent system that routes, reviews, and approves invoices β using the same Agentic Loop, Routing, and Parallelization patterns from today's slides.
β± 35 minutes
What You'll Build
Remember Lab 1 on Day 2? You built an invoice processing pipeline step by step β extract, validate, report. Today you'll see the same workflow, but powered by AI agents that coordinate automatically.
π§ Day 3 Concepts in Action
This lab brings together three patterns from today's slides:
The Agentic Loop β Observe (load invoices) β Plan (route them) β Act (review) β Reflect (synthesize decisions)
Routing β A Router Agent classifies each invoice and sends it to the right processing path
Parallelization β Financial and Compliance reviewers analyze the same invoice at the same time
The Multi-Agent Architecture
Step
What you do
Duration
Pattern
Step 1
Install Strands SDK & explore your first agent
8 min
Agentic Loop
Step 2
Build a Routing Agent that classifies invoices
8 min
Routing
Step 3
Run parallel Financial + Compliance reviews
10 min
Parallelization
Step 4
Run the full pipeline β all patterns combined
9 min
All three
Setup: Download Lab Files
All the code and sample data are pre-built for you. You just need to download and install.
π‘ Why pre-built code?
On Day 2 Lab 1, you asked Kiro to write the invoice processing code from scratch β that taught you how AI generates code. Today the goal is different: understand how multiple AI agents coordinate. The code is ready so you can focus on observing the agent behaviors, not debugging Python.
βΆ π "What prompt created this code?"
Here's the prompt that was used to generate agentic_invoice_processor.py with Kiro. This is the kind of prompt you could write after completing this workshop:
THE PROMPT THAT BUILT THIS LAB
Build a multi-agent invoice processing system using the Strands Agents SDK with Amazon Bedrock.
The system should process 6 vendor invoices from Southeast Asian vendors (JSON files in sample-data/invoices/) and validate them against purchase orders (CSV) and business rules (JSON).
Create 4 agents:
1. ROUTER AGENT β Classifies each invoice by category (technology/consulting/office_supplies), priority (high >$25K / standard / low <$5K), and routes to the right review path
2. FINANCIAL REVIEWER β Validates math (subtotal + GST = total), matches against purchase orders using fuzzy vendor name matching, flags variances >2%
3. COMPLIANCE REVIEWER β Checks regional regulations (MAS Singapore, BNM Malaysia, OJK Indonesia, BOT Thailand, SBV Vietnam, BSP Philippines), withholding tax requirements, and approval thresholds
4. ORCHESTRATOR β Synthesizes financial + compliance reviews into final decisions: APPROVE β / FLAG β οΈ / ESCALATE π΄
Each agent should have @tool-decorated functions for its capabilities. Run financial and compliance reviews in parallel using ThreadPoolExecutor. The pipeline should follow the Agentic Loop: OBSERVE (load invoices) β PLAN (route) β ACT (parallel reviews) β REFLECT (synthesize decisions).
Use BedrockModel with us.anthropic.claude-sonnet-4-20250514-v1:0 in us-west-2. Save the final report as markdown.
All amounts in SGD. Use AnyCompany Financial Group as the company name.
The 3-day connection: This prompt uses techniques from all three days β Day 1 (understanding what Bedrock models can do), Day 2 (structured prompting with personas, specific output formats, and guardrails), and Day 3 (agentic patterns: routing, parallelization, the agentic loop). The prompt templates you built on Day 2 are literally the system prompts inside each agent.
π Connection to Day 2 Lab 1
If you still have your lab1-invoice-processing/ folder from Day 2, you can point this agentic system at your own data! After completing this lab, try this in Kiro:
BONUS β Use your Day 2 data
Read the invoice JSON files in my lab1-invoice-processing/extracted/ folder and the purchase_orders.csv file. Convert them to the format used by lab11-agentic-invoice/sample-data/ and copy them there. Then run the agentic pipeline on my Day 2 data.
π‘ Why --break-system-packages? The Kiro server runs Ubuntu 24.04 which blocks system-wide pip installs by default. On Day 2, Kiro handled this automatically when it installed packages like reportlab for you. Since we're running commands manually in the terminal today, we need this flag. It's safe for our workshop environment.
lab11-agentic-invoice/sample-data/validation_rules.json β business rules
lab11-agentic-invoice/step1_explore_agents.py through step3_parallel_review.py
lab11-agentic-invoice/agentic_invoice_processor.py β the full pipeline
Understanding the Sample Data
The 6 invoices are designed to trigger different processing paths β just like Lab 1 on Day 2:
Invoice
Vendor
Amount (SGD)
What it tests
INV-2025-0401
PT Mitra Teknologi (Indonesia)
$21,800
Standard β PO match, cross-border compliance
INV-2025-0402
SG CloudServe (Singapore)
$5,995
Standard β exact PO match, local vendor
INV-2025-0403
Bangkok Digital Solutions (Thailand)
$36,951
High value β PO variance ($551 over), escalation
INV-2025-0404
KL Fintech Consulting (Malaysia)
$18,630
Standard β consulting category, different GST rate
INV-2025-0405
Saigon Data Systems (Vietnam)
$5,341
No matching PO β flag for review
INV-2025-0406
Manila Office Supplies (Philippines)
$8,938
Office supplies β no PO required by category rules
Step 1: Your First Agent (The Agentic Loop)
π Pattern: The Agentic Loop
Every agent follows: Observe (receive input) β Plan (decide what tools to use) β Act (call tools, generate output) β Reflect (check results, retry if needed). Watch for this loop in the terminal output.
Run the first script to see a simple agent in action:
TERMINAL β Run in Kiro terminal
python3 step1_explore_agents.py
π What to watch for:
The agent decides on its own to call list_all_invoices first β you didn't tell it to
It then reasons about the results to answer your questions
If it needs more detail, it might call read_invoice for a specific invoice β that's the Reflect β Act again loop
This is the same Observe β Plan β Act β Reflect cycle from the slides!
π¬ Explore: Ask your own questions
Open step1_explore_agents.py in Kiro. Change the question at the bottom of the file to something else:
IDEAS β Try changing the agent's question to:
β’ "What is the total value of all invoices combined?"
β’ "Which invoices are from ASEAN countries outside Singapore?"
β’ "Read invoice INV-2025-0403 and tell me if the math adds up"
β’ "Compare the two smallest invoices β which is the better deal?"
β Checkpoint: You've seen an agent autonomously decide which tools to call, process the results, and answer your question. This is the Agentic Loop in action.
Step 2: The Routing Agent
π Pattern: Routing
A Router Agent classifies each input and sends it to the right processing path. Think of it as a smart mailroom β it reads each invoice, decides what kind of review it needs, and routes it accordingly. This is the same pattern from the Day 3 slides: classify β route β process.
Run the routing agent:
TERMINAL
python3 step2_routing_agent.py
π What to watch for:
The Router checks each vendor against purchase orders β it uses the check_purchase_order_exists tool multiple times
It applies business rules (amount thresholds, PO requirements) to decide the route
Bangkok Digital Solutions ($36,951) should be routed to both financial + compliance review (high value)
Saigon Data Systems should be flagged β no matching PO
Manila Office Supplies might get a different route β office supplies don't require POs
π Connection to Your Work
π‘
This routing pattern applies to any classification task in finance: routing support tickets to the right team, classifying transactions for regulatory reporting, or triaging merchant applications by risk level. The agent reads the data, applies rules, and decides the path β no hardcoded if/else needed.
β Checkpoint: You've seen the Routing pattern β one agent classifying 6 invoices into different processing paths based on business rules.
Step 3: Parallel Reviews
π Pattern: Parallelization
Two specialist agents review the same invoice at the same time β a Financial Reviewer checks the numbers, while a Compliance Reviewer checks the regulations. Then an Orchestrator combines their findings into a single decision. This is like a review committee meeting, but in seconds.
Run the parallel review on a high-value invoice (Bangkok Digital Solutions β $36,951):
TERMINAL
python3 step3_parallel_review.py
π What to watch for:
Both reviews start at the same time β you'll see "Starting parallel reviews..." then both complete
The Financial Reviewer catches the PO variance: invoice is $36,951 but PO approved $36,400 (a $551 / ~1.5% difference)
The Compliance Reviewer flags Thailand's withholding tax requirement (3% on services) and the high-value escalation threshold
The Orchestrator combines both views β it should recommend ESCALATE or FLAG because of the PO variance + high value + cross-border compliance
Check the output file: output/parallel_review_report.md
π¬ Explore: Try a different invoice
Open step3_parallel_review.py and change the TARGET_INVOICE variable to review a different invoice:
TRY THESE
TARGET_INVOICE = "INV-2025-0401" # PT Mitra Teknologi β Indonesia, $21,800
TARGET_INVOICE = "INV-2025-0405" # Saigon Data Systems β Vietnam, no PO!
TARGET_INVOICE = "INV-2025-0406" # Manila Office Supplies β Philippines, no PO required
β Checkpoint: You've seen Parallelization β two agents reviewing the same data simultaneously, then an orchestrator synthesizing their findings. Check output/parallel_review_report.md for the full report.
Step 4: The Full Pipeline (All Patterns Combined)
π― Everything together
This script combines all three patterns into one pipeline:
OBSERVE β Load all 6 invoices
PLAN (Routing) β Router Agent classifies and routes each invoice
ACT (Parallelization) β Financial + Compliance agents review each invoice in parallel
REFLECT (Orchestration) β Orchestrator synthesizes all reviews into final decisions
Run the full pipeline:
TERMINAL
python3 agentic_invoice_processor.py
β± This takes 2-3 minutes β the system is making multiple calls to Amazon Bedrock for each agent. Watch the terminal output to see each step of the Agentic Loop in real time.
π What to watch for in the output:
OBSERVE β Lists all 6 invoices with amounts
PLAN β Router classifies each invoice (watch for different routes)
ACT β For each invoice, financial + compliance reviews run in parallel
REFLECT β Orchestrator produces final decisions for all 6 invoices
Report β Check output/invoice_processing_report.md for the full report
Expected Results
Invoice
Expected Decision
Why
INV-2025-0401 (PT Mitra)
APPROVE β
PO match, math OK, standard amount
INV-2025-0402 (SG CloudServe)
APPROVE β
PO match, math OK, local vendor
INV-2025-0403 (Bangkok Digital)
ESCALATE π΄
High value + PO variance ($551 over)
INV-2025-0404 (KL Fintech)
APPROVE β
PO match, consulting category
INV-2025-0405 (Saigon Data)
FLAG β οΈ
No matching purchase order
INV-2025-0406 (Manila Office)
APPROVE β
Office supplies β no PO required
β Final Checkpoint: Open output/invoice_processing_report.md and verify:
All 6 invoices have decisions
Bangkok Digital Solutions is escalated (high value + PO variance)
Saigon Data Systems is flagged (no PO)
There's an executive summary at the end with totals and action items
Reflection: What Just Happened?
π§ Compare: Lab 1 (Day 2) vs Lab 11 (Day 3)
Lab 1 (Day 2)
Lab 11 (Day 3)
Approach
You prompted Kiro step by step
Agents coordinated automatically
Steps
4 manual prompts, one at a time
4 agents, routing + parallel execution
Human role
You drove every step
You pressed "run" β agents did the rest
Scalability
Works for 5 invoices with effort
Works for 500 invoices the same way
Consistency
Depends on your prompts each time
Same rules, same agents, every time
The 4 Agents You Built
Agent
Role
Tools it uses
Pattern
Router
Classify & route invoices
read_invoice, match_purchase_order
Routing
Financial Reviewer
Math, PO matching, variance
read_invoice, match_purchase_order, validate_math
Parallelization
Compliance Reviewer
Regulations, tax, jurisdiction
read_invoice, check_compliance
Parallelization
Orchestrator
Synthesize & decide
save_report
Agentic Loop
π‘
Key insight: Each agent has a clear role, specific tools, and focused instructions. This is the same principle as Day 2's persona-based prompting β but now each persona is an independent agent that can be tested, improved, and reused separately.
π What You Accomplished
β‘ Built and ran a multi-agent system using Strands Agents SDK + Amazon Bedrock
πΊοΈ Saw Routing in action β one agent classifying invoices into different paths
π Saw Parallelization β two specialist agents reviewing the same data simultaneously
π Saw the Agentic Loop β agents autonomously deciding which tools to call and when
π― Saw Orchestration β a manager agent synthesizing multiple reviews into final decisions
π Generated a complete invoice processing report with decisions for 6 invoices
This is the same invoice workflow from Day 2 Lab 1 β but now it runs autonomously with multiple AI agents coordinating the work.
π Connection to Lab 10: Agent Design Canvas
This lab is the realized version of the Invoice Processing canvas from Lab 10. Every section of the canvas maps to something in the code:
Agent Identity β Role became the system_prompt for each agent
Workflow β Pattern became Router (Routing) + ThreadPoolExecutor (Parallelization)
Data β Inputs became @tool functions like read_invoice()
Guardrails β Escalate when became threshold checks in the tools
Open agent-design-canvas-invoice.md in the lab folder to see the full canvas that produced this code.
β Bonus: Customize the Agents
If you finish early, try these modifications. Open the Python files in Kiro and ask it to help you make changes:
IDEA 1 β Add a new specialist agent
Open agentic_invoice_processor.py and add a "Budget Reviewer" agent that checks if each invoice fits within the department's quarterly budget of SGD 100,000 for technology and SGD 50,000 for consulting. Have it run in parallel with the other reviewers.
IDEA 2 β Change the routing rules
Modify the Router Agent's system prompt to add a new route: if an invoice is from a vendor in a country where AnyCompany doesn't have an office (only Singapore and Indonesia have offices), route it to an "Enhanced Due Diligence" path.
IDEA 3 β Add your own invoice
Create a new invoice_007.json in sample-data/invoices/ for a vendor from your own team's domain. Run the pipeline again and see how the agents handle it.