跳转到内容

OpenAIResponsesCompactionSessionOptions

此内容尚不支持你的语言。

type OpenAIResponsesCompactionSessionOptions = object;
optional client: OpenAI;

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().


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.


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.

Parameter Type

context

OpenAIResponsesCompactionDecisionContext

boolean | Promise<boolean>


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 the Responses API previous_response_id flow.

Defaults to an in-memory session for demos.

Name Type

[OPENAI_SESSION_API]?

"responses"