Skip to content

API Reference parrot.storage.artifacts

github-actions[bot] edited this page Dec 2, 2026 · 4 revisions

parrot.storage.artifacts

View source

High-level artifact CRUD operations.

Composes ConversationBackend (artifacts table) and OverflowStore to provide a single interface for saving, loading, listing, updating, and deleting artifacts.

FEAT-116: Refactored to use ConversationBackend ABC and OverflowStore. Removed the leaky ConversationDynamoDB-specific abstraction (FEAT-116). See wiki/stores/storage-backends.md for backend configuration.

Alias Artifact

Re-exported from parrot.storage.models.Artifact.

Class ArtifactStore

Artifact CRUD operations against the configured storage backend.

Parameter Type Default Description
dynamodb ConversationBackend Initialised ConversationBackend instance (param name kept for backward compatibility with existing callers).
s3_overflow OverflowStore Initialised OverflowStore instance (param name kept for backward compatibility).

Attributes:

Attribute Type Description
file_manager The FileManagerInterface the store keeps files in (the overflow store's).

Method ArtifactStore.save_artifact

Persist an artifact, offloading to overflow store if necessary.

save_artifact(user_id: str, agent_id: str, session_id: str, artifact: Artifact) -> None

Parameter Type Default Description
user_id str
agent_id str
session_id str
artifact Artifact

Method ArtifactStore.get_artifact

Retrieve a single artifact with its full definition.

get_artifact(user_id: str, agent_id: str, session_id: str, artifact_id: str) -> Optional[Artifact]

Parameter Type Default Description
user_id str
agent_id str
session_id str
artifact_id str

Returns: Optional[Artifact]

Method ArtifactStore.list_artifacts

List all artifacts for a session as lightweight summaries.

list_artifacts(user_id: str, agent_id: str, session_id: str) -> List[ArtifactSummary]

Parameter Type Default Description
user_id str
agent_id str
session_id str

Returns: List[ArtifactSummary]

Method ArtifactStore.update_artifact

Replace the definition of an existing artifact.

update_artifact(user_id: str, agent_id: str, session_id: str, artifact_id: str, definition: Dict[str, Any]) -> None

Parameter Type Default Description
user_id str
agent_id str
session_id str
artifact_id str
definition Dict[str, Any]

Method ArtifactStore.delete_artifact

Delete an artifact from storage and clean up any overflow data.

delete_artifact(user_id: str, agent_id: str, session_id: str, artifact_id: str) -> bool

Parameter Type Default Description
user_id str
agent_id str
session_id str
artifact_id str

Returns: bool

Method ArtifactStore.get_public_url

Return a presigned URL for the artifact's overflow object.

Generates an S3 sigv4 presigned URL (max 7 days / 604 800 s) so that the artifact can be fetched by any caller with the URL — no session or auth required. The URL does NOT embed user_id; signature alone authorises access.

For the "html" format the URL points to the same overflow JSON object that save_artifact uploaded (which contains the full definition including the html field). TASK-1322's public route provides the HTML-specific serving endpoint on top of this.

get_public_url(user_id: Union[str, int], agent_id: str, session_id: str, artifact_id: str, *, format: Literal['html', 'json'] = 'html') -> str

Parameter Type Default Description
user_id Union[str, int] Owning user identifier (used to locate the artifact).
agent_id str Agent that produced the artifact.
session_id str Session that owns the artifact.
artifact_id str Unique artifact identifier.
format Literal['html', 'json'] 'html' "html" (default) or "json". v1 treats both identically; both return a presigned URL to the overflow JSON. "json" is kept for future use; raises NotImplementedError if distinct JSON-only storage is requested.

Returns: str — A presigned URL string starting with https://.

Raises:

  • KeyError — When the artifact does not exist.
  • ValueError — When the artifact has no overflow reference (stored inline, i.e. small enough to skip S3).

Method ArtifactStore.save_export

Store data under {tenant}/{agent}/{uuid}/{filename} (server-chosen parts only).

save_export(tenant: Optional[str], agent: Optional[str], filename: str, data: bytes, *, content_type: Optional[str] = None, url_base: Optional[str] = None, ttl: Optional[int] = None, limit: Optional[int] = None) -> ExportRef

Parameter Type Default Description
tenant Optional[str]
agent Optional[str]
filename str
data bytes
content_type Optional[str] None
url_base Optional[str] None
ttl Optional[int] None
limit Optional[int] None

Returns: ExportRef

Raises:

  • InvalidExportKey — a tenant/agent segment that cannot be a partition name.
  • ExportTooLarge — data is above the per-file cap (STUDIO_ARTIFACT_MAX_BYTES).

Method ArtifactStore.get_export

The export key for a caller of tenant; None when it is unknown, expired, crafted or another tenant's (a caller cannot tell those apart: the route answers 404 for all of them).

get_export(key: str, *, tenant: Optional[str]) -> Optional[ExportFile]

Parameter Type Default Description
key str
tenant Optional[str]

Returns: Optional[ExportFile]

Method ArtifactStore.delete_export

Remove an export and its metadata (best effort); True when the file existed.

delete_export(key: str) -> bool

Parameter Type Default Description
key str

Returns: bool

Alias ArtifactSummary

Re-exported from parrot.storage.models.ArtifactSummary.

Alias ArtifactType

Re-exported from parrot.storage.models.ArtifactType.

Alias ConversationBackend

Re-exported from parrot.storage.backends.base.ConversationBackend.

Alias DEFAULT_URL_BASE

Re-exported from parrot.storage.exports.DEFAULT_URL_BASE.

Alias EXPORT_PREFIX

Re-exported from parrot.storage.exports.EXPORT_PREFIX.

Class ExportFile

A stored export: its bytes and metadata (:meth:ArtifactStore.get_export).

Parameter Type Default Description
data bytes
filename str
content_type str

Fields:

Field Type Default Description
data bytes
filename str
content_type str

Alias ExportRef

Re-exported from parrot.storage.exports.ExportRef.

Alias ExportTooLarge

Re-exported from parrot.storage.exports.ExportTooLarge.

Alias InvalidExportKey

Re-exported from parrot.storage.exports.InvalidExportKey.

Alias OverflowStore

Re-exported from parrot.storage.overflow.OverflowStore.

Alias build_export_key

Re-exported from parrot.storage.exports.build_export_key.

Alias guess_content_type

Re-exported from parrot.storage.exports.guess_content_type.

Alias max_bytes

Re-exported from parrot.storage.exports.max_bytes.

Alias parse_export_key

Re-exported from parrot.storage.exports.parse_export_key.

Alias partition_segment

Re-exported from parrot.storage.exports.partition_segment.

Alias ttl_seconds

Re-exported from parrot.storage.exports.ttl_seconds.

Architecture

Clients

Bots & Agents

Memory

Knowledge

Tools & Toolkits

Flows

Experts

Skills

Stores & Loaders

MCP & A2A

Server & APIs

Integrations

Outputs & A2UI

Prompts

Security

Operations

Migration

SDD Tooling

LLM Wiki

Deployment

Decisions

API Reference

Clone this wiki locally