OpenAIResponsesCompactionSessionOptions
此内容尚不支持你的语言。
type OpenAIResponsesCompactionSessionOptions = object;Properties
Section titled “Properties”client?
Section titled “client?”optional client?: OpenAIClient;OpenAI client used to call responses.compact.
When omitted, the session will use getDefaultOpenAIClient() if configured. Otherwise it
creates a new OpenAI() instance via new OpenAI().
compactionMode?
Section titled “compactionMode?”optional compactionMode?: OpenAIResponsesCompactionMode;Controls how the compaction request is built.
auto(default): Usesinputwhen the last response was not stored or no response id is available.previous_response_id: Uses the server-managed response chain.input: Sends the locally stored session items as input and does not require a response id.
maxRollbackItems?
Section titled “maxRollbackItems?”optional maxRollbackItems?: number;Optional positive integer budget for complete history snapshots used for rollback. The budget plus one must be a safe integer. Omitting the budget preserves unlimited reads.
Snapshot reads request at most this many items plus one overflow item. Oversized history
throws a UserError before the compaction API call, including forced calls. The snapshot is
refreshed and checked again after the API call, before replacing history. Automatic
compaction that passes the ownership and model-visibility checks also honors this budget.
This does not limit bytes, tokens, stored history, model input, or ordinary candidate reads. Underlying retrieval defaults remain independent of this budget.
model?
Section titled “model?”optional model?: OpenAI.ResponsesModel;The OpenAI model to use for responses.compact.
Defaults to DEFAULT_OPENAI_MODEL. The value must resemble an OpenAI model name (for example
gpt-*, o*, or a fine-tuned ft:gpt-* identifier), otherwise the constructor throws.
shouldTriggerCompaction?
Section titled “shouldTriggerCompaction?”optional shouldTriggerCompaction?: (context) => boolean | Promise<boolean>;Custom decision hook that determines whether to call responses.compact.
The default implementation compares the length of OpenAIResponsesCompactionDecisionContext.compactionCandidateItems to an internal threshold (10). Override this to support token-based triggers or other heuristics using OpenAIResponsesCompactionDecisionContext.compactionCandidateItems or OpenAIResponsesCompactionDecisionContext.sessionItems.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
|
|
Returns
Section titled “Returns”boolean | Promise<boolean>
underlyingSession?
Section titled “underlyingSession?”optional underlyingSession?: Session & object;Session store that receives items and holds the compacted history.
The underlying session is the source of truth for persisted items. Compaction clears the
underlying session and writes the output items returned by responses.compact.
This must not be an OpenAIConversationsSession, because compaction relies on locally stored
items and replaces the underlying session history after responses.compact.
Defaults to an in-memory session for demos.
Type Declaration
Section titled “Type Declaration”| Name | Type |
|---|---|
|
|
|