Workflow Orchestration · Docker sandbox harness

Bulk Invoice and Contract Review with Human Approval

A Python application uses the OpenAI Agents API to delegate invoices and contracts to specialist subagents, apply a shared accounts-payable policy, validate JSON reports, and leave payment or contract decisions to a person.

Evidence DocumentedAgent OpenAI Agents API document-review exampleHarness Docker sandbox harnessAdded 1 Dec 2026

What This Workflow Does

Mounts invoice and contract inputs alongside a reusable accounts-payable policy skill; the inputs and skill are read-only while the output directory is writable.

Coordinates specialist subagents to apply the policy to each document and write individual JSON reports plus a consolidated summary.

Checks invoice arithmetic from extracted line items and shipping, then presents the reports and recommendations for human review.

Exports retained command activity to a separate JSON file before session cleanup; reports remain in the output directory.

Written for Accounts-payable and contract reviewers. Goal: Workflow Orchestration.

Agent, Harness & Requirements

The workflow runs on OpenAI Agents API document-review example inside a Docker sandbox harness. File, shell, and browser access are contained inside an isolated container or virtual machine.

  • Python 3.14+ and uv.
  • A self-hosted Docker sandbox or compatible third-party sandbox provider.
  • An OpenAI API key and a separate restricted executor key with the documented environment-connect permission and network access; the keys must share an owner, organization, and project.
  • Input documents and a review-policy skill mounted in the workspace; the example includes sample invoice and contract documents.

How It Works

  1. Copy the example .env.example, build the documented sandbox image, and set OPENAI_API_KEY and OPENAI_EXECUTOR_API_KEY.
  2. Run the example Python application on an input directory with a separate output directory.
  3. Create an Agents API session configured for multi-agent delegation, mount the input and policy directories read-only, and allow writes only to the output directory.
  4. Follow subagent and output events; validate that each source document has a report and validate each report before presenting it.
  5. Have a person verify extracted amounts and review recommendations. Export retained activity, then delete the session and sandbox container.

Documented Agents API session configuration (excerpt)

agent={
    "model": "gpt-5.6-luna",
    "instructions": "Coordinate a batch review of invoices and contracts. Delegate documents to specialist subagents; apply the shared expense-review policy; write per-document JSON reports and a summary. Never approve a payment or sign a contract.",
    "reasoning": {"effort": "high"},
    "multi_agent": {"enabled": True, "max_concurrent_subagents": 4},
}

Evidence & Source

Documented Documented: the OpenAI Cookbook README provides a runnable example, sample documents, setup instructions, implementation excerpts, and report-validation logic for batch invoice and contract review. This is a provider-authored cookbook example, not an independent reproduction or a report of measured production outcomes.

Bulk invoice and contract review — OpenAI Cookbook

GitHub README (OpenAI Cookbook) · checked 1 Dec 2026

Open the source

Limitations

  • The example explicitly leaves payment and contract decisions to a person; the agent may recommend but must not approve or sign.
  • Arithmetic validation cannot establish that extracted invoice amounts match the original document, so a person must check the source document and recommendation.
  • The README says retained command activity is not a complete security audit and may contain document content; it should be protected like the reports.
  • Use an empty output directory for each run and unique document stems; summary and review-activity are reserved names.
  • The README documents a provider-authored cookbook example; it does not report independent reproduction or measured performance outcomes.

This record describes what the source states. It is not a review, a benchmark, or a recommendation. If the tool has changed since the check date, report it.