Skip to main content

Implement Multi Agent Architecture

Calculating read time…
🏛️ The Finance Multi-Agent Team — What We Are Building
👑
Finance Supervisor
The Orchestrator. Receives the goal, plans the work, delegates to the right specialist, and assembles the final answer.
📄
AP Agent
Accounts Payable specialist. Handles invoice status, supplier payments, and AP validation queries.
🏦
AR Agent
Accounts Receivable specialist. Handles customer invoice status, outstanding balance, and collection queries.
📊
GL Agent
General Ledger specialist. Handles account balances, journal status, and period close queries.
📌 How to Follow This Lab: We build in this exact order — and we do NOT skip any step. First, we build the three Sub-Agents (AP, AR, GL) and test each one completely. Then and only then we build the Finance Supervisor that coordinates them. This bottom-up approach is the only reliable way to build Multi-Agent systems.



📋 Section 1: Business Scenario — Why We Need a Finance Multi-Agent System

InfraGroup India runs Oracle Fusion Finance with three active modules — Accounts Payable, Accounts Receivable, and General Ledger. The Finance Manager receives dozens of queries every morning from three different sources:

💬 AP Queries (from Suppliers)
"Has invoice INV100234 been approved?"
"When will supplier Acme get paid?"
"Why is our invoice on hold?"
💬 AR Queries (from Sales team)
"How much does customer TechCorp owe us?"
"Is customer invoice AR-5521 overdue?"
"What is the total AR outstanding?"
💬 GL Queries (from Controllers)
"What is the current balance for GL account 1001?"
"Has the June journal been posted?"
"Is the period closed for GL?"

Each query requires the Finance Manager to log into a different Fusion module and look up data manually. It takes 5–10 minutes per query. Some queries mix all three modules — "Give me a complete finance health check for June."

✅ Our Multi-Agent Solution: One Finance Supervisor Agent that receives any finance question, understands which domain it belongs to, and delegates it to the right specialist Sub-Agent (AP, AR, or GL). The specialist fetches real Fusion data, formats a business response, and sends it back to the Supervisor, who delivers a clean consolidated answer. For cross-module questions, the Supervisor calls multiple agents and merges the results.
📊 Before vs After — Finance Query Resolution
Query Type Before (Manual) After (Multi-Agent)
AP Invoice StatusLogin to AP → Search → Read → Reply: 5 minAP Agent fetches and responds: <10 seconds
AR Customer BalanceLogin to AR → Search → Export → Reply: 8 minAR Agent fetches and responds: <10 seconds
GL Account BalanceLogin to GL → Navigate → Note → Reply: 7 minGL Agent fetches and responds: <10 seconds
Finance Health CheckLogin to all 3 modules → Compile manually: 45 minSupervisor calls all 3 agents in parallel: <30 seconds

🏗️ Section 2: Solution Architecture — The Complete Blueprint

Draw this architecture on paper before touching OIC. Understanding the blueprint is the difference between a developer who debugs for hours and one who builds it right the first time.

🏗️ Finance Multi-Agent — Complete Architecture
┌─────────────────────────────────────────────────────────────────┐ │ FINANCE USER / CHANNEL │ │ "Give me a finance health check for June 2026" │ └─────────────────────────┬───────────────────────────────────────┘ │ REST POST (user question) ▼ ┌─────────────────────────────────────────────────────────────────┐ │ FINANCE SUPERVISOR AGENT (Orchestrator) │ │ OCI GenAI (Cohere R+) · ReAct · max_iterations=15 │ │ Prompt: Supervisor coordinates AP+AR+GL specialists │ │ Tools: call_ap_agent call_ar_agent call_gl_agent │ └──────┬───────────────────┬──────────────────┬───────────────────┘ │parallel │parallel │parallel ▼ ▼ ▼ ┌────────────┐ ┌─────────────┐ ┌──────────────┐ │ AP AGENT │ │ AR AGENT │ │ GL AGENT │ │ Cohere R │ │ Cohere R │ │ Cohere R │ │ max_it=5 │ │ max_it=5 │ │ max_it=5 │ │ │ │ │ │ │ │ Tools: │ │ Tools: │ │ Tools: │ │ get_ap_inv │ │ get_ar_bal │ │ get_gl_bal │ │ get_ap_pay │ │ get_ar_inv │ │ get_jrnl_sts │ └─────┬──────┘ └──────┬──────┘ └──────┬───────┘ │ │ │ ▼ ▼ ▼ ┌────────────┐ ┌──────────────┐ ┌──────────────────┐ │OIC: AP INT │ │OIC: AR INT │ │OIC: GL INT │ └─────┬──────┘ └──────┬───────┘ └──────┬───────────┘ │ │ │ └────────────────┴──────────────────┘ │ Oracle Applications Adapter (OAuth via OCI Vault) ▼ ┌─────────────────────────────────────────────────────────────────┐ │ ORACLE FUSION FINANCE ERP │ │ AP Module │ AR Module │ GL Module │ └─────────────────────────────────────────────────────────────────┘
All agents live inside one OIC Gen3 Project. All connections are defined at Project level and shared.

📦 Everything We Will Build — In Build Order

// BUILD ORDER — follow this exactly, never skip a step

PHASE 1 → Create OIC Gen3 Project (the container for everything)
PHASE 2 → Build OIC Integration: GET_AP_INVOICE_STATUS
PHASE 3 → Build OIC Integration: GET_AP_PAYMENT_STATUS
PHASE 4 → Build OIC Integration: GET_AR_CUSTOMER_BALANCE
PHASE 5 → Build OIC Integration: GET_AR_INVOICE_STATUS
PHASE 6 → Build OIC Integration: GET_GL_ACCOUNT_BALANCE
PHASE 7 → Build OIC Integration: GET_JOURNAL_STATUS
PHASE 8 → Register Tools: 2 AP tools + 2 AR tools + 2 GL tools
PHASE 9 → Write Prompt Templates: AP Agent + AR Agent + GL Agent
PHASE 10→ Create AP Agent → Test fully
PHASE 11→ Create AR Agent → Test fully
PHASE 12→ Create GL Agent → Test fully
PHASE 13→ Register 3 Agent-as-Tool entries for Supervisor
PHASE 14→ Write Finance Supervisor Prompt Template
PHASE 15→ Create Finance Supervisor Agent → Test all scenarios
PHASE 16→ Deploy Project → Production Readiness Check

🏗️ Section 3: Phase 1 — Create the OIC Gen3 Project

The Project is the container. Everything — all agents, all tools, all integrations, all connections — lives inside this Project. We create it first, and we never build anything outside it.

💡 Why Project first? An OIC Gen3 Project is like a folder for a complete solution. When you create connections at Project level, all agents inside the Project automatically share those connections — you define the Oracle Fusion connection once, not five times. Deployment and migration also happen at Project level — one action moves everything.
1
Navigate to Projects in OIC Gen3
Open your OIC Gen3 console → In the left menu, look for Projects → Click it → You will see a list of existing projects (may be empty) → Click Create Project.

What you will see: A dialog box asking for Project Name, Description, and optionally a team.

✅ Expected Result: A "Create Project" dialog opens.
2
Fill in Project Details
Enter these exact values:

Project Name : FINANCE-MULTI-AGENT-PRJ
Description : Finance Supervisor with AP, AR, and GL Sub-Agents for Oracle Fusion Finance
Environment : Development

Click Create.

✅ Expected Result: You are taken inside the project workspace. You see tabs for Integrations, Connections, and later AI Agents.
3
Create the Shared Oracle Fusion Connection
Inside the Project → Click Connections tab → Click Create Connection → Search for Oracle Applications → Select it.

Configure the connection:
Connection Name : FUSION-FINANCE-CONN
Connection Type : Oracle Applications (ERP Cloud)
Fusion Host URL : https://your-fusion-instance.oraclecloud.com
Security Policy : OAuth 2.0
Client ID : [retrieve from OCI Vault — never type here]
Client Secret : [retrieve from OCI Vault — never type here]

Click Test → Confirm "Connection is successful" message → Click Save.

Why one connection for all three agents? All three Fusion modules — AP, AR, GL — live in the same Fusion instance. One connection covers all. If you create separate connections, you multiply your credential management overhead by 3.

✅ Expected Result: FUSION-FINANCE-CONN appears in Connections tab with status: Active.
4
Create the OCI Object Storage Bucket for Prompt Templates
In OCI Console (separate browser tab) → Object Storage → Create Bucket:
Bucket Name : finance-agent-templates
Visibility : Private
This bucket will hold 4 prompt template text files — one per agent.

✅ Expected Result: Bucket "finance-agent-templates" created in your OCI tenancy.

📄 Section 4: Phase 2 & 3 — Build the AP Agent Integrations

We build two OIC integrations that will back the two AP Agent tools. Each integration connects to a different Fusion AP REST endpoint and returns a trimmed SUMMARY payload.

💡 Beginner Reminder: An OIC integration is the "engine" behind each tool. When the AP Agent decides to call a tool, it calls the OIC integration. The integration connects to Fusion, fetches data, and returns it. Think of the integration as the hands and the agent as the brain that decides when to use those hands.

⚙️ Phase 2: Build GET_AP_INVOICE_STATUS Integration

1
Create the Integration Inside the Project
Inside FINANCE-MULTI-AGENT-PRJ → Click Integrations tab → Click Create → Select Application type.

Name : GET_AP_INVOICE_STATUS
Description: Fetches AP invoice status from Fusion for a given invoice number
Click Create.

✅ Expected Result: Blank integration canvas opens inside the project.
2
Add REST Trigger (How the Tool Calls This Integration)
Click the Trigger slot (left side of canvas) → Choose REST Adapter → Configure:
Endpoint Name : GetAPInvoiceStatus
Relative URL : /ap/invoice/status
Method : POST
Request JSON : { "invoice_number": "INV100234" }
Response JSON : { "invoice_number":"", "status":"", "supplier_name":"",
"amount":0, "currency":"", "invoice_date":"",
"payment_due_date":"", "hold_reason":"", "message":"" }
Click Done.

✅ Expected Result: Trigger appears on canvas. REST endpoint path shows /ap/invoice/status.
3
Add Oracle Applications Adapter Invoke (Call Fusion AP)
Click + on canvas → Add Invoke → Choose Oracle Applications Adapter → Select connection FUSION-FINANCE-CONN.

Module : Financials → Payables → Invoices
Operation : GET /payablesInvoices (query by InvoiceNumber)
Query Param: q=InvoiceNumber={invoice_number}
Click Done.

✅ Expected Result: Canvas shows: REST Trigger → Fusion AP Invoke. A mapping icon appears between them.
4
Map Request: Pass Invoice Number to Fusion
Click the mapping icon between Trigger and Fusion Invoke → In Mapper:
Map $GetAPInvoiceStatus.request.body.invoice_number → to Fusion query field InvoiceNumber.

Expression in the query string: concat("InvoiceNumber=", /nssrcmpr:executeQueryInput/nsmpr0:query)

Click Validate → No errors → Click Close.

✅ Expected Result: Request mapping shows green checkmark. Invoice number flows to Fusion query.
5
Map Response: Return SUMMARY Only (9 Fields)
Click the response mapping icon (between Fusion result and trigger response) → Map only these fields:
// From Fusion → To Response (9 SUMMARY fields only)
invoice_number ← InvoiceNumber
status ← ValidationStatus (Approved / Needs Revalidation / Cancelled)
supplier_name ← SupplierName
amount ← InvoiceAmount
currency ← InvoiceCurrencyCode
invoice_date ← InvoiceDate
payment_due_date ← PaymentsDueDate
hold_reason ← HoldReason (if any)
message ← "" (filled by fault handler if error)
Click Validate → Click Close.

Why 9 fields and not all 200+ Fusion fields? The AP Agent's LLM reads every token in the tool response. If we return all 200+ Fusion fields, the context window fills up in 2 tool calls. With 9 fields, we can make many tool calls without running out of context. Always return the minimum the agent needs.

✅ Expected Result: Response mapping shows 9 fields. No required fields unmapped.
6
Add Fault Handler, Activate, and Test
Click Fault Handler tab → Add Assign activity → Set these values on any error:
invoice_number = $invoice_number (from request)
status = "NOT_FOUND"
message = concat("AP Invoice ", $invoice_number, " not found.")
// All other fields = ""
Click Save → Click Activate → Tracing: Audit → Click Activate.

Test it immediately: Click Test → POST to /ap/invoice/status with body {"invoice_number":"INV100234"} → Confirm you get 9-field SUMMARY JSON back with real Fusion data.

✅ Expected Result: Integration is Active. Test returns 9-field JSON with HTTP 200. Copy the integration REST URL — you will need it in the Tool step.

⚙️ Phase 3: Build GET_AP_PAYMENT_STATUS Integration

This integration answers "when will this invoice be paid?" — it queries the Fusion AP payments schedule rather than the invoice header.

Step 1 — Create Integration inside Project
Project → Integrations → Create → Application type → Name: GET_AP_PAYMENT_STATUS → Description: "Returns Fusion AP payment schedule for a given invoice number"
Step 2 — REST Trigger
REST Trigger → Relative URL: /ap/payment/status → POST → Request: {"invoice_number":""} → Response: {"invoice_number":"","payment_status":"","payment_date":"","payment_amount":0,"bank_account":"","message":""}
Step 3 — Fusion Invoke
Oracle Applications Adapter → Connection: FUSION-FINANCE-CONN → Module: Financials → Payables → Payments → Operation: GET /payablesPayments → Filter by InvoiceNumber
Step 4 — Response Mapping (6 SUMMARY fields)
payment_status ← PaymentStatus | payment_date ← PaymentDate | payment_amount ← PaymentAmount | bank_account ← BankAccountNumber (last 4 digits only for security)
Step 5 — Fault Handler, Activate, Test
Add fault handler with status="NOT_FOUND" → Activate with Audit tracing → Test with a real invoice number → Confirm 6-field SUMMARY response → Copy integration URL.
✅ AP Integrations Checkpoint: Before moving on, confirm: GET_AP_INVOICE_STATUS is Active and tested. GET_AP_PAYMENT_STATUS is Active and tested. Both return SUMMARY JSON. Both have fault handlers. Both URLs are saved in a notepad.

🏦 Section 5: Phase 4 & 5 — Build the AR Agent Integrations

Now we build two integrations for the Accounts Receivable module. The AR Agent will use these to answer customer balance and customer invoice status queries. Same approach as AP — one integration per tool, SUMMARY payloads only.

⚙️ Phase 4: Build GET_AR_CUSTOMER_BALANCE Integration

1
Create the Integration Inside the Project
Inside FINANCE-MULTI-AGENT-PRJ → Integrations tab → Create → Application type.

Name : GET_AR_CUSTOMER_BALANCE
Description : Returns total outstanding AR balance for a given customer name or number
Click Create.

✅ Expected Result: Blank integration canvas opens inside the project.
2
Configure the REST Trigger
Click Trigger slot → REST Adapter → Configure:
Endpoint Name : GetARCustomerBalance
Relative URL : /ar/customer/balance
Method : POST
Request JSON : { "customer_name": "TechCorp Ltd" }
Response JSON : { "customer_name":"", "customer_number":"",
"total_outstanding":0, "currency":"",
"overdue_amount":0, "oldest_invoice_date":"",
"credit_limit":0, "message":"" }
Click Done.

✅ Expected Result: Trigger added to canvas with path /ar/customer/balance.
3
Add Oracle Applications Adapter — Fusion AR
Click + on canvas → Add Invoke → Oracle Applications Adapter → Select connection FUSION-FINANCE-CONN.

Module : Financials → Receivables → Customers (Balances)
Operation : GET /receivablesCustomerAccountSites
Or use : GET /receivablesTransactions with customer filter
Filter : CustomerName = {customer_name}
Important Note: The Fusion AR REST API returns customer transactions. In the response mapping step we will aggregate to produce the total outstanding balance. Fusion does not return a pre-computed "total balance" field — we sum the open transaction amounts in XSLT.

Click Done.

✅ Expected Result: Canvas shows REST Trigger → Fusion AR Invoke.
4
Map Response — 8 SUMMARY Fields with XSLT Aggregation
In the response mapper, use an XSLT expression to calculate total_outstanding and overdue_amount by summing Fusion transaction amounts. Map these 8 summary fields:
customer_name ← CustomerName
customer_number ← CustomerNumber
total_outstanding ← sum(items/BalanceDue)
currency ← CurrencyCode
overdue_amount ← sum(items[DaysLate > 0]/BalanceDue)
oldest_invoice_date ← min(items/InvoiceDate)
credit_limit ← CreditLimit
message ← "" (fault handler fills this on error)
Click Validate → No errors → Click Close.

✅ Expected Result: 8-field response mapping validated successfully.
5
Add Fault Handler, Activate, and Test
Fault Handler → Assign activity → Set:
customer_name = $customer_name (from request)
total_outstanding = 0
message = concat("Customer ", $customer_name, " not found in AR.")
Save → Activate (Audit tracing) → Test:
POST to /ar/customer/balance with body {"customer_name":"TechCorp Ltd"}

✅ Expected Result: HTTP 200. 8-field SUMMARY JSON with real TechCorp balance data. Copy the integration REST URL.

⚙️ Phase 5: Build GET_AR_INVOICE_STATUS Integration

This integration answers "is customer invoice AR-5521 overdue?" — it queries the specific AR transaction rather than the customer-level balance.

Step 1 — Create Integration
Project → Integrations → Create → Application → Name: GET_AR_INVOICE_STATUS → Description: "Returns AR customer invoice status from Fusion for a given AR invoice number"
Step 2 — REST Trigger
Path: /ar/invoice/status | POST | Request: {"ar_invoice_number":"AR-5521"} | Response: {"ar_invoice_number":"","customer_name":"","amount":0,"currency":"","due_date":"","status":"","days_overdue":0,"message":""}
Step 3 — Fusion Invoke
Oracle Applications Adapter → FUSION-FINANCE-CONN → Module: Financials → Receivables → Transactions → GET /receivablesTransactions → Filter: TransactionNumber = {ar_invoice_number}
Step 4 — Response Mapping (8 SUMMARY fields)
ar_invoice_number ← TransactionNumber | customer_name ← CustomerName | amount ← OriginalAmount | due_date ← DueDate | status ← Status | days_overdue ← DaysLate (calculated from DueDate vs today)
Step 5 — Fault Handler, Activate, Test
Fault Handler → status="NOT_FOUND" → message=concat("AR Invoice ", $ar_invoice_number, " not found.") → Activate (Audit) → Test with real AR invoice → Confirm 8-field SUMMARY → Copy URL.
✅ AR Integrations Checkpoint: GET_AR_CUSTOMER_BALANCE is Active and tested. GET_AR_INVOICE_STATUS is Active and tested. Both return SUMMARY JSON with correct Fusion data. Both fault handlers return structured JSON on error. Both URLs saved.

📊 Section 6: Phase 6 & 7 — Build the GL Agent Integrations

Now we build two integrations for the General Ledger module. The GL Agent will use these to answer account balance queries and journal posting status queries. The GL module in Fusion uses different REST endpoints than AP or AR, so pay close attention to the endpoint paths.

⚙️ Phase 6: Build GET_GL_ACCOUNT_BALANCE Integration

1
Create the Integration Inside the Project
Project → Integrations tab → Create → Application type:
Name : GET_GL_ACCOUNT_BALANCE
Description : Returns GL account balance from Fusion for a given account number and period
Click Create.

✅ Expected Result: Blank integration canvas opens.
2
Configure REST Trigger
Trigger → REST Adapter → Configure:
Endpoint Name : GetGLAccountBalance
Relative URL : /gl/account/balance
Method : POST
Request JSON : { "account_number": "1001", "period": "JUN-26" }
Response JSON : { "account_number":"", "account_name":"",
"period":"", "beginning_balance":0,
"period_activity":0, "ending_balance":0,
"currency":"", "period_status":"", "message":"" }
Click Done.

Note on the period field: We accept period as a string (e.g., "JUN-26"). If the user says "June 2026", the GL Agent prompt template will standardise it to "JUN-26" before calling the tool.

✅ Expected Result: Trigger on canvas with path /gl/account/balance.
3
Add Oracle Applications Adapter — Fusion GL
+ → Invoke → Oracle Applications Adapter → Select FUSION-FINANCE-CONN:
Module : Financials → General Ledger → Balances
Operation : GET /ledgerBalances
Filters : AccountCombination={account_number} AND PeriodName={period}
Click Done.

Important Note for Beginners: The Fusion GL Balances API uses a "Chart of Accounts" structure. The account_number you pass (e.g., "1001") maps to a segment in Fusion's account combination. Check with your Fusion administrator what segment value the GL Agent should receive — it may need to be the full combination like "01-1001-0000-000".

✅ Expected Result: Canvas shows Trigger → GL Balance Invoke.
4
Map Response — 9 SUMMARY Fields
Response mapper — map only these 9 fields:
account_number ← AccountCombination
account_name ← AccountDescription
period ← PeriodName
beginning_balance ← BeginningBalance
period_activity ← PeriodActivity
ending_balance ← EndingBalance
currency ← LedgerCurrency
period_status ← PeriodStatus (Open / Closed / Future)
message ← "" (fault handler fills this)
Click Validate → Close.

✅ Expected Result: 9-field mapping validated. No errors.
5
Add Fault Handler, Activate, and Test
Fault Handler → Assign → Set:
account_number = $account_number (from request)
ending_balance = 0
message = concat("GL Account ", $account_number, " not found for period ", $period)
Save → Activate (Audit) → Test:
POST to /gl/account/balance with body {"account_number":"1001","period":"JUN-26"}

✅ Expected Result: HTTP 200. 9-field SUMMARY JSON with real Fusion GL balance data. Copy the REST URL.

⚙️ Phase 7: Build GET_JOURNAL_STATUS Integration

This integration answers "has the June journal been posted?" — it queries GL journal batch status in Fusion.

Step 1 — Create Integration
Project → Integrations → Create → Application → Name: GET_JOURNAL_STATUS → Description: "Returns Fusion GL journal batch posting status for a given journal name or period"
Step 2 — REST Trigger
Path: /gl/journal/status | POST | Request: {"journal_name":"JUN-2026-ACCRUALS","period":"JUN-26"} | Response: {"journal_name":"","period":"","status":"","total_debits":0,"total_credits":0,"posted_by":"","posted_date":"","message":""}
Step 3 — Fusion GL Invoke
Oracle Applications Adapter → FUSION-FINANCE-CONN → Module: Financials → General Ledger → Journals → GET /journals → Filter: Name={journal_name} AND PeriodName={period}
Step 4 — Response Mapping (8 fields)
journal_name ← JournalName | status ← Status (Posted/Draft/Error) | total_debits ← TotalAccounting Debits | total_credits ← TotalAccountingCredits | posted_by ← PostedByUsername | posted_date ← PostedDate
Step 5 — Fault Handler, Activate, Test
Fault Handler → status="NOT_FOUND" → message=concat("Journal ", $journal_name, " not found for period ", $period) → Activate → Test with a real journal name → Confirm 8-field SUMMARY → Copy URL.
✅ ALL 6 Integrations Checkpoint — Before Continuing:
☑ GET_AP_INVOICE_STATUS — Active, Tested, URL saved
☑ GET_AP_PAYMENT_STATUS — Active, Tested, URL saved
☑ GET_AR_CUSTOMER_BALANCE — Active, Tested, URL saved
☑ GET_AR_INVOICE_STATUS — Active, Tested, URL saved
☑ GET_GL_ACCOUNT_BALANCE — Active, Tested, URL saved
☑ GET_JOURNAL_STATUS — Active, Tested, URL saved
All 6 return SUMMARY JSON. All 6 have fault handlers. All 6 URLs in your notepad.

🔧 Section 7: Phase 8 — Register All 6 Tools in AI Agent Studio

With all 6 integrations built and tested, we now register them as Tools in OIC Gen3 AI Agent Studio. A Tool is the bridge between the agent brain and the OIC integration. The agent reads the tool description to decide when to call it. The tool then executes the OIC integration and returns the SUMMARY data.

💡 Register All Tools Before Creating Any Agent. Agents are configured by selecting from the tool registry. If a tool is not registered yet when you create the agent, you cannot assign it. Register all 6 tools now, then create all 3 Sub-Agents.
Tool Name Domain Classification OIC Integration Behind It
get_ap_invoice_statusAP🟢 READGET_AP_INVOICE_STATUS
get_ap_payment_statusAP🟢 READGET_AP_PAYMENT_STATUS
get_ar_customer_balanceAR🟢 READGET_AR_CUSTOMER_BALANCE
get_ar_invoice_statusAR🟢 READGET_AR_INVOICE_STATUS
get_gl_account_balanceGL🟢 READGET_GL_ACCOUNT_BALANCE
get_journal_statusGL🟢 READGET_JOURNAL_STATUS

📋 How to Register Each Tool — Step by Step

The steps below show the full registration for get_ap_invoice_status. Repeat the same steps for all 6 tools — just change the name, description, endpoint, and parameters accordingly.

1
Navigate to AI Agent Studio → Tools → Create Tool
OIC Gen3 console → Left menu → AI Agent Studio → Click Tools tab → Click Create Tool.

✅ Expected Result: Tool creation form opens with: Name, Description, Classification, OIC Endpoint, HTTP Method, Parameters fields.
2
Enter the Tool Configuration
"name" : "get_ap_invoice_status",
"description" : "Retrieves the status of a Fusion Accounts Payable invoice
by invoice number. Returns: invoice status, supplier,
amount, currency, invoice date, payment due date, and
hold reason. Use when user asks about AP invoice status,
whether an invoice is approved, or why it is on hold.
Do NOT use for payment dates — use get_ap_payment_status.",
"classification": "READ",
"oicEndpoint" : "[PASTE GET_AP_INVOICE_STATUS REST URL HERE]",
"httpMethod" : "POST",
"timeout_seconds": 30,
"retry_on_failure": true,
"max_retries" : 2
3
Add the Parameter Schema
Click Add Parameter:
Name : invoice_number
Type : string
Required : true
Description : "Fusion AP invoice number, e.g. INV100234. Always uppercase. No spaces."
Click Save Tool.

✅ Expected Result: Tool appears in Tools list with name get_ap_invoice_status and classification READ. Test it from the test panel — confirm it returns the 9-field AP SUMMARY JSON.

📋 Tool Descriptions for All 6 Tools — Copy These Exactly

The description is the most important part. Copy these precisely — they are carefully written to prevent the LLM from calling the wrong tool.

// TOOL 1 — AP
get_ap_invoice_status: "Retrieves Fusion AP invoice status by invoice number. Returns status, supplier, amount, dates, hold reason. Use when user asks about AP invoice approval, hold, or rejection. Do NOT use for payment schedule queries."
Parameters: invoice_number (string, required)

// TOOL 2 — AP
get_ap_payment_status: "Retrieves Fusion AP payment schedule and payment status for an invoice. Returns payment date, payment amount, bank account. Use when user asks when a supplier will be paid or if payment has been made. Do NOT use for invoice approval status."
Parameters: invoice_number (string, required)

// TOOL 3 — AR
get_ar_customer_balance: "Retrieves total outstanding AR balance for a customer from Fusion. Returns total outstanding, overdue amount, currency, credit limit. Use when user asks about customer balance, how much a customer owes, or total receivables from a customer."
Parameters: customer_name (string, required)

// TOOL 4 — AR
get_ar_invoice_status: "Retrieves status of a specific customer-facing AR invoice from Fusion. Returns invoice status, due date, days overdue, amount. Use when user asks about a specific AR invoice, whether it is overdue, or its payment status."
Parameters: ar_invoice_number (string, required)

// TOOL 5 — GL
get_gl_account_balance: "Retrieves GL account balance from Fusion for a given account number and accounting period. Returns beginning balance, period activity, ending balance, period status. Use when user asks about a GL account balance or ledger balance for a period. Period format: MMM-YY e.g. JUN-26."
Parameters: account_number (string, required), period (string, required — format MMM-YY)

// TOOL 6 — GL
get_journal_status: "Retrieves GL journal batch posting status from Fusion. Returns journal status (Posted/Draft/Error), posted by, posted date, total debits and credits. Use when user asks about journal posting status or whether a journal has been posted. Requires journal name and period."
Parameters: journal_name (string, required), period (string, required)
✅ Tools Checkpoint: All 6 tools registered in AI Agent Studio. Each tested from the test panel. All 6 return correct SUMMARY JSON. The Tools list shows 6 entries all with classification READ.

📝 Section 8: Phase 9 — Write All 4 Prompt Templates

We write 4 prompt templates — one for each Sub-Agent (AP, AR, GL) and one for the Finance Supervisor. Write them in a text editor. Save each as a separate .txt file. Upload all 4 to OCI Object Storage bucket "finance-agent-templates".

💡 Naming Convention for Prompt Files: Use clear version-controlled names.
ap_agent_prompt_v1.0.txt  |  ar_agent_prompt_v1.0.txt  |  gl_agent_prompt_v1.0.txt  |  supervisor_prompt_v1.0.txt

📝 AP Agent Prompt Template — ap_agent_prompt_v1.0.txt

## IDENTITY
You are AP-Bot, an Oracle Fusion Accounts Payable specialist at InfraGroup India.
You answer questions about supplier invoices and AP payments only.
Session: {{session_id}} | User: {{user_name}} | Date: {{current_date}}

## MANDATE
You ONLY handle Accounts Payable queries: invoice status, payment status,
supplier holds, and AP validation. You do NOT handle AR or GL queries.
If asked about AR or GL, reply: "This is outside my AP domain."

## TOOLS YOU HAVE
get_ap_invoice_status — use for invoice approval status, holds, and validation
get_ap_payment_status — use for payment date, payment confirmation, bank payment

## HARD RULES
RULE 1: ALWAYS call a tool before answering. NEVER invent invoice data.
RULE 2: If invoice_number is missing from the query, ask for it before calling any tool.
RULE 3: Standardise invoice numbers to uppercase with no spaces before calling tools.
RULE 4: Format amounts with commas and currency code: INR 1,24,500 not 124500.
RULE 5: If tool returns NOT_FOUND, tell user clearly. Do not guess why.

## REASONING STEPS
1. Identify: is this an invoice status or payment status query?
2. Extract and clean the invoice number.
3. Call the correct tool.
4. Compose a short, clear business response using only tool data.

## TASK IS COMPLETE WHEN
You have called the tool and returned a response in the required output format.

## OUTPUT FORMAT
📄 AP — {{invoice_number}}
Supplier : {{supplier_name}}
Amount : {{currency}} {{amount}}
Status : {{status}}
Payment Due : {{payment_due_date}}
{{one_line_summary}}

📝 AR Agent Prompt Template — ar_agent_prompt_v1.0.txt

## IDENTITY
You are AR-Bot, an Oracle Fusion Accounts Receivable specialist at InfraGroup India.
You answer questions about customer balances and customer invoices only.
Session: {{session_id}} | User: {{user_name}} | Date: {{current_date}}

## MANDATE
You ONLY handle Accounts Receivable queries: customer balances, overdue amounts,
customer invoice status, and credit limits. You do NOT handle AP or GL queries.

## TOOLS YOU HAVE
get_ar_customer_balance — use for total outstanding, overdue amounts, credit status
get_ar_invoice_status — use for a specific customer invoice status or overdue check

## HARD RULES
RULE 1: ALWAYS call a tool before answering. NEVER invent AR data.
RULE 2: If question is about a customer balance, use get_ar_customer_balance.
RULE 3: If question is about a specific AR invoice number, use get_ar_invoice_status.
RULE 4: If overdue_amount > 0, clearly highlight this in your response.
RULE 5: Format all amounts with commas and currency code.

## TASK IS COMPLETE WHEN
You have called one tool and returned a response in the required output format.

## OUTPUT FORMAT (Customer Balance)
🏦 AR Balance — {{customer_name}}
Total Outstanding : {{currency}} {{total_outstanding}}
Overdue Amount : {{currency}} {{overdue_amount}}
Credit Limit : {{currency}} {{credit_limit}}
{{one_line_collection_action_if_overdue}}

📝 GL Agent Prompt Template — gl_agent_prompt_v1.0.txt

## IDENTITY
You are GL-Bot, an Oracle Fusion General Ledger specialist at InfraGroup India.
You answer questions about GL account balances and journal posting status only.
Session: {{session_id}} | User: {{user_name}} | Date: {{current_date}}

## MANDATE
You ONLY handle General Ledger queries: account balances, period status,
and journal posting. You do NOT handle AP or AR queries.

## TOOLS YOU HAVE
get_gl_account_balance — use for account balance, period activity, period open/closed
get_journal_status — use for journal posting status, posted by, posted date

## HARD RULES
RULE 1: ALWAYS call a tool. NEVER guess GL balances or journal status.
RULE 2: Standardise period to MMM-YY format before calling tools.
"June 2026" → "JUN-26" | "June" → "JUN-26" (use current year)
RULE 3: If period_status = Closed, note this clearly — it affects entry permissions.
RULE 4: Always show beginning balance, activity, and ending balance together.

## TASK IS COMPLETE WHEN
You have called one tool and returned a response in the required output format.

## OUTPUT FORMAT (Account Balance)
📊 GL — Account {{account_number}} | Period {{period}}
Account Name : {{account_name}}
Opening Balance : {{currency}} {{beginning_balance}}
Period Activity : {{currency}} {{period_activity}}
Closing Balance : {{currency}} {{ending_balance}}
Period Status : {{period_status}}
{{one_line_note_if_period_closed}}

📋 Upload All 4 Prompt Templates to OCI Object Storage

Step 1 — OCI Console → Object Storage → Bucket "finance-agent-templates" → Click Upload.
Step 2 — Upload all 4 files: ap_agent_prompt_v1.0.txt, ar_agent_prompt_v1.0.txt, gl_agent_prompt_v1.0.txt, supervisor_prompt_v1.0.txt.
Step 3 — Click each file → Copy its Object URL → Save in your notepad under the agent name.
Step 4 (Supervisor template) — We write the Supervisor prompt template in Section 11, after the three Sub-Agents are built. For now upload the 3 Sub-Agent templates only.

Comments