adk-artifact 0.2.1

Binary artifact storage for Rust Agent Development Kit (ADK-Rust) agents
Documentation

adk-artifact

Binary artifact storage for Rust Agent Development Kit (ADK-Rust) agents.

Crates.io Documentation License

Overview

adk-artifact provides binary data storage for the Rust Agent Development Kit (ADK-Rust):

  • InMemoryArtifactService - Simple in-memory artifact storage
  • ArtifactService - Trait for custom storage backends
  • ScopedArtifacts - Session-scoped artifact access
  • Versioning - Multiple versions per artifact

Artifacts are useful for storing images, documents, audio, and other binary data that agents produce or consume.

Installation

[dependencies]
adk-artifact = "0.2.0"

Or use the meta-crate:

[dependencies]
adk-rust = { version = "0.2.1", features = ["artifacts"] }

Quick Start

use adk_artifact::{InMemoryArtifactService, ArtifactService, SaveRequest, LoadRequest};
use adk_core::Part;

// Create artifact service
let service = InMemoryArtifactService::new();

// Store an artifact
let response = service.save(SaveRequest {
    app_name: "my_app".to_string(),
    user_id: "user_123".to_string(),
    session_id: "session_456".to_string(),
    file_name: "report.pdf".to_string(),
    part: Part::InlineData {
        mime_type: "application/pdf".to_string(),
        data: pdf_bytes,
    },
    version: None, // Auto-increment
}).await?;

println!("Saved as version: {}", response.version);

// Retrieve artifact
let response = service.load(LoadRequest {
    app_name: "my_app".to_string(),
    user_id: "user_123".to_string(),
    session_id: "session_456".to_string(),
    file_name: "report.pdf".to_string(),
    version: None, // Latest version
}).await?;

Use with LoadArtifactsTool

Artifacts integrate with agents via LoadArtifactsTool:

use adk_tool::LoadArtifactsTool;

let tool = LoadArtifactsTool::new();

let agent = LlmAgentBuilder::new("assistant")
    .tool(Arc::new(tool))
    .build()?;

The LLM can then call this tool to load artifacts by name into the conversation.

Features

  • Async storage and retrieval
  • Automatic MIME type detection
  • Version history support
  • Thread-safe concurrent access
  • User-scoped artifacts (use user: prefix for cross-session access)

Related Crates

License

Apache-2.0

Part of ADK-Rust

This crate is part of the ADK-Rust framework for building AI agents in Rust.