Record Class Artifact

java.lang.Object
java.lang.Record
org.a2aproject.sdk.spec.Artifact
Record Components:
artifactId - the unique identifier for this artifact (required)
name - the human-readable name of the artifact (optional)
description - a brief description of the artifact's purpose or content (optional)
parts - the content parts comprising the artifact (required, must not be empty)
metadata - additional key-value metadata for the artifact (optional)
extensions - protocol extensions used in this artifact (optional)

public record Artifact(String artifactId, @Nullable String name, @Nullable String description, List<Part<?>> parts, @Nullable Map<String,Object> metadata, @Nullable List<String> extensions) extends Record
Represents a file, data structure, or other resource generated by an agent during task execution.

Artifacts are outputs created by agents in response to user requests. They can represent various types of content including documents, data structures, analysis results, generated files, or any other structured output from agent operations.

Each artifact has a unique identifier and contains content through Parts, which allow for multi-modal output (text, files, structured data). Artifacts can include metadata for additional context and support protocol extensions.

Artifacts are typically delivered to clients through Task responses or TaskArtifactUpdateEvent events in streaming scenarios.

This class is immutable. Use the Artifact.Builder for construction.

See Also:
  • Constructor Details

    • Artifact

      public Artifact(String artifactId, @Nullable String name, @Nullable String description, List<Part<?>> parts, @Nullable Map<String,Object> metadata, @Nullable List<String> extensions)
      Compact constructor that validates required fields.
      Parameters:
      artifactId - the artifactId parameter (see class-level JavaDoc)
      name - the name parameter (see class-level JavaDoc)
      description - the description parameter (see class-level JavaDoc)
      parts - the parts parameter (see class-level JavaDoc)
      metadata - the metadata parameter (see class-level JavaDoc)
      extensions - the extensions parameter (see class-level JavaDoc)
      Throws:
      IllegalArgumentException - if artifactId or parts is null, or if parts is empty
  • Method Details

    • builder

      public static Artifact.Builder builder()
      Create a new Builder
      Returns:
      the builder
    • builder

      public static Artifact.Builder builder(Artifact artifact)
      Create a new Builder initialized with values from an existing Artifact.

      This builder creates defensive copies of mutable collections to ensure that modifications to the builder do not affect the original Artifact.

      Parameters:
      artifact - the Artifact to copy values from
      Returns:
      the builder
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • artifactId

      public String artifactId()
      Returns the value of the artifactId record component.
      Returns:
      the value of the artifactId record component
    • name

      public @Nullable String name()
      Returns the value of the name record component.
      Returns:
      the value of the name record component
    • description

      public @Nullable String description()
      Returns the value of the description record component.
      Returns:
      the value of the description record component
    • parts

      public List<Part<?>> parts()
      Returns the value of the parts record component.
      Returns:
      the value of the parts record component
    • metadata

      public @Nullable Map<String,Object> metadata()
      Returns the value of the metadata record component.
      Returns:
      the value of the metadata record component
    • extensions

      public @Nullable List<String> extensions()
      Returns the value of the extensions record component.
      Returns:
      the value of the extensions record component