SP

miniRL: grading an agent by the database it leaves behind

agentsevaluationreinforcement-learning

An agent can explain an invoice problem correctly and still leave the wrong records behind. In miniRL, the final explanation does not decide whether the episode passes. The database does.

miniRL is my small OpenEnv-based accounts-payable environment for evaluating tool-using language models. It uses synthetic ERP data, seven tools and twelve tasks. Despite the name, the current project is an evaluation sandbox. It does not train a model or connect to a payment service.

Start from a reproducible state

The data path begins with five synthetic CSV files. A cleaning step turns them into a SQLite snapshot used to initialize episodes. Integer cents avoid introducing binary floating-point ambiguity into money comparisons. Alias merges and rejected records retain provenance so data preparation decisions remain inspectable.

Each task runs with a frozen date, an allowlist and a twelve-attempt budget. The task set covers short delivery, price mismatch and duplicate invoices, with four cases in each category. These constraints make the environment small enough to inspect while still requiring the agent to reason about state.

The frozen date matters because time-dependent rules otherwise change between runs. A reset snapshot matters because a previous episode's repair must not become the next episode's starting condition. Reproducibility begins before the first model call.

Keep the action space narrow

The agent acts through seven tools rather than arbitrary code execution. OpenEnv supplies typed reset and step interfaces. The environment uses a private standard-input/output transport so its Docker container can remain without network access.

The model call stays on the host. Its key is never placed inside the task container. The container runs as a non-root user with a read-only root filesystem, resource limits and no mounted host files.

These boundaries help separate the behavior being evaluated from the infrastructure used to evaluate it. They also keep the task interpretable. If the agent succeeds, the trajectory should show which allowed operations produced the result. A broad shell tool would turn a small business-process environment into a different problem.

Check the outcome and the surrounding state

The grader is independent of the agent's final answer. It compares the final SQLite database with the starting snapshot and checks the required outcome, forbidden payments, collateral changes, schema changes and audit replay.

The collateral check is especially important. Completing the target task while modifying an unrelated invoice should not count as a clean success. A grader that looks only for one expected field can reward a destructive shortcut.

For example, imagine a task about one duplicate invoice. The desired state might be present at the end, yet a second invoice may also have changed. Checking the target alone would hide that mistake. Comparing the permitted delta with the broader database makes it observable.

This is a design principle beyond invoices: define what must change and what must remain unchanged. Many agent tasks need both halves of that contract.

Keep reward semantics explicit

The environment returns zero step reward and a binary final grade. That makes the current success criterion easy to state. An episode passes only when the final state satisfies the checks.

This does not imply that intermediate behavior is unimportant. A trajectory can still reveal repeated invalid calls, wasted attempts or a recovery after a mistaken action. Those observations help diagnose the system even when the final grade is the same.

It also does not make this a completed reinforcement-learning experiment. A reset/step environment and a reward function are ingredients for training. The current evaluation harness uses them to measure episodes, without updating model weights.

Retain the evidence for each episode

Runs are stored in immutable directories containing the JSONL trajectory, transcript and final database. The parallel evaluation harness lets multiple episodes run while keeping their evidence separate.

That record supports a more useful failure review than reading a summary sentence. Was the wrong tool chosen? Did a valid tool receive the wrong identifier? Did the target change correctly while another record changed too? Did the budget expire before the necessary action?

A score tells me which episodes need attention. The trajectory and final database tell me what to investigate.

Keep the environment's claims small

The current schema uses one currency, whole units and one purchase-order line per invoice. It does not model tax, foreign exchange or a partial-payment ledger. It has no arbitrary-code tools. Results on the known task set cannot establish generalization to unseen companies or production ERP systems.

I am also leaving the known-task pass rate out of this introduction. A useful model comparison needs fixed tools, prompts and grading, plus a clearly separated evaluation set. Changes to the environment or reminders can change a score without isolating model quality.

The concrete contribution here is an inspectable test environment: synthetic inputs, bounded actions and an independent check of the state left behind. That makes failures specific enough to debug before attempting a larger task set or a training experiment.