Class: ClaudeAgentSDK::CompactMetadata

Inherits:
Object
  • Object
show all
Defined in:
lib/claude_agent_sdk/types.rb

Overview

Metadata about a compaction event

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(pre_tokens: nil, post_tokens: nil, trigger: nil, custom_instructions: nil, preserved_segment: nil) ⇒ CompactMetadata

Returns a new instance of CompactMetadata.



226
227
228
229
230
231
232
# File 'lib/claude_agent_sdk/types.rb', line 226

def initialize(pre_tokens: nil, post_tokens: nil, trigger: nil, custom_instructions: nil, preserved_segment: nil)
  @pre_tokens = pre_tokens
  @post_tokens = post_tokens
  @trigger = trigger # "manual" or "auto"
  @custom_instructions = custom_instructions
  @preserved_segment = preserved_segment # Hash with head_uuid, anchor_uuid, tail_uuid
end

Instance Attribute Details

#custom_instructionsObject

Returns the value of attribute custom_instructions.



224
225
226
# File 'lib/claude_agent_sdk/types.rb', line 224

def custom_instructions
  @custom_instructions
end

#post_tokensObject

Returns the value of attribute post_tokens.



224
225
226
# File 'lib/claude_agent_sdk/types.rb', line 224

def post_tokens
  @post_tokens
end

#pre_tokensObject

Returns the value of attribute pre_tokens.



224
225
226
# File 'lib/claude_agent_sdk/types.rb', line 224

def pre_tokens
  @pre_tokens
end

#preserved_segmentObject

Returns the value of attribute preserved_segment.



224
225
226
# File 'lib/claude_agent_sdk/types.rb', line 224

def preserved_segment
  @preserved_segment
end

#triggerObject

Returns the value of attribute trigger.



224
225
226
# File 'lib/claude_agent_sdk/types.rb', line 224

def trigger
  @trigger
end

Class Method Details

.from_hash(hash) ⇒ Object



234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
# File 'lib/claude_agent_sdk/types.rb', line 234

def self.from_hash(hash)
  return nil unless hash.is_a?(Hash)

  preserved = hash[:preserved_segment] || hash['preserved_segment'] ||
              hash[:preservedSegment] || hash['preservedSegment']

  new(
    pre_tokens: hash[:pre_tokens] || hash['pre_tokens'] || hash[:preTokens] || hash['preTokens'],
    post_tokens: hash[:post_tokens] || hash['post_tokens'] || hash[:postTokens] || hash['postTokens'],
    trigger: hash[:trigger] || hash['trigger'],
    custom_instructions: hash[:custom_instructions] || hash['custom_instructions'] ||
                         hash[:customInstructions] || hash['customInstructions'],
    preserved_segment: preserved
  )
end