Class BetaCompactionBlockParam.ToolChange
-
- All Implemented Interfaces:
public final class BetaCompactionBlockParam.ToolChange
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public interfaceBetaCompactionBlockParam.ToolChange.VisitorAn interface that defines how to map each variant of ToolChange to a value of type T.
public final classBetaCompactionBlockParam.ToolChange.Type
-
Method Summary
Modifier and Type Method Description final Optional<BetaRequestToolAdditionBlock>addition()Mid-conversation directive to make a tool available. final Optional<BetaRequestToolRemovalBlock>removal()Mid-conversation directive to withdraw a tool. final Optional<JsonValue>_json()final BetaCompactionBlockParam.ToolChange.Typetype()final Optional<BetaCacheControlEphemeral>cacheControl()final BooleanisAddition()final BooleanisRemoval()final BetaRequestToolAdditionBlockasAddition()Mid-conversation directive to make a tool available. final BetaRequestToolRemovalBlockasRemoval()Mid-conversation directive to withdraw a tool. final <T extends Any> Taccept(BetaCompactionBlockParam.ToolChange.Visitor<T> visitor)Maps this instance's current variant to a value of type T using the given visitor. final BetaCompactionBlockParam.ToolChangevalidate()Validates that the types of all values in this object match their expected types recursively. final BooleanisValid()Booleanequals(Object other)IntegerhashCode()StringtoString()final static BetaCompactionBlockParam.ToolChangeofAddition(BetaRequestToolAdditionBlock addition)Mid-conversation directive to make a tool available. final static BetaCompactionBlockParam.ToolChangeofAddition(BetaRequestToolAdditionBlock.Tool tool)Returns an immutable instance of ToolChange whose ofAddition variant is built from the given required tool. final static BetaCompactionBlockParam.ToolChangeofAddition(BetaToolChangeToolReference reference)Alias for calling ofAddition with BetaRequestToolAdditionBlock.Tool.ofReference(reference).final static BetaCompactionBlockParam.ToolChangeofAddition(BetaResponseToolChangeToolReference reference)Alias for calling ofAddition with reference.toParam().final static BetaCompactionBlockParam.ToolChangeofAddition(BetaToolChangeMcpToolReference mcpToolReference)Alias for calling ofAddition with BetaRequestToolAdditionBlock.Tool.ofMcpToolReference(mcpToolReference).final static BetaCompactionBlockParam.ToolChangeofAddition(BetaResponseToolChangeMcpToolReference mcpToolReference)Alias for calling ofAddition with mcpToolReference.toParam().final static BetaCompactionBlockParam.ToolChangeofAddition(BetaToolChangeMcpToolsetReference mcpToolsetReference)Alias for calling ofAddition with BetaRequestToolAdditionBlock.Tool.ofMcpToolsetReference(mcpToolsetReference).final static BetaCompactionBlockParam.ToolChangeofAddition(BetaResponseToolChangeMcpToolsetReference mcpToolsetReference)Alias for calling ofAddition with mcpToolsetReference.toParam().final static BetaCompactionBlockParam.ToolChangeofAddition(BetaToolChangeToolDefinitionParam definition)Alias for calling ofAddition with BetaRequestToolAdditionBlock.Tool.ofDefinition(definition).final static BetaCompactionBlockParam.ToolChangeofAddition(BetaToolChangeToolDefinition definition)Alias for calling ofAddition with definition.toParam().final static BetaCompactionBlockParam.ToolChangeofRemoval(BetaRequestToolRemovalBlock removal)Mid-conversation directive to withdraw a tool. final static BetaCompactionBlockParam.ToolChangeofRemoval(BetaRequestToolRemovalBlock.Tool tool)Returns an immutable instance of ToolChange whose ofRemoval variant is built from the given required tool. final static BetaCompactionBlockParam.ToolChangeofRemoval(BetaToolChangeToolReference reference)Alias for calling ofRemoval with BetaRequestToolRemovalBlock.Tool.ofReference(reference).final static BetaCompactionBlockParam.ToolChangeofRemoval(BetaResponseToolChangeToolReference reference)Alias for calling ofRemoval with reference.toParam().final static BetaCompactionBlockParam.ToolChangeofRemoval(BetaToolChangeMcpToolReference mcpToolReference)Alias for calling ofRemoval with BetaRequestToolRemovalBlock.Tool.ofMcpToolReference(mcpToolReference).final static BetaCompactionBlockParam.ToolChangeofRemoval(BetaResponseToolChangeMcpToolReference mcpToolReference)Alias for calling ofRemoval with mcpToolReference.toParam().final static BetaCompactionBlockParam.ToolChangeofRemoval(BetaToolChangeMcpToolsetReference mcpToolsetReference)Alias for calling ofRemoval with BetaRequestToolRemovalBlock.Tool.ofMcpToolsetReference(mcpToolsetReference).final static BetaCompactionBlockParam.ToolChangeofRemoval(BetaResponseToolChangeMcpToolsetReference mcpToolsetReference)Alias for calling ofRemoval with mcpToolsetReference.toParam().-
-
Method Detail
-
addition
final Optional<BetaRequestToolAdditionBlock> addition()
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.
-
removal
final Optional<BetaRequestToolRemovalBlock> removal()
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.
-
type
final BetaCompactionBlockParam.ToolChange.Type type()
-
cacheControl
final Optional<BetaCacheControlEphemeral> cacheControl()
-
isAddition
final Boolean isAddition()
-
asAddition
final BetaRequestToolAdditionBlock asAddition()
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.
-
asRemoval
final BetaRequestToolRemovalBlock asRemoval()
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.
-
accept
final <T extends Any> T accept(BetaCompactionBlockParam.ToolChange.Visitor<T> visitor)
Maps this instance's current variant to a value of type T using the given visitor.
Note that this method is not forwards compatible with new variants from the API, unless visitor overrides Visitor.unknown. To handle variants not known to this version of the SDK gracefully, consider overriding Visitor.unknown:
import com.anthropic.core.JsonValue; import java.util.Optional; Optional<String> result = toolChange.accept(new ToolChange.Visitor<Optional<String>>() { @Override public Optional<String> visitAddition(BetaRequestToolAdditionBlock addition) { return Optional.of(addition.toString()); } // ... @Override public Optional<String> unknown(JsonValue json) { // Or inspect the `json`. return Optional.empty(); } });
-
validate
final BetaCompactionBlockParam.ToolChange validate()
Validates that the types of all values in this object match their expected types recursively.
This method is not forwards compatible with new types from the API for existing fields.
-
ofAddition
final static BetaCompactionBlockParam.ToolChange ofAddition(BetaRequestToolAdditionBlock addition)
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.
-
ofAddition
final static BetaCompactionBlockParam.ToolChange ofAddition(BetaRequestToolAdditionBlock.Tool tool)
Returns an immutable instance of ToolChange whose ofAddition variant is built from the given required tool.
-
ofAddition
final static BetaCompactionBlockParam.ToolChange ofAddition(BetaToolChangeToolReference reference)
Alias for calling ofAddition with
BetaRequestToolAdditionBlock.Tool.ofReference(reference).
-
ofAddition
final static BetaCompactionBlockParam.ToolChange ofAddition(BetaResponseToolChangeToolReference reference)
Alias for calling ofAddition with
reference.toParam().
-
ofAddition
final static BetaCompactionBlockParam.ToolChange ofAddition(BetaToolChangeMcpToolReference mcpToolReference)
Alias for calling ofAddition with
BetaRequestToolAdditionBlock.Tool.ofMcpToolReference(mcpToolReference).
-
ofAddition
final static BetaCompactionBlockParam.ToolChange ofAddition(BetaResponseToolChangeMcpToolReference mcpToolReference)
Alias for calling ofAddition with
mcpToolReference.toParam().
-
ofAddition
final static BetaCompactionBlockParam.ToolChange ofAddition(BetaToolChangeMcpToolsetReference mcpToolsetReference)
Alias for calling ofAddition with
BetaRequestToolAdditionBlock.Tool.ofMcpToolsetReference(mcpToolsetReference).
-
ofAddition
final static BetaCompactionBlockParam.ToolChange ofAddition(BetaResponseToolChangeMcpToolsetReference mcpToolsetReference)
Alias for calling ofAddition with
mcpToolsetReference.toParam().
-
ofAddition
final static BetaCompactionBlockParam.ToolChange ofAddition(BetaToolChangeToolDefinitionParam definition)
Alias for calling ofAddition with
BetaRequestToolAdditionBlock.Tool.ofDefinition(definition).
-
ofAddition
final static BetaCompactionBlockParam.ToolChange ofAddition(BetaToolChangeToolDefinition definition)
Alias for calling ofAddition with
definition.toParam().
-
ofRemoval
final static BetaCompactionBlockParam.ToolChange ofRemoval(BetaRequestToolRemovalBlock removal)
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.
-
ofRemoval
final static BetaCompactionBlockParam.ToolChange ofRemoval(BetaRequestToolRemovalBlock.Tool tool)
Returns an immutable instance of ToolChange whose ofRemoval variant is built from the given required tool.
-
ofRemoval
final static BetaCompactionBlockParam.ToolChange ofRemoval(BetaToolChangeToolReference reference)
Alias for calling ofRemoval with
BetaRequestToolRemovalBlock.Tool.ofReference(reference).
-
ofRemoval
final static BetaCompactionBlockParam.ToolChange ofRemoval(BetaResponseToolChangeToolReference reference)
Alias for calling ofRemoval with
reference.toParam().
-
ofRemoval
final static BetaCompactionBlockParam.ToolChange ofRemoval(BetaToolChangeMcpToolReference mcpToolReference)
Alias for calling ofRemoval with
BetaRequestToolRemovalBlock.Tool.ofMcpToolReference(mcpToolReference).
-
ofRemoval
final static BetaCompactionBlockParam.ToolChange ofRemoval(BetaResponseToolChangeMcpToolReference mcpToolReference)
Alias for calling ofRemoval with
mcpToolReference.toParam().
-
ofRemoval
final static BetaCompactionBlockParam.ToolChange ofRemoval(BetaToolChangeMcpToolsetReference mcpToolsetReference)
Alias for calling ofRemoval with
BetaRequestToolRemovalBlock.Tool.ofMcpToolsetReference(mcpToolsetReference).
-
ofRemoval
final static BetaCompactionBlockParam.ToolChange ofRemoval(BetaResponseToolChangeMcpToolsetReference mcpToolsetReference)
Alias for calling ofRemoval with
mcpToolsetReference.toParam().
-
-
-
-