Effect Ledger

An effect ledger is an append-only record of the state changes that an agent’s tool calls actually caused: one entry per refund issued, record updated, email sent, or escalation opened. It is written by the system that performs the action, not by the model and not from the model’s description of what it did. It serves two uses: scoring a run by what changed in the world, and answering after the fact what the agent did.

Why the final message is not enough

An agent run produces a transcript, with the model’s calls, the tool answers, and a closing message. A closing message that says “your refund of 20.00 was issued” is a claim about state. It can be true while the world is wrong, for instance when a retry created a second refund. It can also be false while the wording looks perfect, when the call failed and the model summarized optimistically. Scoring the reply with a reference answer or a judge model sees only the words. Matching the trajectory against a reference sequence of calls penalizes valid alternatives and misses wrong argument values. The ledger gives a third view, the outcome: what the backend and its connected systems look like after the run, compared with what the task required.

Public agent benchmarks lean on this idea. Yao et al.’s ฯ„-bench compares the database state at the end of a conversation with a goal state, and Jimenez et al.’s SWE-bench runs tests against the repository the model produced.

What a ledger records

A useful entry is small and written at the point where the effect happens, inside the tool implementation or the dispatcher that runs it:

class Backend:
    def __init__(self):
        self.refunded = {}
        self.ledger = []      # committed effects only
    def _log(self, kind, **kw):
        self.ledger.append({"seq": len(self.ledger), "kind": kind, **kw})
    def refund(self, order_id, cents, call_key):
        if any(e["kind"] == "refund" and e["call_key"] == call_key for e in self.ledger):
            return "duplicate-ignored"
        old_state, old_ledger = self.refunded.copy(), self.ledger.copy()
        try:
            self.refunded[order_id] = self.refunded.get(order_id, 0) + cents
            self._log("refund", order=order_id, cents=cents, call_key=call_key)
        except Exception:
            self.refunded, self.ledger = old_state, old_ledger
            raise
        return "ok"


Each entry names the kind of effect, the target, the amounts or values, and a key tying it to the call that caused it. Reads can be recorded separately when they matter, but the ledger’s core is changes. Refusals before execution produce no effect entry. This sequential in-memory toy rolls both state and ledger back if logging raises. A durable backend needs the effect and record committed in one transaction, or reconciliation for an external effect. A timeout after commit can report failure even though the effect happened; record attempts separately and retry with the same idempotency key rather than treating every failed call as no effect.

Scoring with it

An evaluator compares the ledger with the expected outcome for the task, and the reply with the ledger. The oracle below requires exactly one refund of 2000 cents to order0 and no other effect. It compares the effect kind, target, and amount as a multiset, so a refund to another order cannot pass merely because the total is right:

from collections import Counter

def score(ledger, expected, reply):
    actual = [(e["kind"], e.get("order"), e.get("cents")) for e in ledger]
    refunds = [e for e in ledger if e["kind"] == "refund"]
    return {"effects_match": Counter(actual) == Counter(expected),
            "total_refunded": sum(e["cents"] for e in refunds),
            "n_refund_records": len(refunds),
            "reply_claims_refund": "refund" in reply.lower()}


  • Run 1, one refund with a stable key: effects_match is true, one record.
  • Run 2, the call retried with a fresh key after a lost response: effects_match is false, total_refunded 4000 across two records, while the reply still says the refund was issued. A reply-only scorer passes this run.
  • Run 3, no refund written but the reply claims one: effects_match is false with zero records and reply_claims_refund true. The mismatch between claim and ledger is itself a failure category, a false completion claim.
expected = [("refund", "order0", 2000)]
for name,orders,keys in (
    ("stable retry",["order0","order0"],["key0","key0"]),
    ("fresh retry",["order0","order0"],["key0","key1"]),
    ("no effect",[],[]),
    ("wrong order",["order1"],["key0"]),
):
    b=Backend()
    for order,key in zip(orders,keys): b.refund(order,2000,key)
    print(name,score(b.ledger,expected,"Your refund was issued."))
b=Backend()
def failed_log(*args,**kwargs): raise RuntimeError("log failed")
b._log=failed_log
try: b.refund("order0",2000,"key0")
except RuntimeError: pass
print("log failure",b.refunded,b.ledger)
stable retry {'effects_match': True, 'total_refunded': 2000, 'n_refund_records': 1, 'reply_claims_refund': True}
fresh retry {'effects_match': False, 'total_refunded': 4000, 'n_refund_records': 2, 'reply_claims_refund': True}
no effect {'effects_match': False, 'total_refunded': 0, 'n_refund_records': 0, 'reply_claims_refund': True}
wrong order {'effects_match': False, 'total_refunded': 2000, 'n_refund_records': 1, 'reply_claims_refund': True}
log failure {} []

Run 4 refunds order1 instead of order0: the total is still 2000, but effects_match is false. The logging-failure test leaves both state and ledger empty. The same exact-effects comparison rejects additional effect kinds; a real evaluator also checks approvals and reconciles recorded changes with authoritative final state. The reply flag here is only a substring demonstration, not a semantic claim checker.

Conditions and limits

  • Completeness. The ledger is only as complete as the instrumentation. An effect produced by a path that does not log, such as a direct database write or a call to an external service the backend cannot see, is invisible. For external systems, reconcile with the system’s own records.
  • Independence. The recorder must not be the agent. If the model can write entries, the ledger is another claim.
  • Append-only. Entries are never edited, so corrections appear as new entries. When tamper evidence matters beyond evaluation, a hash chain over the entries can make edits detectable, but only if the latest hash is anchored somewhere the writer cannot change, such as a signed checkpoint, an external timestamp, or a protected append-only store. Without that anchor, someone who can edit the records can recompute every later hash.
  • It is not an audit log in the broad sense. An audit log records who did what under whose authority and why, including refused actions; the effect ledger focuses on state changes and is shaped for comparing outcomes against expectations. One system can serve both with different entry types.

References


Discover more from Insightful Data Lab

Subscribe to get the latest posts sent to your email.

Similar Posts

Questions, corrections, or additional insights?

This site uses Akismet to reduce spam. Learn how your comment data is processed.