Module: Anthropic::Models::Beta::BetaContextManagementConfig::Edit

Extended by:
Internal::Type::Union
Defined in:
lib/anthropic/models/beta/beta_context_management_config.rb,
sig/anthropic/models/beta/beta_context_management_config.rbs

Defined Under Namespace

Modules: Type

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Internal::Type::Union

==, ===, coerce, derefed_variants, dump, hash, inspect, to_sorbet_type, variants

Methods included from Internal::Util::SorbetRuntimeSupport

#const_missing, #define_sorbet_constant!, #sorbet_constant_defined?, #to_sorbet_type, to_sorbet_type

Methods included from Internal::Type::Converter

#coerce, coerce, #dump, dump, inspect, #inspect, meta_info, new_coerce_state, type_info

Class Method Details

.new(type:, **args) ⇒ Anthropic::Models::Beta::BetaClearToolUses20250919Edit, ...

Creates a new instance of the variant class whose type matches the given value, passing the remaining arguments to its constructor.

Some parameter documentations has been truncated, see Anthropic::Models::Beta::BetaContextManagementConfig::Edit for more details.

Parameters:

  • type (Symbol, Anthropic::Models::Beta::BetaContextManagementConfig::Edit::Type, String)
  • args (Hash{Symbol=>Object}) —

    Attributes for the chosen variant.

    @option args [Anthropic::Models::Beta::BetaInputTokensClearAtLeast, nil] :clear_at_least Minimum number of tokens that must be cleared when triggered. Context will only

    @option args [Boolean, Array, nil] :clear_tool_inputs Whether to clear all tool inputs (bool) or specific tool inputs to clear (list)

    @option args [Array, nil] :exclude_tools Tool names whose uses are preserved from clearing

    @option args [Anthropic::Models::Beta::BetaToolUsesKeep, Anthropic::Models::Beta::BetaThinkingTurns, Anthropic::Models::Beta::BetaAllThinkingTurns, Symbol, :all] :keep Number of tool uses to retain in the conversation

    @option args [Anthropic::Models::Beta::BetaInputTokensTrigger, Anthropic::Models::Beta::BetaToolUsesTrigger, Anthropic::Models::Beta::BetaInputTokensTrigger, nil] :trigger Condition that triggers the context management strategy

    @option args [String, nil] :instructions Additional instructions for summarization.

    @option args [Boolean] :pause_after_compaction Whether to pause after compaction and return the compaction block to the user.

Returns:

Raises:

  • (ArgumentError)


69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/anthropic/models/beta/beta_context_management_config.rb', line 69

def self.new(type:, **args)
  case type.to_sym
  when :clear_tool_uses_20250919
    Anthropic::Beta::BetaClearToolUses20250919Edit.new(**args)
  when :clear_thinking_20251015
    Anthropic::Beta::BetaClearThinking20251015Edit.new(**args)
  when :compact_20260112
    Anthropic::Beta::BetaCompact20260112Edit.new(**args)
  else
    raise ArgumentError, "unknown type: #{type}"
  end
end

.values ⇒ Array<Symbol>

Returns:

  • (Array<Symbol>)


# File 'lib/anthropic/models/beta/beta_context_management_config.rb', line 36


.variants ⇒ Array(Anthropic::Models::Beta::BetaClearToolUses20250919Edit, Anthropic::Models::Beta::BetaClearThinking20251015Edit, Anthropic::Models::Beta::BetaCompact20260112Edit)



# File 'lib/anthropic/models/beta/beta_context_management_config.rb', line 40


Instance Method Details

#initialize(edits: nil) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/anthropic/models/beta/beta_context_management_config.rb', line 17

module Edit
  extend Anthropic::Internal::Type::Union

  discriminator :type

  variant :clear_tool_uses_20250919, -> { Anthropic::Beta::BetaClearToolUses20250919Edit }

  variant :clear_thinking_20251015, -> { Anthropic::Beta::BetaClearThinking20251015Edit }

  # Automatically compact older context when reaching the configured trigger threshold.
  variant :compact_20260112, -> { Anthropic::Beta::BetaCompact20260112Edit }

  module Type
    extend Anthropic::Internal::Type::Enum

    CLEAR_TOOL_USES_20250919 = :clear_tool_uses_20250919
    CLEAR_THINKING_20251015 = :clear_thinking_20251015
    COMPACT_20260112 = :compact_20260112

    # @!method self.values
    #   @return [Array<Symbol>]
  end

  # @!method self.variants
  #   @return [Array(Anthropic::Models::Beta::BetaClearToolUses20250919Edit, Anthropic::Models::Beta::BetaClearThinking20251015Edit, Anthropic::Models::Beta::BetaCompact20260112Edit)]

  # Creates a new instance of the variant class whose `type` matches the given
  # value, passing the remaining arguments to its constructor.
  #
  # Some parameter documentations has been truncated, see
  # {Anthropic::Models::Beta::BetaContextManagementConfig::Edit} for more details.
  #
  # @param type [Symbol, Anthropic::Models::Beta::BetaContextManagementConfig::Edit::Type, String]
  #
  # @param args [Hash{Symbol=>Object}] Attributes for the chosen variant.
  #
  #   @option args [Anthropic::Models::Beta::BetaInputTokensClearAtLeast, nil] :clear_at_least Minimum number of tokens that must be cleared when triggered. Context will only
  #
  #   @option args [Boolean, Array<String>, nil] :clear_tool_inputs Whether to clear all tool inputs (bool) or specific tool inputs to clear (list)
  #
  #   @option args [Array<String>, nil] :exclude_tools Tool names whose uses are preserved from clearing
  #
  #   @option args [Anthropic::Models::Beta::BetaToolUsesKeep, Anthropic::Models::Beta::BetaThinkingTurns, Anthropic::Models::Beta::BetaAllThinkingTurns, Symbol, :all] :keep Number of tool uses to retain in the conversation
  #
  #   @option args [Anthropic::Models::Beta::BetaInputTokensTrigger, Anthropic::Models::Beta::BetaToolUsesTrigger, Anthropic::Models::Beta::BetaInputTokensTrigger, nil] :trigger Condition that triggers the context management strategy
  #
  #   @option args [String, nil] :instructions Additional instructions for summarization.
  #
  #   @option args [Boolean] :pause_after_compaction Whether to pause after compaction and return the compaction block to the user.
  #
  # @raise [ArgumentError]
  # @return [Anthropic::Models::Beta::BetaClearToolUses20250919Edit, Anthropic::Models::Beta::BetaClearThinking20251015Edit, Anthropic::Models::Beta::BetaCompact20260112Edit]
  def self.new(type:, **args)
    case type.to_sym
    when :clear_tool_uses_20250919
      Anthropic::Beta::BetaClearToolUses20250919Edit.new(**args)
    when :clear_thinking_20251015
      Anthropic::Beta::BetaClearThinking20251015Edit.new(**args)
    when :compact_20260112
      Anthropic::Beta::BetaCompact20260112Edit.new(**args)
    else
      raise ArgumentError, "unknown type: #{type}"
    end
  end
end

#self?.variants ⇒ ::Array[Anthropic::Models::Beta::BetaContextManagementConfig::edit]

Returns:

  • (::Array[Anthropic::Models::Beta::BetaContextManagementConfig::edit])


49
# File 'sig/anthropic/models/beta/beta_context_management_config.rbs', line 49

def self?.variants: -> ::Array[Anthropic::Models::Beta::BetaContextManagementConfig::edit]