⚑ Lab 11: Agentic Invoice Processing

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

OBSERVE PLAN ACT REFLECT πŸ“„ 6 Invoices SE Asian vendors Β· SGD $5K–$37K πŸ—ΊοΈ ROUTER AGENT Classifies each invoice by category, priority, risk Routes to the right processing path ⚑ PARALLEL EXECUTION πŸ’° Financial Reviewer Math Β· PO matching Β· Variance πŸ“‹ Compliance Reviewer Regulations Β· Tax Β· Jurisdiction 🎯 ORCHESTRATOR Synthesizes all reviews into final decisions βœ… APPROVE ⚠️ FLAG πŸ”΄ ESCALATE
StepWhat you doDurationPattern
Step 1Install Strands SDK & explore your first agent8 minAgentic Loop
Step 2Build a Routing Agent that classifies invoices8 minRouting
Step 3Run parallel Financial + Compliance reviews10 minParallelization
Step 4Run the full pipeline β€” all patterns combined9 minAll 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.

Download and extract the lab files:

  1. Download lab11-agentic-invoice.zip
  2. Extract it into your Kiro workspace β€” you should see a lab11-agentic-invoice/ folder

Install dependencies:

TERMINAL β€” Run in Kiro terminal
pip install --break-system-packages strands-agents strands-agents-tools
πŸ’‘ 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.
βœ… Checkpoint: You should have:
  • lab11-agentic-invoice/sample-data/invoices/ β€” 6 invoice JSON files
  • lab11-agentic-invoice/sample-data/purchase_orders.csv β€” 6 POs
  • 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:

InvoiceVendorAmount (SGD)What it tests
INV-2025-0401PT Mitra Teknologi (Indonesia)$21,800Standard β€” PO match, cross-border compliance
INV-2025-0402SG CloudServe (Singapore)$5,995Standard β€” exact PO match, local vendor
INV-2025-0403Bangkok Digital Solutions (Thailand)$36,951High value β€” PO variance ($551 over), escalation
INV-2025-0404KL Fintech Consulting (Malaysia)$18,630Standard β€” consulting category, different GST rate
INV-2025-0405Saigon Data Systems (Vietnam)$5,341No matching PO β€” flag for review
INV-2025-0406Manila Office Supplies (Philippines)$8,938Office 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:
  1. OBSERVE β€” Load all 6 invoices
  2. PLAN (Routing) β€” Router Agent classifies and routes each invoice
  3. ACT (Parallelization) β€” Financial + Compliance agents review each invoice in parallel
  4. 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

InvoiceExpected DecisionWhy
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)
ApproachYou prompted Kiro step by stepAgents coordinated automatically
Steps4 manual prompts, one at a time4 agents, routing + parallel execution
Human roleYou drove every stepYou pressed "run" β€” agents did the rest
ScalabilityWorks for 5 invoices with effortWorks for 500 invoices the same way
ConsistencyDepends on your prompts each timeSame rules, same agents, every time

The 4 Agents You Built

AgentRoleTools it usesPattern
RouterClassify & route invoicesread_invoice, match_purchase_orderRouting
Financial ReviewerMath, PO matching, varianceread_invoice, match_purchase_order, validate_mathParallelization
Compliance ReviewerRegulations, tax, jurisdictionread_invoice, check_complianceParallelization
OrchestratorSynthesize & decidesave_reportAgentic 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.