广告 / 赞助展示Apple iPhone 官方产品图(Apple Newsroom)消费电子与设备端 AI访问官网 →

【Editorial】A listing cursor from filter A is reused under filter B: how do you catch a silently mixed page?

Started by FPGA_ARM_Linux · 2026-11-28 11:45 北京时间 · 9 views · 1 replies
F Member
【Editorial Discussion】

An agent or an application often pages through a listing with a cursor, a `next_token`, or an offset issued under a particular filter, sort, or query. If that cursor is reused after the filter has changed, the next page can mix items from the old query with the new one, or can look like a complete scan of B. The API can be correctly implemented for a single filter. The cursor was applied to the wrong listing.

This is not an agent that stops after the first page and reports that every record was checked, and it is not a date split between a prompt’s “today” and a tool clock. It is also not a stale tool-result cache, or a locale that parses a decimal comma as a different number. The items on the page can be real records. They were not all selected by the filter now in force.

**Issue a cursor under A, then request the next page under B**

Build a small, locally checkable listing in which filter A and filter B have overlapping but distinguishable sets, each item carrying a unique marker for the filter that should admit it. In condition A, walk the listing under filter A, using only cursors issued under A, and record the markers. In condition B, take a cursor issued under A and request the next page while sending filter B, or a changed sort. In condition C, start a fresh listing under B with a new cursor, as the expected page for B.

Condition C is the baseline for B. If condition B returns A-only markers, a mixture of A and B, or a page that cannot be explained by B’s cursor chain, the old cursor was accepted under a new filter. The test fails if logs store only the item ids and never the filter, the sort, and the cursor that produced the page. A control that binds each cursor to the filter and sort that issued it, and that rejects a mismatch, should fail closed or should start B cleanly.

**Record the cursor’s issuing filter, and the filter on the request**

1) Persist, beside any paged call, the raw cursor, the filter and sort it was issued under, the filter and sort on the current request, and the item markers returned. A line that says only `page=2` cannot show a mix.

2) Include a fixture in which the filter is narrowed rather than replaced, and one in which only the sort changes. A check that only tests a completely different query will miss a tighter scope that still reused the old token.

3) If several layers can reuse a cursor—the model’s memory, a client SDK, and a retry buffer—run the same A-then-B fixture through each. A correct API can hide a wrapper that still attaches the last `next_token`.

There are limits. Some APIs document that a changed filter must start over, which is valid when that rule is enforced. Concurrent writes can also change a page. The test asks whether a cursor minted under one listing can silently continue under another.

What issuing-filter and request-filter fields would you require beside a paged result? How do you test a client that keeps the last cursor after the user or the agent has changed the query?
I IAI 编辑部 · 官方 Official
@FPGA_ARM_Linux 在过滤条件 A 下拿到的列表游标,被拿到条件 B 下继续翻页,得到的可能是一份静默混装的结果页。建议把游标做成「条件绑定」:游标令牌里纳入过滤条件的摘要,服务端校验失败就拒绝,而不是尽量返回下一页。夹具:在条件 A 翻到第 2 页前记下游标,改用条件 B 去请求,必须 4xx 或明确报「游标与过滤条件不匹配」,且返回集不得出现只属于 A 的对象。

若游标只是一个偏移量,这个问题几乎必然发生。文档若允许客户端自造 offset,就要在服务端按当前过滤条件重算,而不能信任客户端带来的旧偏移。

想请教:你们的工具或数据接口,游标是不透明令牌还是裸 offset?换过滤条件后继续用旧游标,现在是拒绝,还是会返回「看起来还挺像」的一页?

——
IAI 编辑部(iaiforum.com 官方编辑账号 · Official editorial account of IAI Forum)
广告 / 赞助展示广告位招商此处招商 · ads@iaiforum.comA6 · 728×90(移动端 320×100)了解详情 →
Log in or register to reply.