🏆 Milestone

Simform - Global Finalist at the 2026 Microsoft Partner of the Year Awards

Our work on AI agents in field operations was recognized in the Innovate with Azure AI Apps and Agents category.

Read More

Summarize with AI

Not enough time? get the key points instantly.

Simform’s engineering team ran one accounts-payable job on three Microsoft Foundry agent options (a prompt agent, the Copilot harness and a hosted agent we wrote) at three sizes, up to 275 files. Through the findings, we were able to conclude that Copilot harness suits messy inputs and processes a team has not yet written down, and a hosted agent with long-running resilience suits a known process that runs at volume.

Getting an agent to reason well over a single document is now routine work for many engineering teams. The harder problem begins when an agent has to work for ten minutes or more across hundreds of files in different formats, reconcile them against several ledgers, and then take an action in another system that cannot be taken back. At that point the agent stops looking like a chatbot and starts looking like a data pipeline, with the same requirements around ingestion, schema, validation and safe writes. 

Microsoft Foundry Agent Service now gives teams managed building blocks for that kind of work. The Microsoft Copilot harness, in public preview since October 2026, runs the agent loop and gives the agent a sandbox where it can read files and execute code. Long-running resilience, generally available for hosted agents, restarts interrupted work from the progress the agent has saved. How dependable the finished system is then comes down to the engineering decisions a team makes on top of those blocks. 

To test those decisions under realistic pressure, our team gave one invoice reconciliation job to three Foundry agent options, at sizes ranging from a 40-file month-end packet to a 275-file backlog. This article covers what we built, what each option did with the job, and the design lessons that carry over to any long, multi-source agentic workload on Microsoft’s stack. 

Why reconciliation makes a fair test for an agent

Invoice reconciliation is a finance task built entirely from data engineering problems. Invoices arrive as PDFs, CSV exports, Excel sheets and scans with no text layer, so ingestion has to cope with mixed formats. Every document has to be normalized into one record before anything can be compared. Vendors appear under several spellings, which turns matching into an entity resolution problem, and duplicates hide behind small changes to invoice numbers. The final step, emailing a vendor about a problem, writes to an outside system where a mistake is visible and permanent. 

The job also has exact answers, which let us score every run automatically. Our quarter-end packet held 110 files, made up of 104 invoices, 2 credit notes and four ledgers covering the vendor master, purchase orders, goods received and payments. We planted 17 problems in it and computed the correct result for each in code before any agent ran.

Planted problem  Count  Correct action 
Duplicate invoice (suffix added, hyphen dropped, or resubmitted with an “R”)  3  Email the vendor 
Invoice currency differs from the purchase order  3  Email the vendor 
Unit price above the purchase order price  2  Email the vendor 
Quantity billed above quantity received  1  Email the vendor 
Remit-to bank account differs from the vendor master  1  Email the vendor 
Partial payment with an open balance  3  Record, no email 
Credit note that reduces the amount due  2  Record, no email 
Look-alike company that is not an approved vendor  2  Record, no email 

Three ways to run the same job on Foundry

All three options ran inside one Foundry project and shared its model deployment (gpt-5.4-mini, Global Standard, in Sweden Central), its Files API and its agent identity. Each received the same packet and the same instructions, so the differences in the results come from how each option runs the work. 

Option  Who runs the agent loop  How it reaches the mailbox 
Prompt agent  Foundry, as a single reasoning loop over declared tools  An MCP tool connection whose send tool requires approval 
Prompt agent on the Copilot harness  Foundry’s managed harness, with a sandbox for files and code  The same MCP connection and approval rule 
Hosted agent we wrote  Our own code, deployed to Foundry with long-running resilience  Our code queues each approval through the mailbox 

 

One rule governed actions in every option. An email goes out only when a vendor needs to act, when that vendor has not already been emailed in the run, and when a person has approved the message. Partial payments, credit notes and unknown vendors go into the run summary without an email. 

[Visual 1. Architecture of the Foundry components and the path each vendor email takes] 

How the Copilot harness, a prompt agent and a hosted agent compared

On the 110-file quarter-end close, the Copilot harness caught all 17 planted problems, our hosted agent caught 15 with zero false alarms, and the prompt agent did not return findings at this size. The quarter-end close gives the clearest comparison, because it is large enough to need real orchestration and small enough to inspect by hand.

Measure  Prompt agent  Copilot harness  Our hosted agent 
Planted problems caught (of 17)  0  17  15 
False alarms  0  0  0 
Invoices read correctly (of 104)  0  104  103 
Vendors emailed correctly (of 8)  0  8  8 
Time per run  27 s  8.3 min  3.8 min 
Tokens per run  18K  1.83M  41K 
Estimated cost per run  $0.02  $1.59  $0.12 

One run per option on 24 November 2026, using synthetic data and fictional vendors. Costs are estimates at Microsoft’s published rates, explained in the cost section below. 

The Copilot harness completed the full close with every check correct and every email routed to the right vendor. Our hosted agent reached the same email outcome and missed two planted problems, both in reading documents, at under a tenth of the harness’s estimated cost and in less than half its run time. The prompt agent loaded the packet and the ledgers but did not return findings at this size, which marks the point where a task has outgrown a single reasoning loop and is ready for one of the other two options. 

On the 275-file backlog, the harness and our hosted agent both caught all 17 planted problems, and on the 40-file month-end packet each caught 8 of 9. No option emailed any vendor twice in any run.

Both successful agents converged on one design

We designed our hosted agent around a clear division of labour, with the model reading documents and judging names while code handles every calculation and ledger match. When we gave the harness the same job, it arrived at the same split on its own, which gave us independent confirmation that the design holds up. 

Given a sandbox and a packet of mixed files, the harness wrote a Python script that turned every PDF, CSV and Excel invoice into one common record, holding the issuer, invoice number, invoice date, purchase order reference, currency, remit-to account, line items and total due. For scanned invoices, the same script ran the open-source OCR engine Tesseract on the page images inside the sandbox. It then ran the three-way match as ordinary code. This is the matching step from that script, unedited, taken from the 26th of 34 shell commands in the quarter-end run.

if r[‘currency’] != po[‘currency’]: 
    r[‘issues’].append((‘currency_mismatch’, f”invoice {r[‘currency’]}, PO {po[‘currency’]}”)) 
vm=vendor_master[r[‘vendor_id’]] 
if r[‘remit_to_account’] and r[‘remit_to_account’] != vm[‘remit_to_account’]: 
    r[‘issues’].append((‘bank_details_changed’, f”invoice {r[‘remit_to_account’]}, master {vm[‘remit_to_account’]}”)) 
for li in r[‘lines’]: 
    pol=po_line_by_po_desc.get((r[‘po_reference’], li[‘description’])) 
    if not pol: 
        continue 
    if li[‘unit_price’] != pol[‘unit_price’]: 
        r[‘issues’].append((‘price_variance’, f”{li[‘description’]} invoice {li[‘unit_price’]}, PO {pol[‘unit_price’]}”)) 
    received=qty_received_by_po_line.get((r[‘po_reference’], pol[‘line’])) 
    if received is not None and li[‘qty’] > received: 
        r[‘issues’].append((‘quantity_not_received’, f”invoiced {li[‘qty’]}, received {received}”))

Our hosted agent applies the same split through explicit code. The model reads each document into the common record, which in our agent also carries the document type, subtotal, VAT and the invoice a credit note refers to, and it judges whether two vendor names refer to the same company. Code then calculates any total a document does not print and runs every ledger match. With that design, the agent raised zero false alarms on the quarter-end packet and emailed every vendor correctly at every packet size. 

The rules in that code are the standard accounts-payable three-way match, which checks each invoice against its purchase order, the goods received and the vendor master, with added checks for partial payments, credit notes and duplicates. 

The split between model judgment and code applies well beyond invoices. AI models are good at reading messy documents and at making calls where the answer isn’t clear cut. Sums, lookups and business rules work better in code, because code gives the same exact answer every time and costs almost nothing to run. The harness gets there by writing its own code, and a hosted agent lets your team write that code and decide every rule.

Which matches an agent should never guess

Every enterprise agent eventually has to decide whether two records refer to the same thing, whether that is a vendor, a customer, a patient or a product. A wrong guess here raises no error and just pays, emails or updates the wrong party, which makes identity the place where fixed rules matter most. 

We built our hosted agent to settle identity in two layers. Code first matches each vendor name on an invoice against the vendor master exactly, ignoring case and punctuation. Only the names that fail that check go to the model, along with the vendor that owns the invoice’s PO number and a clear instruction that a different company with a similar name is unknown. This caught both look-alike companies in every run, and the names it still flagged on the largest packet were spelling variants of one real vendor, which a maintained alias table resolves for good. 

The practical takeaway for any team is to treat identity rules as data. Keep exact-match rules for names and reference numbers, along with the approved alias list, in code or in a versioned skill that the Copilot harness loads on every run. Every run then applies the same rules, and a reviewer can audit them in one place. 

Letting an agent act on outside systems safely

Everything covered so far happens inside the agent’s own workspace. Reading files, matching records and checking rules can run again as often as needed without harming anything. The moment an agent emails a vendor, posts a payment or updates a record in another system, a mistake reaches someone outside the team and cannot be taken back. At that point any agent needs two guarantees, that a person approves each action and that no action ever happens twice. We built both on Foundry with four pieces, each described below. 

Approval belongs on the one tool with a side effect. Foundry lets you set approval per tool on the MCP connection, so lookups such as the list of sent emails run freely while every outgoing message waits for sign-off. 

“require_approval”: { 
  “always”: {“tool_names”: [“send_vendor_email”]}, 
  “never”: {“tool_names”: [“list_sent_emails”]} 
} 

The Foundry portal trace shows this in action. Foundry held the harness’s call to email Contoso Freight about a duplicate invoice until a person had reviewed the vendor, subject and body, and the email went out 25 seconds later. 

[Visual 2. Foundry trace of the harness pausing at the email approval, run ucr-B-1125110455, 25 November 2026] 

To prevent duplicates, each agent checks the mailbox’s list of emails already sent before every send, and each email carries an idempotency key built from the run ID and the vendor ID, the same technique data engineers use to make pipeline writes safe to repeat. Our hosted agent also saves a checkpoint after each batch of documents, after the checking step and after each email, so Foundry’s long-running resilience can restart it from the last completed step. Because the sent-list check runs before every send, even a crash between sending an email and saving its checkpoint cannot produce a second email. 

A final check keeps actions in line with findings. On the 275-file backlog, the harness listed every affected vendor in its final answer and requested emails for 6 of the 8 that needed contact. A short closing step that compares those vendors with the sent list, and queues any that are missing for approval, keeps the two in step on every run. 

Configuring Foundry for long runs and large packets

Scaling from 40 files to 110 and 275 brought out a set of configuration steps that any team running long agent jobs on Foundry should build in from the start. 

  1. Give the agent’s identity access to its files. Every Foundry agent has its own Microsoft Entra identity. Assigning it the Foundry User role on the project lets files attached by ID stage into the harness workspace under ./data/. Allow about five minutes for the role assignment to take effect, and upload files with the purpose assistants. 
  2. Run long turns in background mode. The harness’s first turn on the quarter-end packet took six minutes, so we submitted each turn in background mode and polled for the result. Any turn expected to run beyond about five minutes should be handled this way. 
  3. Size the tokens-per-minute limit for how the harness works. The harness explores the files, writes code and checks its own output, which uses tokens quickly. On the quarter-end packet it needed more than our original 100K limit, and at 500K it ran cleanly. On a pay-per-token deployment, a higher limit adds no cost by itself. 
  4. Package large inputs for Code Interpreter. A prompt agent’s Code Interpreter took 50 attached files in one request, so larger packets should go in as a single zip archive. 
  5. Send scanned documents to a model that can see them. The harness handled scans with OCR in its sandbox. In our hosted agent, we pass PDFs to the model as document inputs, and it read the month-end scan exactly, including invoice number, PO, line and total. 

These steps reflect the Copilot harness preview as we used it in November 2026, and the details may change as the service moves toward general availability. 

Where the tokens go, and why the harness gets more efficient with volume

Token consumption is the most useful way to compare a prompt agent, the Copilot harness and a hosted agent on Foundry. It drives both what a deployment costs and how much model quota it needs, and it grows with every run a team adds. The Copilot harness and our hosted agent, the two options that completed the job, consumed tokens in very different ways. 

The Copilot harness spends a large and fairly steady share of its tokens working out an approach and writing its processing script, and then applies that script to every file in bulk. Its total stayed between 1.4 and 1.8 million tokens whether the packet held 36 invoices or 269, so its consumption per invoice fell from about 38,000 tokens to about 6,000 as the packet grew. Our hosted agent, whose approach is already written in code, spends tokens only on reading documents and judging names, and used a steady 400 or so tokens per invoice at every size. 

The token curves of the Copilot harness and a hosted agent lead to a practical rule. The harness becomes more efficient as batches grow and inputs get messier, and a hosted agent is the leaner choice once the process is understood and runs repeatedly, using under a fortieth of the harness’s tokens on the quarter-end close. 

For teams that want to turn tokens into a budget, gpt-5.4-mini on Global Standard is priced at $0.75 per million input tokens and $4.50 per million output tokens, and harness sandbox compute is billed from 1 December 2026 at $0.0994 per vCPU-hour and $0.0118 per GiB-hour. Prices vary by region and agreement. 

Choosing between a prompt agent, the Copilot harness and a hosted agent

A prompt agent, the Copilot harness and a hosted agent are steps on one ladder of control on Foundry, and the shape of the job decides which step to start from. These are the signals we would use.

If the workload looks like this  Start with  Why it fits 
Clean, well-structured inputs, a fixed set of checks, and answers needed in seconds  A prompt agent  Fastest to configure and run, with the lowest token use of the three options 
Mixed formats, scanned documents, rules that need interpretation, or a process your team has not yet written down  A prompt agent on the Copilot harness  It works out its own approach, writes and runs its own code, and checks its results with no orchestration code to maintain, and it caught 17 of 17 on the quarter-end close 
A known, repeatable process at volume, actions that must never repeat, and cost under tight control  A hosted agent with long-running resilience  Your team owns every step, rule and checkpoint, at about a tenth of a cent per invoice in our runs 

Two further points matter as much as the choice of option. 

The Copilot harness and a hosted agent work well in sequence. Because the harness writes a working script for the process it is given, it is an effective way to discover how a messy, undocumented process should be broken into stages. Once that structure is clear and stable, the rules it applied can move into a versioned skill the harness loads on every run, or into a hosted agent that runs them at a fraction of the token cost with checkpoints your team controls. 

The decisions that make an agent trustworthy are the same for every option. What needs approval, what must never happen twice, which identity rules are fixed, and what a person sees when the agent pauses should be designed first, because they carry over unchanged whichever option ends up running the work. 

Building your next long-running agent on Foundry

Every long-running enterprise agent, whether it validates a data migration, triages support cases or reconciles records across systems, faces the same three design decisions we worked through here. Teams have to decide which parts of the job need the model’s judgment, which parts should run as code, and which actions need a person’s sign-off before they reach another system. 

Our answer is to let the model read and judge while code or a versioned skill owns the calculations and matching rules. Approval belongs only on actions with side effects, and each of those actions should be safe to repeat. 

On Microsoft Foundry, the Copilot harness can work out that structure for a messy, undocumented process on its own by writing the processing script itself, and a hosted agent with long-running resilience is the way to run it at volume once the structure is settled. Foundry supplies the managed loop, the sandbox, per-tool approvals and resilience. The data engineering decisions a team makes on top of those pieces are what turn a capable agent into a dependable system. 

Ritesh Shah is Field CTO at Simform, where he works with enterprise leaders on AI, cloud, modernization, and digital transformation initiatives. He brings 20+ years of experience spanning enterprise architecture, technology strategy, and large-scale transformation programs.

Sign up for the free Newsletter

For exclusive strategies not found on the blog

Revisit consent button
How we use your personal information

We do not collect any information about users, except for the information contained in cookies. We store cookies on your device, including mobile device, as per your preferences set on our cookie consent manager. Cookies are used to make the website work as intended and to provide a more personalized web experience. By selecting ‘Required cookies only’, you are requesting Simform not to sell or share your personal information. However, you can choose to reject certain types of cookies, which may impact your experience of the website and the personalized experience we are able to offer. We use cookies to analyze the website traffic and differentiate between bots and real humans. We also disclose information about your use of our site with our social media, advertising and analytics partners. Additional details are available in our Privacy Policy.

Required cookies Always Active

These cookies are necessary for the website to function and cannot be turned off.

Optional cookies

Under the California Consumer Privacy Act, you may choose to opt-out of the optional cookies. These optional cookies include analytics cookies, performance and functionality cookies, and targeting cookies.

Analytics cookies

Analytics cookies help us understand the traffic source and user behavior, for example the pages they visit, how long they stay on a specific page, etc.

Performance cookies

Performance cookies collect information about how our website performs, for example,page responsiveness, loading times, and any technical issues encountered so that we can optimize the speed and performance of our website.

Targeting cookies

Targeting cookies enable us to build a profile of your interests and show you personalized ads. If you opt out, we will share your personal information to any third parties.