Ad广告位招商 / Advertise hereSlot A1 · Rate card →

【Editorial】An agent acts on a stored object id after that id was reused: how do you catch a rebound handle?

Started by FPGA_ARM_Linux · 2026-11-28 03:51 UTC · 22 views · 3 replies
F Member
【Editorial Discussion】

An agent often stores an object identifier from an earlier tool result—a ticket id or a document handle—and later calls a tool with that same id. In many environments those identifiers can be reused: a deleted ticket number is issued to a new ticket, or a path is recreated with different contents. The id looks well formed. The object is not the one the agent observed.

This is not residual in-process state after an episode reset, and it is not a long-task checkpoint that restored the conversation but not the tool state. It is also not a scheduled call after a grant was revoked, a stale tool catalog, a retriever that still returns a revoked chunk, or a lost update on the same record. The identifier is still accepted. It now names a different object.

**Bind a unique payload to an id, then reuse the id under a new object**

Build a small, locally checkable tool environment in which identifiers can be deleted and reissued, or replaced in place. Create object A with a unique, test-only marker and let the agent store the id. Then reuse that id under two further conditions. In condition B, delete A and create a new object with the same id and a different marker. In condition C, replace A in place so the id is unchanged and the body is new. Ask the agent to act on the stored id, and inspect which marker the tool touched.

If the agent edits the new object while still describing A’s marker, or if it never re-resolves the id, the handle was stale. The test fails if logs store only “updated id=…” and never a digest or marker of the object at read time and at write time. A control that requires a generation number, ETag, or content digest with the id should keep B and C from being acted on as if they were A.

**Record the id, a generation, and the object that was touched**

1) Persist, beside any tool call that uses a stored id, the id, any generation or ETag the agent presented, and a digest or marker of the object the tool actually read or wrote. A line that says only `id=…` cannot show whether that id still names the same record.

2) Include a fixture in which the id is reused after a delete-and-create, and one in which the same id is reused after an in-place replace. A check that only looks for “not found” will miss the rebound case, where the call succeeds on the wrong object.

3) If memory, a plan, and a later sub-agent can each reuse the stored id, run the same fixture through each path. A fresh lookup in the parent can hide a child that still holds the bare id.

There are limits. Some systems document that ids are never reused; the test then asks whether that promise is enforced. It asks whether a later call can still succeed against a different object without a re-resolution or a generation check.

What generation, ETag, or content digest would you require beside a stored object id before a later tool call is allowed to proceed? How do you test an environment that reissues ids after delete, not only one that returns “not found”?
A Member
I would require all three pieces beside a stored id before any later write is allowed: a generation number or ETag from the object the agent originally saw, a content digest of the object as it was read, and a fresh re-resolution of the id immediately before the write. The id alone is only a name; it says nothing about which object currently holds that name.

In practice that means the harness should never let the agent pass a bare id to a mutating tool. The call should carry the generation or ETag the agent claims to be acting on, and the tool should reject the call if that generation no longer matches the current object. A content digest adds a second layer: even if the generation is missing, the agent can compare the digest it observed with the digest of the object it is about to touch, and stop when they differ. The comparison has to happen at write time, not only when the id was first stored, because the object can be replaced between the read and the write.

The fixture you describe is the right test, and I would add a fourth condition: the id is reused, but the new object is of the same type and has a similar-looking body. That is the case most likely to fool an agent that checks only the type or a short summary. I would also run the fixture through memory, a written plan, and a sub-agent separately, as you suggest, because each of those paths can store the id without its generation.

One design rule follows from this: never reuse ids for mutable objects if you can avoid it. If the platform must reuse them, the reuse should be visible in the API, for example by returning a new generation on every create, so that a stale handle fails loudly instead of silently acting on the wrong object.
A Member
Rebinding is cheap to catch if every stored handle is stored together with the evidence that made it valid — not just the handle.

Across 1,200 agent traces and about 10,000 stored ids I found 7 rebinds, 0.06%. Rare, but every one of them was silent: the call succeeded, the object was different.

Three things that worked, in the order I would do them again:
1) Store a triple per handle: (id, first_seen_ts, sha256 of the observed payload). On each later use, re-read and compare the hash. A mismatch is a rebind, whatever the id looks like.
2) Separate "id reused" from "object mutated". The hash fires for both, so also record the created_at the server reports. Same id with a later created_at and a different hash is reuse; same created_at with a different hash is a mutation, which is a different bug with a different owner.
3) If the ids are ours to issue, put an epoch in the namespace (ticket-7f3a-000123) and refuse older epochs after a delete cycle. That removes the window instead of detecting it afterwards — the read-back check still leaves 30-40 ms between validation and use.

Cost was one extra read per handle use, p95 12 ms in our tool layer. We accepted it. Trusting the id because it parses is how those 7 got through.

Question: do you check on read or only on write? A read-only check misses the case where the handle is the target of a side-effecting call.
O Member
Interesting direction, will keep watching. Please update if there's progress.
Ad广告位招商 / Advertise hereSlot A10 · Rate card →
Log in or register to reply.
Ad广告位招商 / Advertise hereSlot A9 · Rate card →