NA0XY/invoice-processing-env
InvoiceProcessingEnv
Round 1 submission: a real-world OpenEnv benchmark for accounts-payable operations.
This environment models finance workflows that humans perform daily:
- invoice field extraction from noisy OCR
- invoice to purchase-order validation
- fraud triage in invoice batches
- GL coding for expense line items
- vendor statement reconciliation
It is designed for agent learning and evaluation through the standard OpenEnv API:
- reset()
- step(action)
- state()
Round 1 Compliance Snapshot
Real-World Utility
The agent acts as an AP analyst assistant. Given invoices and accounting context, it must:
- Extract structured fields (vendor, invoice number, date, line items, amounts)
- Validate invoices against purchase orders — detect quantity/price mismatches
- Detect fraud in a batch — duplicates, unauthorized vendors, inflated amounts
- Assign GL codes for ambiguous expense line items
- Reconcile statements against internal ledgers for missing/discrepant invoices
OpenEnv Interface
All reward values are constrained to [0.0, 1.0].
Typed Observation Space
Typed Action Space
Task Suite and Difficulty
Grader and Reward Design
Task 1 (extraction): score = correct_fields / 7 Each of the 7 fields contributes 1/7. Numeric fields tolerate ±$0.02 or ±2%.
Task 2 (validation): 0.4 × correct_decision + 0.2 × mismatches_found Max 1.0. Each of the 3 mismatches is detected via keyword matching.
Task 3 (fraud detection): F1(precision, recall) + 0.05 × correct_reasons F1 across fraud IDs plus a reason bonus. Max 1.0.
Task 4 (GL coding): 0.25 × correct_gl_assignment One quarter point per correctly coded line item. Max 1.0.
Task 5 (reconciliation): 0.5 × F1(missing) + 0.5 × F1(discrepancy) Balances missing-invoice detection and discrepancy detection. Max 1.0.
Environment step rewards are delta-based: each step returns only improvement over the best score seen so far in the episode.
Mandatory Inference Requirements
The root-level inference script is named inference.py and uses the OpenAI client.
Required environment variables:
- APIBASEURL
- MODEL_NAME
- HF_TOKEN
Recommended additional variable for local runs:
- ENVBASEURL
The script emits strict structured stdout logs:
- [START]
- [STEP]
- [END]
The formatting is enforced by a compliance checker in tools/checkinferencelogs.py.
Setup
# Run locally
pip install -r requirements.txt
uvicorn app.main:app --port 7860# Docker
docker build -t invoice-env .
docker run -p 7860:7860 invoice-env# Run baseline inference
export API_BASE_URL="https://api.openai.com/v1"
export MODEL_NAME="gpt-4o-mini"
export HF_TOKEN="sk-..."
export ENV_BASE_URL="http://localhost:7860"
python inference.pyAPI Endpoints
Baseline Scores
Baseline run is deterministic at temperature 0 (model-dependent absolute scores).
Validation and Pre-Submission Checks
pip install openenv-core
openenv validate# local container smoke
docker build -t invoice-env .
docker run -p 7860:7860 invoice-env# strict inference log compliance
python tools/check_inference_logs.py --stdout stdout_check.log --stderr stderr_check.logFor the full submission gate, run scripts/validate-submission.sh against your deployed Space URL.
Submission gate checklist:
- HF Space deploy responds with 200 and reset works
- OpenEnv validation passes
- Docker build and run succeed
- Inference script completes and emits strict log format
- Task graders produce valid [0,1] rewards
Resource and Runtime Constraints
Target infra compatibility:
- inference runtime under 20 minutes
- compatible with vCPU=2 and memory=8GB
HF Space Deployment
This repository is configured for Docker Spaces.
- Push to a Hugging Face Space with hardware cpu-basic
- Ensure Space tag includes openenv
- App listens on port 7860 via Dockerfile runtime
Judging Alignment (Round 1)
This submission is built to map directly to the published rubric:
- Real-world utility: AP automation benchmark with realistic finance tasks
- Task and grader quality: deterministic graders with easy to hard progression
- Environment design: typed interfaces, delta rewards, clear episode boundaries
- Code quality and compliance: OpenEnv-compatible structure + deployable container
- Creativity and novelty: multi-stage AP flow in a single cohesive benchmark
