From 6227fbe2f354d92216169d8ac88015561497deee Mon Sep 17 00:00:00 2001 From: Wout Stiens <71498452+StiensWout@users.noreply.github.com> Date: Thu, 3 Dec 2026 18:09:30 +0100 Subject: [PATCH 1/6] test: scenario for ACP session pages with long cursors Co-authored-by: Claude Opus 5.5 --- ...session-list-keeps-pagination-token.e2e.ts | 89 +++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 scripts/scenarios/acp-session-list-keeps-pagination-token.e2e.ts diff --git a/scripts/scenarios/acp-session-list-keeps-pagination-token.e2e.ts b/scripts/scenarios/acp-session-list-keeps-pagination-token.e2e.ts new file mode 100644 index 0000000000000..159a08d9a1fbc --- /dev/null +++ b/scripts/scenarios/acp-session-list-keeps-pagination-token.e2e.ts @@ -0,0 +1,89 @@ +// @effect-diagnostics nodeBuiltinImport:off -- The scenario stages a local ACP executable. +import * as NodePath from "node:path"; + +import { ProviderDriverKind, ProviderInstanceId } from "@t3tools/contracts"; +import { expect } from "e2e"; +import * as Effect from "effect/Effect"; + +import { T3_HOME } from "../e2e.config.ts"; +import { rpcClient, runPromise, test, WEB } from "./t3.ts"; + +const ACP = ` +import { createInterface } from "node:readline"; + +// An opaque cursor can encode the IDs the agent has already returned. +const ids = Array.from({ length: 60 }, (_, index) => "sample-conversation-session-" + index); +const nextCursor = Buffer.from(JSON.stringify(ids)).toString("base64url"); +const send = (message) => process.stdout.write(JSON.stringify({ jsonrpc: "2.0", ...message }) + "\\n"); +for await (const line of createInterface({ input: process.stdin })) { + const { id, method, params } = JSON.parse(line); + if (id === undefined) continue; + if (method === "initialize") { + send({ id, result: { + protocolVersion: 1, + agentCapabilities: { loadSession: true, sessionCapabilities: { list: {} } }, + authMethods: [], + } }); + } else if (method === "session/new") { + send({ id, result: { sessionId: "probe" } }); + } else if (method === "session/list" && params.cursor === undefined) { + send({ id, result: { + nextCursor, + sessions: ids.map((sessionId, index) => ({ + sessionId, + cwd: params.cwd, + title: "Native conversation " + (index + 1), + })), + } }); + } else if (method === "session/list" && params.cursor === nextCursor) { + send({ id, result: { + sessions: [{ sessionId: "archived", cwd: params.cwd, title: "Older conversation" }], + } }); + } else { + send({ id, error: method === "session/list" + ? { code: -32602, message: "Invalid session cursor" } + : { code: -32601, message: "Method not found" }, + }); + } +} +`; + +test( + "Load more opens the next ACP session page when its cursor is long", + WEB, + async ({ t3, app, screen }) => { + const project = await t3.project("demo", { "session-agent.mjs": ACP }); + const instanceId = ProviderInstanceId.make("scenario-long-session-cursor"); + await runPromise( + Effect.gen(function* () { + const client = yield* rpcClient(T3_HOME, app.baseUrl ?? ""); + yield* client["server.updateSettings"]({ + patch: {}, + providerInstanceMutation: { + operation: "upsert", + instanceId, + instance: { + driver: ProviderDriverKind.make("acpRegistry"), + displayName: "Local Session Agent", + enabled: true, + config: { + source: "local", + commandPath: process.execPath, + commandArgs: [NodePath.join(project, "session-agent.mjs")], + }, + }, + }, + }); + }).pipe(Effect.scoped), + ); + + await t3.open(`/settings/providers?instanceId=${instanceId}`); + await screen.getByRole("button", "List sessions", { exact: true }).tap({ timeout: 60_000 }); + await screen.getByRole("button", "Load more", { exact: true }).tap(); + await screen.getByRole("button", "Refresh", { exact: true }).waitFor(); + + const older = screen.getByText("Older conversation", { exact: true }); + await app.screenshot("native-sessions-after-load-more"); + expect(await older.isVisible()).toBe(true); + }, +); From d69e80f5dcbfd201b22de02d954d176100a04281 Mon Sep 17 00:00:00 2001 From: Wout Stiens <71498452+StiensWout@users.noreply.github.com> Date: Thu, 3 Dec 2026 18:11:05 +0100 Subject: [PATCH 2/6] fix(server): ACP session lists load pages with long cursors Agents may encode already returned sessions in their opaque session/list cursor. The server cut cursors to 2,048 characters, so Load more sent a different cursor and the agent rejected it. Cursors now pass through verbatim up to a shared 16 KiB limit, and an oversized one ends paging instead of being shortened. Co-authored-by: Claude Opus 5.5 --- packages/contracts/src/acpRegistry.ts | 10 ++++++++-- packages/provider-acp-registry/src/server/probe.ts | 4 +++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/packages/contracts/src/acpRegistry.ts b/packages/contracts/src/acpRegistry.ts index fffbe8dd44934..47e28dce4776d 100644 --- a/packages/contracts/src/acpRegistry.ts +++ b/packages/contracts/src/acpRegistry.ts @@ -155,16 +155,22 @@ export const AcpRegistrySession = Schema.Struct({ }); export type AcpRegistrySession = typeof AcpRegistrySession.Type; +// ACP cursors are opaque; agents may encode the pages they already returned in them. +export const ACP_REGISTRY_SESSION_CURSOR_MAX_LENGTH = 16_384; +const AcpRegistrySessionCursor = Schema.String.check( + Schema.isMaxLength(ACP_REGISTRY_SESSION_CURSOR_MAX_LENGTH), +); + export const AcpRegistryListSessionsInput = Schema.Struct({ instanceId: ProviderInstanceId, projectId: ProjectId, - cursor: Schema.optionalKey(Schema.String.check(Schema.isMaxLength(2_048))), + cursor: Schema.optionalKey(AcpRegistrySessionCursor), }); export type AcpRegistryListSessionsInput = typeof AcpRegistryListSessionsInput.Type; export const AcpRegistryListSessionsResult = Schema.Struct({ sessions: Schema.Array(AcpRegistrySession).check(Schema.isMaxLength(256)), - nextCursor: Schema.NullOr(Schema.String.check(Schema.isMaxLength(2_048))), + nextCursor: Schema.NullOr(AcpRegistrySessionCursor), canLoad: Schema.Boolean, canResume: Schema.Boolean, canDelete: Schema.Boolean, diff --git a/packages/provider-acp-registry/src/server/probe.ts b/packages/provider-acp-registry/src/server/probe.ts index 7bf0fe28114c9..ac3ac9a376600 100644 --- a/packages/provider-acp-registry/src/server/probe.ts +++ b/packages/provider-acp-registry/src/server/probe.ts @@ -1,5 +1,6 @@ import { resolveProviderProbeTimeoutMs } from "@t3tools/provider-core/server/snapshotProbe"; import { + ACP_REGISTRY_SESSION_CURSOR_MAX_LENGTH, AcpRegistryListProvidersResult, AcpRegistryOperationError, AcpRegistryListSessionsResult, @@ -897,10 +898,11 @@ export const listAcpRegistrySessions = Effect.fn("AcpRegistryProbe.listSessions" }); return AcpRegistryListSessionsResult.make({ sessions, + // A shortened cursor names a different page, so an oversized one ends paging instead. nextCursor: listed.nextCursor === undefined || listed.nextCursor === null ? null - : boundedText(listed.nextCursor, 2_048) || null, + : (boundedOpaqueValue(listed.nextCursor, ACP_REGISTRY_SESSION_CURSOR_MAX_LENGTH) ?? null), canLoad: initialized.agentCapabilities?.loadSession === true, canResume: initialized.agentCapabilities?.sessionCapabilities?.resume != null, canDelete: initialized.agentCapabilities?.sessionCapabilities?.delete != null, From 6e1b9088c8855b860f72dfe504b60b2a80152e4a Mon Sep 17 00:00:00 2001 From: Wout Stiens <71498452+StiensWout@users.noreply.github.com> Date: Thu, 3 Dec 2026 18:17:48 +0100 Subject: [PATCH 3/6] test(server): cover ACP session cursor length limits Co-authored-by: Claude Opus 5.5 --- apps/server/scripts/acp-mock-agent.ts | 2 + .../src/provider/AcpRegistryProbe.test.ts | 57 ++++++++++++++++++- 2 files changed, 58 insertions(+), 1 deletion(-) diff --git a/apps/server/scripts/acp-mock-agent.ts b/apps/server/scripts/acp-mock-agent.ts index d137791ab7724..630280503a825 100644 --- a/apps/server/scripts/acp-mock-agent.ts +++ b/apps/server/scripts/acp-mock-agent.ts @@ -17,6 +17,7 @@ import type * as AcpCompat from "effect-acp/compat"; import { beginAcpMockPrompt } from "./acpMockCancellationState.ts"; const requestLogPath = process.env.T3_ACP_REQUEST_LOG_PATH; +const sessionListNextCursor = process.env.T3_ACP_SESSION_LIST_NEXT_CURSOR; const antigravityProfile = process.env.T3_ACP_ANTIGRAVITY === "1"; const antigravityThoughtLevel = process.env.T3_ACP_ANTIGRAVITY_THOUGHT_LEVEL === "1"; const antigravityResumeThoughtLevel = process.env.T3_ACP_RESUME_THOUGHT_LEVEL; @@ -776,6 +777,7 @@ const program = Effect.gen(function* () { updatedAt: "1970-01-01T00:00:00.000Z", }, ], + ...(sessionListNextCursor === undefined ? {} : { nextCursor: sessionListNextCursor }), }; }), ); diff --git a/apps/server/src/provider/AcpRegistryProbe.test.ts b/apps/server/src/provider/AcpRegistryProbe.test.ts index f9a982dfef503..977ece6c1fcd9 100644 --- a/apps/server/src/provider/AcpRegistryProbe.test.ts +++ b/apps/server/src/provider/AcpRegistryProbe.test.ts @@ -5,7 +5,7 @@ import * as NodeURL from "node:url"; import * as NodeCrypto from "@effect/platform-node/NodeCrypto"; import * as NodeServices from "@effect/platform-node/NodeServices"; import * as Layer from "effect/Layer"; -import { ProviderInstanceId } from "@t3tools/contracts"; +import { ACP_REGISTRY_SESSION_CURSOR_MAX_LENGTH, ProviderInstanceId } from "@t3tools/contracts"; import { AcpRegistrySettings } from "@t3tools/provider-acp-registry/settings"; import { describe, expect, it } from "@effect/vitest"; import * as Effect from "effect/Effect"; @@ -417,6 +417,61 @@ describe("ACP Registry probe", () => { ); }); + it.effect.each([ + { name: "a long cursor verbatim", cursor: "c".repeat(2_049), expected: "c".repeat(2_049) }, + { + name: "a cursor at the limit", + cursor: "c".repeat(ACP_REGISTRY_SESSION_CURSOR_MAX_LENGTH), + expected: "c".repeat(ACP_REGISTRY_SESSION_CURSOR_MAX_LENGTH), + }, + { + name: "no cursor past the limit", + cursor: "c".repeat(ACP_REGISTRY_SESSION_CURSOR_MAX_LENGTH + 1), + expected: null, + }, + { name: "no empty cursor", cursor: "", expected: null }, + ])("returns $name for the next session page", ({ cursor, expected }) => { + const catalog = AcpRegistrySupport.AcpRegistryCatalog.of({ + search: () => Effect.die("unused search"), + prepare: () => Effect.die("unused prepare"), + refreshIndex: () => Effect.succeed(false), + invalidateIndex: () => Effect.void, + inspect: () => Effect.die("unused inspect"), + uninstallManagedBinary: () => Effect.die("unused uninstall"), + resolve: () => + Effect.succeed({ + agent: { + id: "mock-agent", + name: "Mock Agent", + version: "1.0.0", + description: "ACP session paging test agent", + distribution: { npx: { package: "mock-agent@1.0.0" } }, + }, + distribution: "npx" as const, + spawn: { + command: "node", + args: [mockAgentPath], + env: { + ...process.env, + T3_ACP_SESSION_LIFECYCLE: "1", + T3_ACP_SESSION_LIST_NEXT_CURSOR: cursor, + }, + }, + }), + }); + + return listAcpRegistrySessions({ + instanceId, + settings: decodeSettings({ agentId: "mock-agent" }), + cwd: process.cwd(), + environment: process.env, + }).pipe( + Effect.map((listed) => expect(listed.nextCursor).toBe(expected)), + Effect.provideService(AcpRegistrySupport.AcpRegistryCatalog, catalog), + Effect.provide(Layer.mergeAll(NodeServices.layer, NodeCrypto.layer)), + ); + }); + it.live.each(["succeeds", "fails"] as const)( "deletes its health-probe session when deletion is advertised and %s", (deleteOutcome) => From 24f34f214046839fcbbd17eeae46d24b521949cf Mon Sep 17 00:00:00 2001 From: Wout Stiens <71498452+StiensWout@users.noreply.github.com> Date: Thu, 3 Dec 2026 18:24:18 +0100 Subject: [PATCH 4/6] fix(server): keep ACP session cursors exactly as the agent sent them Cursors with surrounding spaces are passed through untouched, the shared limit grows to 64 KiB for cursors that accumulate across pages, and a cursor past it fails the list with an explicit error instead of quietly ending pagination. Co-authored-by: Claude Opus 5.5 --- apps/server/src/provider/AcpRegistryProbe.test.ts | 14 +++++++++----- packages/contracts/src/acpRegistry.ts | 2 +- packages/provider-acp-registry/src/server/probe.ts | 13 ++++++++----- 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/apps/server/src/provider/AcpRegistryProbe.test.ts b/apps/server/src/provider/AcpRegistryProbe.test.ts index 977ece6c1fcd9..82664997c3cbf 100644 --- a/apps/server/src/provider/AcpRegistryProbe.test.ts +++ b/apps/server/src/provider/AcpRegistryProbe.test.ts @@ -418,18 +418,18 @@ describe("ACP Registry probe", () => { }); it.effect.each([ - { name: "a long cursor verbatim", cursor: "c".repeat(2_049), expected: "c".repeat(2_049) }, { name: "a cursor at the limit", cursor: "c".repeat(ACP_REGISTRY_SESSION_CURSOR_MAX_LENGTH), expected: "c".repeat(ACP_REGISTRY_SESSION_CURSOR_MAX_LENGTH), }, + { name: "a cursor with surrounding spaces", cursor: " c c ", expected: " c c " }, + { name: "no cursor for an empty one", cursor: "", expected: null }, { - name: "no cursor past the limit", + name: "an error for a cursor past the limit", cursor: "c".repeat(ACP_REGISTRY_SESSION_CURSOR_MAX_LENGTH + 1), - expected: null, + expected: "The ACP agent returned a session page cursor that is too long.", }, - { name: "no empty cursor", cursor: "", expected: null }, ])("returns $name for the next session page", ({ cursor, expected }) => { const catalog = AcpRegistrySupport.AcpRegistryCatalog.of({ search: () => Effect.die("unused search"), @@ -466,7 +466,11 @@ describe("ACP Registry probe", () => { cwd: process.cwd(), environment: process.env, }).pipe( - Effect.map((listed) => expect(listed.nextCursor).toBe(expected)), + Effect.match({ + onSuccess: (listed) => listed.nextCursor, + onFailure: (error) => error.message, + }), + Effect.map((nextCursor) => expect(nextCursor).toBe(expected)), Effect.provideService(AcpRegistrySupport.AcpRegistryCatalog, catalog), Effect.provide(Layer.mergeAll(NodeServices.layer, NodeCrypto.layer)), ); diff --git a/packages/contracts/src/acpRegistry.ts b/packages/contracts/src/acpRegistry.ts index 47e28dce4776d..bbc4551da1d6d 100644 --- a/packages/contracts/src/acpRegistry.ts +++ b/packages/contracts/src/acpRegistry.ts @@ -156,7 +156,7 @@ export const AcpRegistrySession = Schema.Struct({ export type AcpRegistrySession = typeof AcpRegistrySession.Type; // ACP cursors are opaque; agents may encode the pages they already returned in them. -export const ACP_REGISTRY_SESSION_CURSOR_MAX_LENGTH = 16_384; +export const ACP_REGISTRY_SESSION_CURSOR_MAX_LENGTH = 65_536; const AcpRegistrySessionCursor = Schema.String.check( Schema.isMaxLength(ACP_REGISTRY_SESSION_CURSOR_MAX_LENGTH), ); diff --git a/packages/provider-acp-registry/src/server/probe.ts b/packages/provider-acp-registry/src/server/probe.ts index ac3ac9a376600..c12cc30e26fda 100644 --- a/packages/provider-acp-registry/src/server/probe.ts +++ b/packages/provider-acp-registry/src/server/probe.ts @@ -870,6 +870,13 @@ export const listAcpRegistrySessions = Effect.fn("AcpRegistryProbe.listSessions" const runtime = yield* makeAcpRegistryManagementRuntime(input); const initialized = yield* runtime.initialize(); const listed = yield* runtime.listSessions(input.cursor); + // Cursors are opaque, so one that does not fit is rejected rather than altered or dropped. + if ((listed.nextCursor?.length ?? 0) > ACP_REGISTRY_SESSION_CURSOR_MAX_LENGTH) { + return yield* new AcpRegistryOperationError({ + reason: "probe_failed", + message: "The ACP agent returned a session page cursor that is too long.", + }); + } const sessions = listed.sessions.slice(0, 256).flatMap((session) => { const sessionId = boundedOpaqueValue(session.sessionId, 1_024); const cwd = boundedOpaqueValue(session.cwd, 4_096); @@ -898,11 +905,7 @@ export const listAcpRegistrySessions = Effect.fn("AcpRegistryProbe.listSessions" }); return AcpRegistryListSessionsResult.make({ sessions, - // A shortened cursor names a different page, so an oversized one ends paging instead. - nextCursor: - listed.nextCursor === undefined || listed.nextCursor === null - ? null - : (boundedOpaqueValue(listed.nextCursor, ACP_REGISTRY_SESSION_CURSOR_MAX_LENGTH) ?? null), + nextCursor: listed.nextCursor || null, canLoad: initialized.agentCapabilities?.loadSession === true, canResume: initialized.agentCapabilities?.sessionCapabilities?.resume != null, canDelete: initialized.agentCapabilities?.sessionCapabilities?.delete != null, From fd2b37f7c3a940b4a2646dadce78dbf5f5e86700 Mon Sep 17 00:00:00 2001 From: Julius Marminge Date: Thu, 3 Dec 2026 20:45:18 +0000 Subject: [PATCH 5/6] test(server): keep only the cursor cases that catch a regression Co-Authored-By: Claude Opus 5.5 --- apps/server/src/provider/AcpRegistryProbe.test.ts | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/apps/server/src/provider/AcpRegistryProbe.test.ts b/apps/server/src/provider/AcpRegistryProbe.test.ts index 82664997c3cbf..4f53d2eca66e2 100644 --- a/apps/server/src/provider/AcpRegistryProbe.test.ts +++ b/apps/server/src/provider/AcpRegistryProbe.test.ts @@ -419,12 +419,10 @@ describe("ACP Registry probe", () => { it.effect.each([ { - name: "a cursor at the limit", - cursor: "c".repeat(ACP_REGISTRY_SESSION_CURSOR_MAX_LENGTH), - expected: "c".repeat(ACP_REGISTRY_SESSION_CURSOR_MAX_LENGTH), + name: "an unaltered cursor at the limit", + cursor: ` ${"c".repeat(ACP_REGISTRY_SESSION_CURSOR_MAX_LENGTH - 2)} `, + expected: ` ${"c".repeat(ACP_REGISTRY_SESSION_CURSOR_MAX_LENGTH - 2)} `, }, - { name: "a cursor with surrounding spaces", cursor: " c c ", expected: " c c " }, - { name: "no cursor for an empty one", cursor: "", expected: null }, { name: "an error for a cursor past the limit", cursor: "c".repeat(ACP_REGISTRY_SESSION_CURSOR_MAX_LENGTH + 1), From 234e58e36320c39d740c8f689408c057a7dcd2fb Mon Sep 17 00:00:00 2001 From: Julius Marminge Date: Thu, 3 Dec 2026 21:01:01 +0000 Subject: [PATCH 6/6] fix(server): keep older clients listing ACP sessions when a cursor is long Clients built before this change decode nextCursor with a 2,048-character limit, so a longer cursor there would fail the whole list. nextCursor keeps that limit and a cursor past it travels in the new longNextCursor field, which older clients ignore. Co-Authored-By: Claude Opus 5.5 --- apps/server/src/provider/AcpRegistryProbe.test.ts | 6 +++--- .../components/settings/AcpSessionManagementSection.tsx | 2 +- packages/contracts/src/acpRegistry.ts | 7 ++++++- packages/provider-acp-registry/src/server/probe.ts | 7 ++++++- 4 files changed, 16 insertions(+), 6 deletions(-) diff --git a/apps/server/src/provider/AcpRegistryProbe.test.ts b/apps/server/src/provider/AcpRegistryProbe.test.ts index 4f53d2eca66e2..c243cd1c321ff 100644 --- a/apps/server/src/provider/AcpRegistryProbe.test.ts +++ b/apps/server/src/provider/AcpRegistryProbe.test.ts @@ -421,7 +421,7 @@ describe("ACP Registry probe", () => { { name: "an unaltered cursor at the limit", cursor: ` ${"c".repeat(ACP_REGISTRY_SESSION_CURSOR_MAX_LENGTH - 2)} `, - expected: ` ${"c".repeat(ACP_REGISTRY_SESSION_CURSOR_MAX_LENGTH - 2)} `, + expected: [null, ` ${"c".repeat(ACP_REGISTRY_SESSION_CURSOR_MAX_LENGTH - 2)} `], }, { name: "an error for a cursor past the limit", @@ -465,10 +465,10 @@ describe("ACP Registry probe", () => { environment: process.env, }).pipe( Effect.match({ - onSuccess: (listed) => listed.nextCursor, + onSuccess: (listed) => [listed.nextCursor, listed.longNextCursor], onFailure: (error) => error.message, }), - Effect.map((nextCursor) => expect(nextCursor).toBe(expected)), + Effect.map((nextCursor) => expect(nextCursor).toEqual(expected)), Effect.provideService(AcpRegistrySupport.AcpRegistryCatalog, catalog), Effect.provide(Layer.mergeAll(NodeServices.layer, NodeCrypto.layer)), ); diff --git a/apps/web/src/components/settings/AcpSessionManagementSection.tsx b/apps/web/src/components/settings/AcpSessionManagementSection.tsx index 6ac63a01837d2..a20fe552d30e6 100644 --- a/apps/web/src/components/settings/AcpSessionManagementSection.tsx +++ b/apps/web/src/components/settings/AcpSessionManagementSection.tsx @@ -215,7 +215,7 @@ function InstanceSessionManagement( setSessions((current) => cursor === undefined ? listedSessions : [...current, ...listedSessions], ); - setNextCursor(result.value.nextCursor); + setNextCursor(result.value.nextCursor ?? result.value.longNextCursor ?? null); return; } reportFailure(gt`Could not list ACP sessions`, result); diff --git a/packages/contracts/src/acpRegistry.ts b/packages/contracts/src/acpRegistry.ts index bbc4551da1d6d..8af4b26eb5d0a 100644 --- a/packages/contracts/src/acpRegistry.ts +++ b/packages/contracts/src/acpRegistry.ts @@ -157,6 +157,7 @@ export type AcpRegistrySession = typeof AcpRegistrySession.Type; // ACP cursors are opaque; agents may encode the pages they already returned in them. export const ACP_REGISTRY_SESSION_CURSOR_MAX_LENGTH = 65_536; +export const ACP_REGISTRY_LEGACY_SESSION_CURSOR_MAX_LENGTH = 2_048; const AcpRegistrySessionCursor = Schema.String.check( Schema.isMaxLength(ACP_REGISTRY_SESSION_CURSOR_MAX_LENGTH), ); @@ -170,7 +171,11 @@ export type AcpRegistryListSessionsInput = typeof AcpRegistryListSessionsInput.T export const AcpRegistryListSessionsResult = Schema.Struct({ sessions: Schema.Array(AcpRegistrySession).check(Schema.isMaxLength(256)), - nextCursor: Schema.NullOr(AcpRegistrySessionCursor), + // Clients built before `longNextCursor` reject a longer `nextCursor`, so it carries those instead. + nextCursor: Schema.NullOr( + Schema.String.check(Schema.isMaxLength(ACP_REGISTRY_LEGACY_SESSION_CURSOR_MAX_LENGTH)), + ), + longNextCursor: Schema.optionalKey(AcpRegistrySessionCursor), canLoad: Schema.Boolean, canResume: Schema.Boolean, canDelete: Schema.Boolean, diff --git a/packages/provider-acp-registry/src/server/probe.ts b/packages/provider-acp-registry/src/server/probe.ts index c12cc30e26fda..1db342bfbb389 100644 --- a/packages/provider-acp-registry/src/server/probe.ts +++ b/packages/provider-acp-registry/src/server/probe.ts @@ -1,5 +1,6 @@ import { resolveProviderProbeTimeoutMs } from "@t3tools/provider-core/server/snapshotProbe"; import { + ACP_REGISTRY_LEGACY_SESSION_CURSOR_MAX_LENGTH, ACP_REGISTRY_SESSION_CURSOR_MAX_LENGTH, AcpRegistryListProvidersResult, AcpRegistryOperationError, @@ -903,9 +904,13 @@ export const listAcpRegistrySessions = Effect.fn("AcpRegistryProbe.listSessions" }, ]; }); + const nextCursor = listed.nextCursor || null; + const isLong = + nextCursor !== null && nextCursor.length > ACP_REGISTRY_LEGACY_SESSION_CURSOR_MAX_LENGTH; return AcpRegistryListSessionsResult.make({ sessions, - nextCursor: listed.nextCursor || null, + nextCursor: isLong ? null : nextCursor, + ...(isLong ? { longNextCursor: nextCursor } : {}), canLoad: initialized.agentCapabilities?.loadSession === true, canResume: initialized.agentCapabilities?.sessionCapabilities?.resume != null, canDelete: initialized.agentCapabilities?.sessionCapabilities?.delete != null,