📋 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:
"When will supplier Acme get paid?"
"Why is our invoice on hold?"
"Is customer invoice AR-5521 overdue?"
"What is the total AR outstanding?"
"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."
| Query Type | Before (Manual) | After (Multi-Agent) |
|---|---|---|
| AP Invoice Status | Login to AP → Search → Read → Reply: 5 min | AP Agent fetches and responds: <10 seconds |
| AR Customer Balance | Login to AR → Search → Export → Reply: 8 min | AR Agent fetches and responds: <10 seconds |
| GL Account Balance | Login to GL → Navigate → Note → Reply: 7 min | GL Agent fetches and responds: <10 seconds |
| Finance Health Check | Login to all 3 modules → Compile manually: 45 min | Supervisor 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.
📦 Everything We Will Build — In Build Order
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.
What you will see: A dialog box asking for Project Name, Description, and optionally a team.
✅ Expected Result: A "Create Project" dialog opens.
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.
Configure the connection:
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.
Visibility : Private
✅ 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.
⚙️ Phase 2: Build GET_AP_INVOICE_STATUS Integration
Description: Fetches AP invoice status from Fusion for a given invoice number
✅ Expected Result: Blank integration canvas opens inside the project.
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":"" }
✅ Expected Result: Trigger appears on canvas. REST endpoint path shows
/ap/invoice/status.
Operation : GET /payablesInvoices (query by InvoiceNumber)
Query Param: q=InvoiceNumber={invoice_number}
✅ Expected Result: Canvas shows: REST Trigger → Fusion AP Invoke. A mapping icon appears between them.
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.
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)
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.
status = "NOT_FOUND"
message = concat("AP Invoice ", $invoice_number, " not found.")
// All other fields = ""
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.
Project → Integrations → Create → Application type → Name:
GET_AP_PAYMENT_STATUS → Description: "Returns Fusion AP payment schedule for a given invoice number"
REST Trigger → Relative URL:
/ap/payment/status → POST → Request: {"invoice_number":""} → Response: {"invoice_number":"","payment_status":"","payment_date":"","payment_amount":0,"bank_account":"","message":""}
Oracle Applications Adapter → Connection: FUSION-FINANCE-CONN → Module: Financials → Payables → Payments → Operation: GET /payablesPayments → Filter by InvoiceNumber
payment_status ← PaymentStatus | payment_date ← PaymentDate | payment_amount ← PaymentAmount | bank_account ← BankAccountNumber (last 4 digits only for security)
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.
🏦 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
Description : Returns total outstanding AR balance for a given customer name or number
✅ Expected Result: Blank integration canvas opens inside the project.
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":"" }
✅ Expected Result: Trigger added to canvas with path
/ar/customer/balance.
Operation : GET /receivablesCustomerAccountSites
Or use : GET /receivablesTransactions with customer filter
Filter : CustomerName = {customer_name}
Click Done.
✅ Expected Result: Canvas shows REST Trigger → Fusion AR Invoke.
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)
✅ Expected Result: 8-field response mapping validated successfully.
total_outstanding = 0
message = concat("Customer ", $customer_name, " not found in AR.")
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.
Project → Integrations → Create → Application → Name:
GET_AR_INVOICE_STATUS → Description: "Returns AR customer invoice status from Fusion for a given AR invoice number"
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":""}
Oracle Applications Adapter → FUSION-FINANCE-CONN → Module: Financials → Receivables → Transactions → GET /receivablesTransactions → Filter: TransactionNumber = {ar_invoice_number}
ar_invoice_number ← TransactionNumber | customer_name ← CustomerName | amount ← OriginalAmount | due_date ← DueDate | status ← Status | days_overdue ← DaysLate (calculated from DueDate vs today)
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.
📊 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
Description : Returns GL account balance from Fusion for a given account number and period
✅ Expected Result: Blank integration canvas opens.
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":"" }
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.
Operation : GET /ledgerBalances
Filters : AccountCombination={account_number} AND PeriodName={period}
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.
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)
✅ Expected Result: 9-field mapping validated. No errors.
ending_balance = 0
message = concat("GL Account ", $account_number, " not found for period ", $period)
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.
Project → Integrations → Create → Application → Name:
GET_JOURNAL_STATUS → Description: "Returns Fusion GL journal batch posting status for a given journal name or period"
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":""}
Oracle Applications Adapter → FUSION-FINANCE-CONN → Module: Financials → General Ledger → Journals → GET /journals → Filter: Name={journal_name} AND PeriodName={period}
journal_name ← JournalName | status ← Status (Posted/Draft/Error) | total_debits ← TotalAccounting Debits | total_credits ← TotalAccountingCredits | posted_by ← PostedByUsername | posted_date ← PostedDate
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.
☑ 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.
| Tool Name | Domain | Classification | OIC Integration Behind It |
|---|---|---|---|
get_ap_invoice_status | AP | 🟢 READ | GET_AP_INVOICE_STATUS |
get_ap_payment_status | AP | 🟢 READ | GET_AP_PAYMENT_STATUS |
get_ar_customer_balance | AR | 🟢 READ | GET_AR_CUSTOMER_BALANCE |
get_ar_invoice_status | AR | 🟢 READ | GET_AR_INVOICE_STATUS |
get_gl_account_balance | GL | 🟢 READ | GET_GL_ACCOUNT_BALANCE |
get_journal_status | GL | 🟢 READ | GET_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.
✅ Expected Result: Tool creation form opens with: Name, Description, Classification, OIC Endpoint, HTTP Method, Parameters fields.
"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
Type : string
Required : true
Description : "Fusion AP invoice number, e.g. INV100234. Always uppercase. No spaces."
✅ 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.
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)
📝 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".
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
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
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
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}}
Comments
Post a Comment