mirror of
https://github.com/openai/codex.git
synced 2026-11-19 22:30:42 +00:00
Add item anchors to thread/items/list pagination (#48151)
## What changed
Allow `cursor` to accept an item anchor such as `{"type":"item","itemId":"item-123"}` with a non-empty `turnId`. Ascending pagination returns items after the anchor; descending pagination returns items before it. The anchor itself is excluded, and subsequent pages use the returned opaque string cursor.
Resolve anchors within the requested turn's visible history, including inherited fork history. Reject missing turn IDs and empty, unknown, or out-of-scope item IDs with invalid params (`-32602`). Preserve existing string and null cursor behavior, and update the protocol schemas, TypeScript and Python types, and API documentation.
## Testing
Add protocol round-trip and invalid-shape tests, app-server coverage for anchored pagination and errors, and thread-store coverage for growing turns, reverse pagination, page boundaries, fork visibility, and anchor scope validation.
GitOrigin-RevId: a74cea190d3ff1b44865429f8b0650b793eb688d
This commit is contained in:
+45
-5
@@ -4491,14 +4491,54 @@
|
||||
],
|
||||
"type": "object"
|
||||
},
|
||||
"ThreadItemsListAnchor": {
|
||||
"description": "An exclusive item position within the requested visible turn.",
|
||||
"oneOf": [
|
||||
{
|
||||
"properties": {
|
||||
"itemId": {
|
||||
"type": "string"
|
||||
},
|
||||
"type": {
|
||||
"enum": [
|
||||
"item"
|
||||
],
|
||||
"title": "ItemThreadItemsListAnchorType",
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"itemId",
|
||||
"type"
|
||||
],
|
||||
"title": "ItemThreadItemsListAnchor",
|
||||
"type": "object"
|
||||
}
|
||||
]
|
||||
},
|
||||
"ThreadItemsListCursor": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"$ref": "#/definitions/ThreadItemsListAnchor"
|
||||
}
|
||||
],
|
||||
"description": "Starting position for an item-history page."
|
||||
},
|
||||
"ThreadItemsListParams": {
|
||||
"properties": {
|
||||
"cursor": {
|
||||
"description": "Opaque cursor to pass to the next call to continue after the last item.",
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
]
|
||||
"anyOf": [
|
||||
{
|
||||
"$ref": "#/definitions/ThreadItemsListCursor"
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
],
|
||||
"description": "Opaque continuation cursor or an exclusive item anchor in the requested visible turn. An item anchor requires a non-empty `turnId`; ascending (the default) returns items after it, and descending returns items before it. Continue with the returned string cursor."
|
||||
},
|
||||
"limit": {
|
||||
"description": "Optional item page size.",
|
||||
|
||||
+45
-5
@@ -22589,15 +22589,55 @@
|
||||
],
|
||||
"type": "object"
|
||||
},
|
||||
"ThreadItemsListAnchor": {
|
||||
"description": "An exclusive item position within the requested visible turn.",
|
||||
"oneOf": [
|
||||
{
|
||||
"properties": {
|
||||
"itemId": {
|
||||
"type": "string"
|
||||
},
|
||||
"type": {
|
||||
"enum": [
|
||||
"item"
|
||||
],
|
||||
"title": "ItemThreadItemsListAnchorType",
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"itemId",
|
||||
"type"
|
||||
],
|
||||
"title": "ItemThreadItemsListAnchor",
|
||||
"type": "object"
|
||||
}
|
||||
]
|
||||
},
|
||||
"ThreadItemsListCursor": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"$ref": "#/definitions/v2/ThreadItemsListAnchor"
|
||||
}
|
||||
],
|
||||
"description": "Starting position for an item-history page."
|
||||
},
|
||||
"ThreadItemsListParams": {
|
||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||
"properties": {
|
||||
"cursor": {
|
||||
"description": "Opaque cursor to pass to the next call to continue after the last item.",
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
]
|
||||
"anyOf": [
|
||||
{
|
||||
"$ref": "#/definitions/v2/ThreadItemsListCursor"
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
],
|
||||
"description": "Opaque continuation cursor or an exclusive item anchor in the requested visible turn. An item anchor requires a non-empty `turnId`; ascending (the default) returns items after it, and descending returns items before it. Continue with the returned string cursor."
|
||||
},
|
||||
"limit": {
|
||||
"description": "Optional item page size.",
|
||||
|
||||
+45
-5
@@ -20303,15 +20303,55 @@
|
||||
],
|
||||
"type": "object"
|
||||
},
|
||||
"ThreadItemsListAnchor": {
|
||||
"description": "An exclusive item position within the requested visible turn.",
|
||||
"oneOf": [
|
||||
{
|
||||
"properties": {
|
||||
"itemId": {
|
||||
"type": "string"
|
||||
},
|
||||
"type": {
|
||||
"enum": [
|
||||
"item"
|
||||
],
|
||||
"title": "ItemThreadItemsListAnchorType",
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"itemId",
|
||||
"type"
|
||||
],
|
||||
"title": "ItemThreadItemsListAnchor",
|
||||
"type": "object"
|
||||
}
|
||||
]
|
||||
},
|
||||
"ThreadItemsListCursor": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"$ref": "#/definitions/ThreadItemsListAnchor"
|
||||
}
|
||||
],
|
||||
"description": "Starting position for an item-history page."
|
||||
},
|
||||
"ThreadItemsListParams": {
|
||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||
"properties": {
|
||||
"cursor": {
|
||||
"description": "Opaque cursor to pass to the next call to continue after the last item.",
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
]
|
||||
"anyOf": [
|
||||
{
|
||||
"$ref": "#/definitions/ThreadItemsListCursor"
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
],
|
||||
"description": "Opaque continuation cursor or an exclusive item anchor in the requested visible turn. An item anchor requires a non-empty `turnId`; ascending (the default) returns items after it, and descending returns items before it. Continue with the returned string cursor."
|
||||
},
|
||||
"limit": {
|
||||
"description": "Optional item page size.",
|
||||
|
||||
@@ -7,15 +7,55 @@
|
||||
"desc"
|
||||
],
|
||||
"type": "string"
|
||||
},
|
||||
"ThreadItemsListAnchor": {
|
||||
"description": "An exclusive item position within the requested visible turn.",
|
||||
"oneOf": [
|
||||
{
|
||||
"properties": {
|
||||
"itemId": {
|
||||
"type": "string"
|
||||
},
|
||||
"type": {
|
||||
"enum": [
|
||||
"item"
|
||||
],
|
||||
"title": "ItemThreadItemsListAnchorType",
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"itemId",
|
||||
"type"
|
||||
],
|
||||
"title": "ItemThreadItemsListAnchor",
|
||||
"type": "object"
|
||||
}
|
||||
]
|
||||
},
|
||||
"ThreadItemsListCursor": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"$ref": "#/definitions/ThreadItemsListAnchor"
|
||||
}
|
||||
],
|
||||
"description": "Starting position for an item-history page."
|
||||
}
|
||||
},
|
||||
"properties": {
|
||||
"cursor": {
|
||||
"description": "Opaque cursor to pass to the next call to continue after the last item.",
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
]
|
||||
"anyOf": [
|
||||
{
|
||||
"$ref": "#/definitions/ThreadItemsListCursor"
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
],
|
||||
"description": "Opaque continuation cursor or an exclusive item anchor in the requested visible turn. An item anchor requires a non-empty `turnId`; ascending (the default) returns items after it, and descending returns items before it. Continue with the returned string cursor."
|
||||
},
|
||||
"limit": {
|
||||
"description": "Optional item page size.",
|
||||
|
||||
BIN
Binary file not shown.
BIN
Binary file not shown.
@@ -0,0 +1,8 @@
|
||||
// GENERATED CODE! DO NOT MODIFY BY HAND!
|
||||
|
||||
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
||||
|
||||
/**
|
||||
* An exclusive item position within the requested visible turn.
|
||||
*/
|
||||
export type ThreadItemsListAnchor = { "type": "item", itemId: string, };
|
||||
@@ -0,0 +1,9 @@
|
||||
// GENERATED CODE! DO NOT MODIFY BY HAND!
|
||||
|
||||
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
||||
import type { ThreadItemsListAnchor } from "./ThreadItemsListAnchor";
|
||||
|
||||
/**
|
||||
* Starting position for an item-history page.
|
||||
*/
|
||||
export type ThreadItemsListCursor = string | ThreadItemsListAnchor;
|
||||
+5
-2
@@ -2,6 +2,7 @@
|
||||
|
||||
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
||||
import type { SortDirection } from "./SortDirection";
|
||||
import type { ThreadItemsListCursor } from "./ThreadItemsListCursor";
|
||||
|
||||
export type ThreadItemsListParams = { threadId: string,
|
||||
/**
|
||||
@@ -9,9 +10,11 @@ export type ThreadItemsListParams = { threadId: string,
|
||||
*/
|
||||
turnId?: string | null,
|
||||
/**
|
||||
* Opaque cursor to pass to the next call to continue after the last item.
|
||||
* Opaque continuation cursor or an exclusive item anchor in the requested visible turn.
|
||||
* An item anchor requires a non-empty `turnId`; ascending (the default) returns items
|
||||
* after it, and descending returns items before it. Continue with the returned string cursor.
|
||||
*/
|
||||
cursor?: string | null,
|
||||
cursor?: ThreadItemsListCursor | null,
|
||||
/**
|
||||
* Optional item page size.
|
||||
*/
|
||||
|
||||
@@ -514,6 +514,8 @@ export type { ThreadInjectItemsParams } from "./ThreadInjectItemsParams";
|
||||
export type { ThreadInjectItemsResponse } from "./ThreadInjectItemsResponse";
|
||||
export type { ThreadItem } from "./ThreadItem";
|
||||
export type { ThreadItemEntry } from "./ThreadItemEntry";
|
||||
export type { ThreadItemsListAnchor } from "./ThreadItemsListAnchor";
|
||||
export type { ThreadItemsListCursor } from "./ThreadItemsListCursor";
|
||||
export type { ThreadItemsListParams } from "./ThreadItemsListParams";
|
||||
export type { ThreadItemsListResponse } from "./ThreadItemsListResponse";
|
||||
export type { ThreadListParams } from "./ThreadListParams";
|
||||
|
||||
Reference in New Issue
Block a user