Module: RubyLLM::Providers::OpenAIResponses::Compaction
- Defined in:
- lib/ruby_llm/providers/openai_responses/compaction.rb
Overview
Server-side compaction support for long-running agent sessions. Automatically compacts conversation context when token count exceeds threshold.
Class Method Summary collapse
-
.apply_compaction(payload, params) ⇒ Hash
Apply compaction settings to payload.
-
.compact_url ⇒ String
URL for explicit Responses API compaction.
-
.compaction_params(compact_threshold: 200_000) ⇒ Hash
Build context_management parameter for compaction.
-
.input_tokens_url ⇒ String
URL for Responses API input token counting.
Class Method Details
.apply_compaction(payload, params) ⇒ Hash
Apply compaction settings to payload
26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/ruby_llm/providers/openai_responses/compaction.rb', line 26 def apply_compaction(payload, params) if params[:compact_threshold] payload[:context_management] = [ { type: 'compaction', compact_threshold: params[:compact_threshold] } ] elsif params[:context_management] payload[:context_management] = params[:context_management] end payload end |
.compact_url ⇒ String
URL for explicit Responses API compaction.
40 41 42 |
# File 'lib/ruby_llm/providers/openai_responses/compaction.rb', line 40 def compact_url 'responses/compact' end |
.compaction_params(compact_threshold: 200_000) ⇒ Hash
Build context_management parameter for compaction
14 15 16 17 18 19 20 |
# File 'lib/ruby_llm/providers/openai_responses/compaction.rb', line 14 def compaction_params(compact_threshold: 200_000) { context_management: [ { type: 'compaction', compact_threshold: compact_threshold } ] } end |
.input_tokens_url ⇒ String
URL for Responses API input token counting.
46 47 48 |
# File 'lib/ruby_llm/providers/openai_responses/compaction.rb', line 46 def input_tokens_url 'responses/input_tokens' end |