Module: Anthropic::Models::Beta::BetaCompactionBlock::ToolChange

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

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::BetaCompactionBlock::ToolChange for more details.

Parameters:

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

    Attributes for the chosen variant.

    @option args [Anthropic::Models::Beta::BetaResponseToolChangeToolReference, Anthropic::Models::Beta::BetaResponseToolChangeMCPToolReference, Anthropic::Models::Beta::BetaResponseToolChangeMCPToolsetReference, Anthropic::Models::Beta::BetaToolChangeToolDefinition, Anthropic::Models::Beta::BetaResponseToolChangeToolReference, Anthropic::Models::Beta::BetaResponseToolChangeMCPToolReference, Anthropic::Models::Beta::BetaResponseToolChangeMCPToolsetReference] :tool The tool made available: a reference to a tools entry or MCP toolset, or a `to

Returns:

Raises:

  • (ArgumentError)


106
107
108
109
110
111
112
113
114
115
# File 'lib/anthropic/models/beta/beta_compaction_block.rb', line 106

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

.valuesArray<Symbol>

Returns:

  • (Array<Symbol>)


# File 'lib/anthropic/models/beta/beta_compaction_block.rb', line 85


.variantsArray(Anthropic::Models::Beta::BetaResponseToolAdditionBlock, Anthropic::Models::Beta::BetaResponseToolRemovalBlock)



# File 'lib/anthropic/models/beta/beta_compaction_block.rb', line 89


Instance Method Details

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

A compaction block returned when autocompact is triggered.

When content is None, it indicates the compaction failed to produce a valid summary (e.g., malformed output from the model). Clients may round-trip compaction blocks with null content; the server treats them as no-ops.

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

Parameters:

  • content (String, nil)

    Summary of compacted content, or null if compaction failed

  • encrypted_content (String, nil)

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

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

    Signature over the summary, to be sent back with the block verbatim

  • tool_changes (Array<Anthropic::Models::Beta::BetaResponseToolAdditionBlock, Anthropic::Models::Beta::BetaResponseToolRemovalBlock>, nil) (defaults to: nil)

    The tool changes of the compacted range: the tool_addition and tool_removal

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


63
64
65
66
67
68
69
70
71
72
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
# File 'lib/anthropic/models/beta/beta_compaction_block.rb', line 63

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

  discriminator :type

  # An entry of a `compaction` block's `tool_changes`: a tool the
  # compacted range made available, as a reference to a `tools` entry or
  # MCP toolset, or as the tool definition in effect at the end of the
  # range, by value. Send it back unchanged.
  variant :tool_addition, -> { Anthropic::Beta::BetaResponseToolAdditionBlock }

  # An entry of a `compaction` block's `tool_changes`: a tool of the
  # request's `tools` (or an MCP tool or toolset) that the compacted range
  # withdrew. Send it back unchanged.
  variant :tool_removal, -> { Anthropic::Beta::BetaResponseToolRemovalBlock }

  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::BetaResponseToolAdditionBlock, Anthropic::Models::Beta::BetaResponseToolRemovalBlock)]

  # 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::BetaCompactionBlock::ToolChange} for more details.
  #
  # @param type [Symbol, Anthropic::Models::Beta::BetaCompactionBlock::ToolChange::Type, String]
  #
  # @param args [Hash{Symbol=>Object}] Attributes for the chosen variant.
  #
  #   @option args [Anthropic::Models::Beta::BetaResponseToolChangeToolReference, Anthropic::Models::Beta::BetaResponseToolChangeMCPToolReference, Anthropic::Models::Beta::BetaResponseToolChangeMCPToolsetReference, Anthropic::Models::Beta::BetaToolChangeToolDefinition, Anthropic::Models::Beta::BetaResponseToolChangeToolReference, Anthropic::Models::Beta::BetaResponseToolChangeMCPToolReference, Anthropic::Models::Beta::BetaResponseToolChangeMCPToolsetReference] :tool The tool made available: a reference to a `tools` entry or MCP toolset, or a `to
  #
  # @raise [ArgumentError]
  # @return [Anthropic::Models::Beta::BetaResponseToolAdditionBlock, Anthropic::Models::Beta::BetaResponseToolRemovalBlock]
  def self.new(type:, **args)
    case type.to_sym
    when :tool_addition
      Anthropic::Beta::BetaResponseToolAdditionBlock.new(**args)
    when :tool_removal
      Anthropic::Beta::BetaResponseToolRemovalBlock.new(**args)
    else
      raise ArgumentError, "unknown type: #{type}"
    end
  end
end

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

Returns:

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


60
# File 'sig/anthropic/models/beta/beta_compaction_block.rbs', line 60

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