refactor(sessions): consolidate entry state (#115299)

* refactor(sessions): consolidate entry state

* refactor(gateway): unify session kind classification

* refactor(sessions): keep entry state types private

* test(sessions): drop retired pending delivery case

* fix(sessions): clear stale transport-only delivery
This commit is contained in:
Peter Steinberger
2026-07-28 14:31:02 -04:00
committed by GitHub
parent 642befa179
commit 8ee1d046d3
70 changed files with 1022 additions and 992 deletions
@@ -315,6 +315,11 @@ describe("plugin session extension SessionEntry projection", () => {
description: "retired transcript locator",
sessionEntrySlotKey: "transcriptPath",
});
api.registerSessionExtension({
namespace: "pending-final-text",
description: "retired pending-final field",
sessionEntrySlotKey: "pendingFinalDeliveryText",
});
},
});
@@ -342,6 +347,10 @@ describe("plugin session extension SessionEntry projection", () => {
pluginId: "slot-collision",
message: "sessionEntrySlotKey is reserved by SessionEntry: transcriptPath",
},
{
pluginId: "slot-collision",
message: "sessionEntrySlotKey is reserved by SessionEntry: pendingFinalDeliveryText",
},
]);
});
+20 -18
View File
@@ -111,13 +111,6 @@ const SESSION_ENTRY_RESERVED_SLOT_KEY_LIST = [
"outputTokens",
"totalTokens",
"pendingFinalDelivery",
"pendingFinalDeliveryCreatedAt",
"pendingFinalDeliveryLastAttemptAt",
"pendingFinalDeliveryAttemptCount",
"pendingFinalDeliveryLastError",
"pendingFinalDeliveryText",
"pendingFinalDeliveryContext",
"pendingFinalDeliveryIntentId",
"restartRecoveryDeliveryContext",
"restartRecoveryDeliveryMediaUrls",
"restartRecoveryDisableMessageTool",
@@ -143,19 +136,12 @@ const SESSION_ENTRY_RESERVED_SLOT_KEY_LIST = [
"model",
"modelSelectionLocked",
"agentHarnessId",
"fallbackNoticeSelectedModel",
"fallbackNoticeActiveModel",
"fallbackNoticeReason",
"fallbackNotice",
"contextTokens",
"contextBudgetStatus",
"compactionCount",
"compactionCheckpoints",
"memoryFlushAt",
"memoryFlushCompactionCount",
"memoryFlushContextHash",
"memoryFlushFailureCount",
"memoryFlushLastFailedAt",
"memoryFlushLastFailureError",
"memoryFlush",
"cliSessionIds",
"cliSessionBindings",
"acpSessionBinding",
@@ -193,7 +179,7 @@ type SessionEntryReservedSlotSetValue = [MissingSessionEntryReservedSlotKey] ext
const SESSION_ENTRY_RESERVED_SLOT_KEYS = new Set<SessionEntryReservedSlotSetValue>(
SESSION_ENTRY_RESERVED_SLOT_KEY_LIST,
);
const RETIRED_SESSION_DELIVERY_SLOT_KEYS = new Set<string>([
const RETIRED_SESSION_SLOT_KEYS = new Set<string>([
"channel",
"origin",
"route",
@@ -202,6 +188,22 @@ const RETIRED_SESSION_DELIVERY_SLOT_KEYS = new Set<string>([
"lastTo",
"lastAccountId",
"lastThreadId",
"pendingFinalDeliveryCreatedAt",
"pendingFinalDeliveryLastAttemptAt",
"pendingFinalDeliveryAttemptCount",
"pendingFinalDeliveryLastError",
"pendingFinalDeliveryText",
"pendingFinalDeliveryContext",
"pendingFinalDeliveryIntentId",
"fallbackNoticeSelectedModel",
"fallbackNoticeActiveModel",
"fallbackNoticeReason",
"memoryFlushAt",
"memoryFlushCompactionCount",
"memoryFlushContextHash",
"memoryFlushFailureCount",
"memoryFlushLastFailedAt",
"memoryFlushLastFailureError",
]);
const OBJECT_PROTOTYPE_RESERVED_SLOT_KEYS = new Set<string>([
"prototype",
@@ -226,7 +228,7 @@ export function normalizeSessionEntrySlotKey(
error: "sessionEntrySlotKey must be an identifier-style field name",
};
}
if (SESSION_ENTRY_RESERVED_SLOT_KEYS.has(key) || RETIRED_SESSION_DELIVERY_SLOT_KEYS.has(key)) {
if (SESSION_ENTRY_RESERVED_SLOT_KEYS.has(key) || RETIRED_SESSION_SLOT_KEYS.has(key)) {
return {
ok: false,
error: `sessionEntrySlotKey is reserved by SessionEntry: ${key}`,