Skip to main content

Artifact

Struct Artifact 

#[non_exhaustive]
pub struct Artifact { pub id: Option<String>, pub name: String, pub mime_type: Option<String>, pub data: Value, pub file: Option<ArtifactFile>, }
Expand description

A named piece of output produced while a run works (a file, a report, a structured result). A2A maps these to task artifacts.

Two forms. A JSON artifact has data (a string becomes a text part, anything else a data part). A file artifact (Artifact::file) has file, and its media type is mime_type; its data is null. The A2A server serves a file as a raw part with the media type and the filename, which any A2A client reads as a file. Artifacts journaled before the file form existed have no file and read as they did.

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§id: Option<String>

The artifact’s identity within the run, when it has one: a later artifact of the run with the same id replaces it, whichever tool made it, in place (it keeps its position) instead of being added after it, so a thing that changes while a run works (a plan, a surface) is one artifact, not one per change. None (artifacts journaled before ids existed, and every artifact that is only ever made once) is not replaced by anything. Files have no id: a file artifact is content-addressed (ADR 0012), so with_id leaves a file without one, and the run never replaces a file nor replaces anything with a file (an id on a file is dropped, both are kept).

§name: String

Artifact name.

§mime_type: Option<String>

Media type of data (or of the file), if known.

§data: Value

The content of a JSON artifact; null for a file.

§file: Option<ArtifactFile>

The file, for a file artifact.

Implementations§

§

impl Artifact

pub fn new( name: impl Into<String>, mime_type: Option<String>, data: Value, ) -> Artifact

A JSON artifact: data with its media type, if it has one.

pub fn with_id(self, id: impl Into<String>) -> Artifact

Keep this artifact under id: see id. A file artifact stays without one.

pub fn file( name: impl Into<String>, media_type: impl Into<String>, filename: impl Into<String>, bytes: Vec<u8>, ) -> Result<Artifact, ArtifactFileError>

A file artifact: bytes, saved as filename, of media_type.

§Errors

[ArtifactFileError]: the file is over [MAX_ARTIFACT_FILE_BYTES], the filename is not a name, or the media type is not type/subtype.

pub fn upload_ref( name: impl Into<String>, media_type: impl Into<String>, filename: impl Into<String>, upload_id: impl Into<String>, ) -> Result<Artifact, ArtifactFileError>

A file that was sent by reference (uploads/v1): the bytes went straight to the bucket, and the artifact names the upload_id the orchestrator issued for them. It holds no bytes, here or in the journal, and is a JSON artifact whose media type is [UPLOAD_REF_MEDIA_TYPE] and whose data is {filename, mediaType, uploadId}: the A2A server serves it as the contract’s data part (see [upload_ref_of]).

§Errors

[ArtifactFileError]: the filename is not a name, the media type is not type/subtype, or the id is empty or over [MAX_UPLOAD_ID_BYTES].

pub fn file_len(&self) -> usize

The bytes of the file, 0 for a JSON artifact.

pub fn file_sha256(&self) -> Option<String>

The SHA-256 of the file’s bytes, as 64 lower-case hexadecimal digits: the name the person’s screen keeps the file under, and what a form’s picture of it (ask_user’s image.sha256) refers to. None for a JSON artifact.

§

impl Artifact

pub fn shared_line(&self) -> String

What a tool tells the model it shared, in place of the bytes: Shared report.pdf (84.0 KiB, application/pdf). for a file artifact; for an image, also how to use it, by the file’s name inline in the answer (what the person’s screen resolves an image’s source against, never a path) and by its SHA-256 as the picture of an ask_user option and in a show Image block:

Shared chart.png (1.5 KiB, image/png). To show it in your answer, write
![description](chart.png). To use it as the picture of an `ask_user` option, pass image
{sha256: "<64 hex digits>", alt}. In a `show` block, an `Image` names it:
{component: "Image", artifact: "<64 hex digits>", alt}.

Every source of a shared file says it the same way: the coder’s share_file, a server of an mcp.json with files: true and a remote subagent with files: true. A JSON artifact is Shared <name>.

Trait Implementations§

§

impl Clone for Artifact

§

fn clone(&self) -> Artifact

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
§

impl Debug for Artifact

§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
§

impl<'de> Deserialize<'de> for Artifact

§

fn deserialize<__D>( __deserializer: __D, ) -> Result<Artifact, <__D as Deserializer<'de>>::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
§

impl PartialEq for Artifact

§

fn eq(&self, other: &Artifact) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
§

impl Serialize for Artifact

§

fn serialize<__S>( &self, __serializer: __S, ) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
§

impl StructuralPartialEq for Artifact

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> FromRef<T> for T
where T: Clone,

§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T> IntoRequest<T> for T

§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
§

impl<L> LayerExt<L> for L

§

fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>
where L: Layer<S>,

Applies the layer to a service and wraps it in [Layered].
§

impl<T> PolicyExt for T
where T: ?Sized,

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
§

impl<T> ServiceExt for T

§

fn map_response_body<F>(self, f: F) -> MapResponseBody<Self, F>
where Self: Sized,

Apply a transformation to the response body. Read more
§

fn trace_for_http(self) -> Trace<Self, SharedClassifier<ServerErrorsAsFailures>>
where Self: Sized,

High level tracing that classifies responses using HTTP status codes. Read more
§

fn trace_for_grpc(self) -> Trace<Self, SharedClassifier<GrpcErrorsAsFailures>>
where Self: Sized,

High level tracing that classifies responses using gRPC headers. Read more
§

fn follow_redirects(self) -> FollowRedirect<Self>
where Self: Sized,

Follow redirect resposes using the Standard policy. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more