Enum Class ToolDefer

java.lang.Object
java.lang.Enum<ToolDefer>
com.github.copilot.rpc.ToolDefer
All Implemented Interfaces:
Serializable, Comparable<ToolDefer>, Constable

public enum ToolDefer extends Enum<ToolDefer>
Controls whether a ToolDefinition may be deferred (loaded lazily via tool search) rather than always pre-loaded.

Set on ToolDefinition.createWithDefer(String, String, java.util.Map, ToolHandler, ToolDefer) to express the tool's deferral preference; defaults to letting the runtime decide when unset.

Since:
1.0.0
See Also:
  • Enum Constant Details

    • NONE

      public static final ToolDefer NONE
      No deferral preference set. This is an annotation-only sentinel used as the default for @CopilotTool(defer = ToolDefer.NONE).

      This constant must not be passed to ToolDefinition factory methods. The annotation processor and ToolDefinition.fromObject() must map NONE to a null field reference so that @JsonInclude(NON_NULL) on ToolDefinition omits the defer key from the JSON-RPC wire payload entirely (matching the nullable/optional semantics used by all other SDKs).

      As a secondary safety net, getValue() returns null for this constant. Note that this alone does not cause field omission: if a non-null NONE reference reaches a ToolDefinition field, Jackson's @JsonInclude(NON_NULL) will still emit the field (as "defer": null) because the field reference itself is not null. The primary protection is mapping NONE to a null field reference before constructing the ToolDefinition.

    • AUTO

      public static final ToolDefer AUTO
      The tool can be deferred and surfaced through tool search.
    • NEVER

      public static final ToolDefer NEVER
      The tool is always pre-loaded.
  • Method Details

    • values

      public static ToolDefer[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static ToolDefer valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null
    • getValue

      public String getValue()
      Returns the JSON value for this deferral mode.

      Returns null for NONE to avoid emitting an empty string ("defer": "") if this sentinel accidentally reaches serialization. With null, the worst-case leak becomes "defer": null rather than an invalid empty string.

      Returns:
      the string value used in JSON serialization, or null for NONE
    • fromValue

      public static ToolDefer fromValue(String value)
      Deserializes a JSON string value into the corresponding ToolDefer enum constant.
      Parameters:
      value - the JSON string value
      Returns:
      the matching ToolDefer, or null if value is null
      Throws:
      IllegalArgumentException - if the value does not match any known deferral mode