Module: Anthropic::Models::Beta::BetaCompactionBlockParam::ToolChange

Extended by:
Internal::Type::Union
Defined in:
lib/anthropic/models/beta/beta_compaction_block_param.rb,
sig/anthropic/models/beta/beta_compaction_block_param.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::BetaRequestToolAdditionBlock, Anthropic::Models::Beta::BetaRequestToolRemovalBlock

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

Parameters:

  • type (Symbol, Anthropic::Models::Beta::BetaCompactionBlockParam::ToolChange::Type, String)
  • args (Hash{Symbol=>Object})

    Attributes for the chosen variant.

    @option args [Anthropic::Models::Beta::BetaToolChangeToolReference, Anthropic::Models::Beta::BetaToolChangeMCPToolReference, Anthropic::Models::Beta::BetaToolChangeMCPToolsetReference, Anthropic::Models::Beta::BetaToolChangeToolDefinitionParam, Anthropic::Models::Beta::BetaToolChangeToolReference, Anthropic::Models::Beta::BetaToolChangeMCPToolReference, Anthropic::Models::Beta::BetaToolChangeMCPToolsetReference] :tool

    @option args [Anthropic::Models::Beta::BetaCacheControlEphemeral, nil] :cache_control Create a cache control breakpoint at this content block.

Returns:

Raises:

  • (ArgumentError)


122
123
124
125
126
127
128
129
130
131
# File 'lib/anthropic/models/beta/beta_compaction_block_param.rb', line 122

def self.new(type:, **args)
  case type.to_sym
  when :tool_addition
    Anthropic::Beta::BetaRequestToolAdditionBlock.new(**args)
  when :tool_removal
    Anthropic::Beta::BetaRequestToolRemovalBlock.new(**args)
  else
    raise ArgumentError, "unknown type: #{type}"
  end
end

.valuesArray<Symbol>

Returns:

  • (Array<Symbol>)


# File 'lib/anthropic/models/beta/beta_compaction_block_param.rb', line 102

.variantsArray(Anthropic::Models::Beta::BetaRequestToolAdditionBlock, Anthropic::Models::Beta::BetaRequestToolRemovalBlock)



# File 'lib/anthropic/models/beta/beta_compaction_block_param.rb', line 106

Instance Method Details

#initialize(cache_control: nil, content: nil, encrypted_content: nil, signature: nil, tool_changes: nil, type: :compaction) ⇒ void

A compaction block containing summary of previous context.

Users should round-trip these blocks from responses to subsequent requests to maintain context across compaction boundaries.

When content is None, the block represents a failed compaction. The server treats these as no-ops. Empty string content is not allowed.

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

Parameters:

  • cache_control (Anthropic::Models::Beta::BetaCacheControlEphemeral, nil) (defaults to: nil)

    Create a cache control breakpoint at this content block.

  • content (String, nil) (defaults to: nil)

    Summary of previously compacted content, or null if compaction failed

  • encrypted_content (String, nil) (defaults to: nil)

    Opaque metadata from prior compaction, to be round-tripped verbatim

  • signature (String, nil) (defaults to: nil)

    The block's signature as returned, to be sent back verbatim

  • tool_changes (Array<Anthropic::Models::Beta::BetaRequestToolAdditionBlock, Anthropic::Models::Beta::BetaRequestToolRemovalBlock>, nil) (defaults to: nil)

    The tool changes of the compacted range, as the server returned them on this blo

  • type (Symbol, :compaction) (defaults to: :compaction)


73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
# File 'lib/anthropic/models/beta/beta_compaction_block_param.rb', line 73

module ToolChange
  extend Anthropic::Internal::Type::Union

  discriminator :type

  # Mid-conversation directive to make a tool available.
  #
  # ``tool`` is a reference to a tool (or MCP toolset) declared in the
  # request's ``tools``. Under the ``inline-tools-2026-09-15`` beta it may
  # instead be a reference to a tool defined earlier in ``messages``, or a
  # ``tool_definition`` object that carries an inline tool definition in
  # ``definition`` (the same object a ``tools`` entry holds). An ``mcp_toolset``
  # definition also requires the ``mcp-client-2026-09-15`` beta. The tool is
  # offered to the model from this point in the conversation onward.
  variant :tool_addition, -> { Anthropic::Beta::BetaRequestToolAdditionBlock }

  # Mid-conversation directive to withdraw a tool.
  #
  # ``tool`` references a tool (or MCP toolset) by name: one declared in the
  # request's ``tools`` or defined earlier in ``messages``. It is no longer
  # offered to the model from this point in the conversation onward.
  variant :tool_removal, -> { Anthropic::Beta::BetaRequestToolRemovalBlock }

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

    TOOL_ADDITION = :tool_addition
    TOOL_REMOVAL = :tool_removal

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

  # @!method self.variants
  #   @return [Array(Anthropic::Models::Beta::BetaRequestToolAdditionBlock, Anthropic::Models::Beta::BetaRequestToolRemovalBlock)]

  # Creates a new instance of the variant class whose `type` matches the given
  # value, passing the remaining arguments to its constructor.
  #
  # @param type [Symbol, Anthropic::Models::Beta::BetaCompactionBlockParam::ToolChange::Type, String]
  #
  # @param args [Hash{Symbol=>Object}] Attributes for the chosen variant.
  #
  #   @option args [Anthropic::Models::Beta::BetaToolChangeToolReference, Anthropic::Models::Beta::BetaToolChangeMCPToolReference, Anthropic::Models::Beta::BetaToolChangeMCPToolsetReference, Anthropic::Models::Beta::BetaToolChangeToolDefinitionParam, Anthropic::Models::Beta::BetaToolChangeToolReference, Anthropic::Models::Beta::BetaToolChangeMCPToolReference, Anthropic::Models::Beta::BetaToolChangeMCPToolsetReference] :tool
  #
  #   @option args [Anthropic::Models::Beta::BetaCacheControlEphemeral, nil] :cache_control Create a cache control breakpoint at this content block.
  #
  # @raise [ArgumentError]
  # @return [Anthropic::Models::Beta::BetaRequestToolAdditionBlock, Anthropic::Models::Beta::BetaRequestToolRemovalBlock]
  def self.new(type:, **args)
    case type.to_sym
    when :tool_addition
      Anthropic::Beta::BetaRequestToolAdditionBlock.new(**args)
    when :tool_removal
      Anthropic::Beta::BetaRequestToolRemovalBlock.new(**args)
    else
      raise ArgumentError, "unknown type: #{type}"
    end
  end
end

#self?.variants::Array[Anthropic::Models::Beta::BetaCompactionBlockParam::tool_change]

Returns:

  • (::Array[Anthropic::Models::Beta::BetaCompactionBlockParam::tool_change])


65
# File 'sig/anthropic/models/beta/beta_compaction_block_param.rbs', line 65

def self?.variants: -> ::Array[Anthropic::Models::Beta::BetaCompactionBlockParam::tool_change]