Tools and state
openai_responses_compact
Summarizes conversation history when the token count exceeds a configured threshold.
On this page
Summarizes conversation history when the token count exceeds a configured threshold.
Configuration Notes
compact_threshold in context_management must be an integer of at least 1000. Invalid or missing compact_threshold values produce an invalid_request_error.
Compaction applies in two scenarios:
Rehydrated history - stored history loaded via
previous_response_idorconversation. Only the stored history is summarized; the current turn is preserved.Explicit compact -
POST /v1/responses/compactwith a requiredmodeland an optional inlineinputconversation and/orprevious_response_id. Loads any stored history, appends the inline input, summarizes the combined conversation, and returns aresponse.compactionobject (withoutputandusage) per the OpenAI contract. A schema-valid empty conversation is not rejected: no callout is made and a no-op compaction is persisted (issue #1139).
Direct input requests (full conversation in input with no stored history) skip reactive compaction because state.input == state.messages - there is no separable “current turn” to preserve after summarization. Requests without rehydrated history are released without compaction.
On listeners with openai_agentic_loop.max_retained_bytes, explicit compact uses a bounded Store read and caps the summarization response before it is buffered. Source expansion and persistence are charged to one request-wide budget. An overflow returns 413 before the next payload owner is created.
Praxis runs StreamBuffer body hooks before header-phase request filters. This filter therefore requires allow_pre_security_callout: true and should only be used behind an outer authentication and authorization boundary.
Configuration
| Field | Type | Required | Description |
|---|---|---|---|
allow_pre_security_callout | bool | no | Allow summarization callouts from the StreamBuffer pre-read phase, before header-phase security filters execute. This must be explicitly enabled only when an outer trust boundary authenticates and authorizes requests before they reach this listener. |
inference_url | string | yes | URL of the inference backend for summarization calls. E.g., "http://localhost:11434/v1/chat/completions" |
allow_private_inference_url | bool | no | Allow the inference target to resolve to non-public addresses. Cloud metadata, unspecified, and multicast addresses remain blocked. |
default_model | string | no | Default model for summarization when not overridden in the request’s context_management. |
tiktoken_encoding | string | no | Tiktoken encoding name for local token estimation of the conversation text. |
summary_prefix | string | no | Prefix prepended to the summary when translating compaction items to backend messages. Defaults to "[Previous conversation summary]\n\n". |
timeout_ms | integer | no | Callout timeout in milliseconds. |
on_failure | closed | open | no | Failure mode for the inference callout. |
status_on_error | integer | no | HTTP error status code (400..=599) to return when rejecting on error. |
Examples
Example 1
filter: openai_responses_compact
allow_pre_security_callout: true
inference_url: "http://localhost:11434/v1/chat/completions"
allow_private_inference_url: true
default_model: llama3.2:1b
Example 2
filter: openai_responses_compact
allow_pre_security_callout: true
inference_url: "http://localhost:11434/v1/chat/completions"
allow_private_inference_url: true
default_model: gpt-4o-mini
tiktoken_encoding: cl100k_base
summary_prefix: "[Previous conversation summary]\n\n"
timeout_ms: 30000
on_failure: closed
status_on_error: 502