Class AgentSkill.Builder

java.lang.Object
org.a2aproject.sdk.spec.AgentSkill.Builder
Enclosing class:
AgentSkill

public static class AgentSkill.Builder extends Object
Builder for constructing immutable AgentSkill instances.

The Builder pattern provides a fluent API for setting skill properties. This approach ensures that once an AgentSkill is created, its state cannot be modified, which is important for protocol correctness and thread-safety.

Example usage:


 AgentSkill skill = AgentSkill.builder()
     .id("weather_query")
     .name("Weather Queries")
     .description("Get current weather conditions for any location")
     .tags(List.of("weather", "information"))
     .examples(List.of(
         "What's the weather in Tokyo?",
         "Current temperature in London"
     ))
     .inputModes(List.of("text"))
     .outputModes(List.of("text"))
     .build();
 
  • Method Details

    • id

      public AgentSkill.Builder id(String id)
      Sets the unique identifier for the skill.

      The ID should be a stable identifier that doesn't change across versions, typically in snake_case format (e.g., "weather_query", "translate_text").

      Parameters:
      id - the skill ID (required)
      Returns:
      this builder for method chaining
    • name

      public AgentSkill.Builder name(String name)
      Sets the human-readable name of the skill.

      The name is displayed to users and should clearly describe the skill's purpose.

      Parameters:
      name - the skill name (required)
      Returns:
      this builder for method chaining
    • description

      public AgentSkill.Builder description(String description)
      Sets a detailed description of what the skill does and how to use it.

      The description should provide sufficient information for users to understand when and how to invoke the skill.

      Parameters:
      description - the skill description (required)
      Returns:
      this builder for method chaining
    • tags

      public AgentSkill.Builder tags(List<String> tags)
      Sets categorization tags for discovery and filtering.

      Tags help organize skills and enable clients to filter or search for specific categories of functionality.

      Parameters:
      tags - list of tags (required, may be empty)
      Returns:
      this builder for method chaining
    • examples

      public AgentSkill.Builder examples(List<String> examples)
      Sets example queries or use cases demonstrating the skill.

      Examples help users understand how to phrase requests to effectively invoke the skill.

      Parameters:
      examples - list of example queries (optional)
      Returns:
      this builder for method chaining
    • inputModes

      public AgentSkill.Builder inputModes(List<String> inputModes)
      Sets the supported input formats for this skill.

      If not specified, the skill inherits the default input modes from the AgentCard. Common values include "text", "audio", "image", "video".

      Parameters:
      inputModes - list of supported input formats (optional)
      Returns:
      this builder for method chaining
    • outputModes

      public AgentSkill.Builder outputModes(List<String> outputModes)
      Sets the supported output formats for this skill.

      If not specified, the skill inherits the default output modes from the AgentCard. Common values include "text", "audio", "image", "video".

      Parameters:
      outputModes - list of supported output formats (optional)
      Returns:
      this builder for method chaining
    • securityRequirements

      public AgentSkill.Builder securityRequirements(List<SecurityRequirement> securityRequirements)
      Sets security requirements specific to this skill.

      Security requirements override or supplement the agent-level security defined in the AgentCard. Each entry represents an alternative security requirement (OR relationship). Schemes within a single SecurityRequirement must all be satisfied (AND relationship).

      Parameters:
      securityRequirements - list of security requirements (optional)
      Returns:
      this builder for method chaining
      See Also:
    • build

      public AgentSkill build()
      Builds an immutable AgentSkill from the current builder state.
      Returns:
      a new AgentSkill instance
      Throws:
      IllegalArgumentException - if any required field (id, name, description, tags) is null