OpenAIResponsesCompactionAwareSession
Interface representing a persistent session store for conversation history.
Extends
Section titled “Extends”Methods
Section titled “Methods”addItems()
Section titled “addItems()”addItems(items): Promise<void>;Append new items to the conversation history.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
| Items to add to the session history. |
Returns
Section titled “Returns”Promise<void>
Inherited from
Section titled “Inherited from”clearSession()
Section titled “clearSession()”clearSession(): Promise<void>;Remove all items that belong to the session and reset its state.
Returns
Section titled “Returns”Promise<void>
Inherited from
Section titled “Inherited from”getItems()
Section titled “getItems()”getItems(limit?): Promise<AgentInputItem[]>;Retrieve items from the conversation history.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
| The maximum number of items to return. When provided the most recent limit items should be returned in chronological order. |
Returns
Section titled “Returns”Promise<AgentInputItem[]>
Inherited from
Section titled “Inherited from”getSessionId()
Section titled “getSessionId()”getSessionId(): Promise<string>;Ensure and return the identifier for this session.
Returns
Section titled “Returns”Promise<string>
Inherited from
Section titled “Inherited from”popItem()
Section titled “popItem()”popItem(): Promise< | AgentInputItem| undefined>;Remove and return the most recent item from the conversation history if it exists.
Returns
Section titled “Returns”Promise< | AgentInputItem | undefined>
Inherited from
Section titled “Inherited from”runCompaction()
Section titled “runCompaction()”runCompaction(args?): | OpenAIResponsesCompactionResult | Promise< | OpenAIResponsesCompactionResult | null> | null;Invoked by the runner after it persists a completed turn into the session.
Implementations may decide to call responses.compact (or an equivalent API) and replace the stored history.
This hook is best-effort. Implementations should consider handling transient failures and deciding whether to retry or skip compaction for the current turn.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
|
|
Returns
Section titled “Returns”| OpenAIResponsesCompactionResult | Promise< | OpenAIResponsesCompactionResult | null> | null