# Verifying that an approved correction reaches the next agent run

> Source: <https://dev.to/sathish_palanisamy/verifying-that-an-approved-correction-reaches-the-next-agent-run-14ci>
> Published: 2026-10-21 19:56:02+00:00

Disclosure: I work on Areev. This article was written by AI agents and checked against the public source and executed fixture tests.

A corrected answer isn’t guaranteed to influence future agent runs. A meaningful integration test must trace the correction from approval, through persistent storage, into the next run’s context, and finally into the output.

This path is demonstrated in the public Areev invoice-to-accounting Python example. The example uses synthetic fixtures and mock integrations; it is not a live accounting deployment or evidence of model learning.

The test fixture starts with a misspelled vendor: “Cobolt Cloud.” A user corrects it to “Cobalt Cloud” and approves the change. In the reply handler, the alias is only saved when the decision is approval, the state is marked as revised, and the corrected vendor differs from the original input. A correction message alone does not create the alias.

The resulting relation is `mg:alias_of`, scoped to the client’s vendor namespace. This ensures the correction persists independently of the conversation event that triggered it. Source: [reply handler](https://github.com/AreevAI/areev/blob/64db3302e5df85fddead7bc7fc7c80f1775eee99/examples/agents/invoice-to-accounting/python/agent.py#L448-L455).

The trigger uses an `extract_ctx` saved query. Its assembly includes instructions, organizational facts, and recent thread events. The extraction tool processes the provided grains and constructs an alias lookup:

```
aliases = {g["subject"]: g["object"] for g in grains
           if g.get("relation") == "mg:alias_of"}
if vendor in aliases:
    vendor = aliases[vendor]
    confidence = max(confidence, 0.95)
```

This fixture extractor uses predefined fields and does not invoke a model. Increasing confidence after an alias match is a defined rule in this example, not a general assertion that known vendor names justify automatic approval. Other fields and the workflow’s validation steps remain relevant. A production system must define its own validation and approval logic.

Source: [extraction and context assembly](https://github.com/AreevAI/areev/blob/64db3302e5df85fddead7bc7fc7c80f1775eee99/examples/agents/invoice-to-accounting/python/agent.py).

With Git, Bash, and Python available, initialize a fresh directory and virtual environment:

```
git clone https://github.com/AreevAI/areev.git
cd areev
git checkout 64db3302e5df85fddead7bc7fc7c80f1775eee99
python3 -m venv .venv
. .venv/bin/activate
python3 -m pip install areev
cd examples/agents/invoice-to-accounting
bash python/smoke.sh
bash python/improve.sh
```

Package installation requires network access; the fixture walkthrough does not need a model key or live accounting credentials. These commands use the published Python package, so record the installed version when comparing runs.

The smoke script runs the revision and subsequent approval. The improve script processes later fixtures and verifies that the repeated misspelling results in the canonical vendor and an automatic approval in this controlled scenario:

```
assert again[0]["vendor"] == "Cobalt Cloud", again[0]
assert again[0]["approved_by"] == "auto", \
    "it should not have needed a person this time: %r" % again[0]
```

Source: [later-run assertions](https://github.com/AreevAI/areev/blob/64db3302e5df85fddead7bc7fc7c80f1775eee99/examples/agents/invoice-to-accounting/improve.sh#L40-L56). The smoke and improve scripts passed in an isolated environment using the published wheel during the article’s preparation.

The tests confirm that the saved alias persists across runs and affects output. They do not validate extraction accuracy on real invoices. For other workflows, test the same boundaries: what triggers persistence, which context query retrieves the stored data, which step uses it, and which output changes result. A memory write can succeed while a later boundary fails.
