The agent's record #
What is new: an agent's work is a lineage, not a transcript. Every step names the instruction that caused it, its parent step and what it produced. Rewards are computed from exact evidence, and they flow to the agent that did the work and to whoever gave the instruction. There is no verb to declare success.
Why it matters: you can audit which instruction led to which result, credit good planning as well as good execution, and find where a bad outcome came from. An agent cannot talk its way into a reward.
A plan, two steps, one without evidence #
import hashlib
from tensorchain.workspace import Workspace
h = lambda text: hashlib.sha256(text.encode()).hexdigest()
with Workspace("record.sqlite", actor="agent:lead") as ws:
plan = ws.log_step(agent="lead", cause=h("summarise the incident"), cause_kind="prompt", kind="plan")
summary = ws.put(b"Incident 7: cache stampede at 09:12, fixed by request coalescing.")
done = ws.log_step(agent="writer", cause=h("write the summary"), cause_kind="plan-step",
kind="change", parent=plan, output=summary, output_kind="object")
# A step that claims work but produced nothing verifiable.
claimed = ws.log_step(agent="writer", cause=h("also file the ticket"), cause_kind="plan-step",
kind="change", parent=plan)
ws.evaluate(done)
ws.evaluate(claimed)
rows = ws.rewards()
chain = ws.trace(done)
earned = sorted((r["side"], r["beneficiary"], r["outcome"]) for r in rows if r["via"] == done)
unearned = [r for r in rows if r["via"] == claimed and r["outcome"] == "success"]
print("rewards for the summary step:")
for side, who, outcome in earned:
print(" ", side, who, outcome)
print("successful rewards for the claimed-only step:", len(unearned))
print("trace of the summary step:", [(s["kind"], s["agent"]) for s in chain])
assert ("child", "writer", "success") in earned
assert any(side == "parent" and outcome == "success" for side, _, outcome in earned)
assert unearned == []
assert [s["kind"] for s in chain] == ["change", "plan"]
rewards for the summary step:
child writer success
parent lead success
successful rewards for the claimed-only step: 0
trace of the summary step: [('change', 'writer'), ('plan', 'lead')]The summary step produced an object that verifies, so the writer (child) and the plan it came from (parent) were both rewarded, with the object itself as evidence. The step that only claimed work earned nothing, and trace walks the summary back to the instruction that started it.