Skip to content

OpenAIConversationsSession

  • Session
  • OpenAISessionApiTagged<"conversations">
new OpenAIConversationsSession(options?): OpenAIConversationsSession;
Parameter Type

options

OpenAIConversationsSessionOptions

OpenAIConversationsSession

readonly [OPENAI_SESSION_API]: "conversations";
OpenAISessionApiTagged.[OPENAI_SESSION_API]
get sessionId(): string | undefined;

string | undefined

addItems(items): Promise<void>;

Append new items to the conversation history.

Parameter Type Description

items

AgentInputItem[]

Items to add to the session history.

Promise<void>

Session.addItems

clearSession(): Promise<void>;

Remove all items that belong to the session and reset its state.

Promise<void>

Session.clearSession

getItems(limit?): Promise<AgentInputItem[]>;

Retrieve items from the conversation history.

Parameter Type Description

limit?

number

The maximum number of items to return. When provided the most recent limit items should be returned in chronological order.

Promise<AgentInputItem[]>

Session.getItems

getSessionId(): Promise<string>;

Ensure and return the identifier for this session.

Promise<string>

Session.getSessionId

popItem(): Promise<AgentInputItem | undefined>;

Remove and return the most recent item from the conversation history if it exists.

Promise<AgentInputItem | undefined>

Session.popItem

prepareHistoryItemForModelInput(item): AgentInputItem;

Optionally rewrite a stored history item before it is sent back to the model.

Session implementations can use this to strip provider-managed replay metadata while preserving their public getItems() shape for UI and deletion workflows.

Parameter Type

item

AgentInputItem

AgentInputItem

Session.prepareHistoryItemForModelInput

preserveReasoningItemIdsForPersistence(): boolean;

Optionally preserve reasoning item IDs when persisting generated output.

Some remote session stores require provider-assigned reasoning identities to accept stored reasoning items, even when model replay should omit those IDs.

boolean

Session.preserveReasoningItemIdsForPersistence