Artifact and Serialization API Reference
ArtifactIdentity
async_batch_llm.ArtifactIdentity
dataclass
ArtifactIdentity(provider: str | None = None, model: str | None = None, prompt_version: str | None = None, parser_version: str | None = None, application_version: str | None = None, extra: Mapping[str, JSONValue] = dict())
Caller-supplied provenance used to decide whether replay is compatible.
ResumePolicy
async_batch_llm.ResumePolicy
Bases: str, Enum
Which compatible terminal artifact records may bypass provider work.
ArtifactStore
async_batch_llm.ArtifactStore
Bases: Protocol
Provider-neutral asynchronous checkpoint/replay store.
append
async
append(work_item: LLMWorkItem[Any, Any, Any], prepared_item: Any, result: WorkItemResult[Any, Any]) -> None
Durably append one newly executed terminal result.
close
async
iter_results
lookup
async
lookup(work_item: LLMWorkItem[Any, Any, Any], prepared_item: Any, policy: ResumePolicy) -> WorkItemResult[Any, Any] | None
Return the newest compatible reusable result, if any.
prepare_item
async
JsonlArtifactStore
async_batch_llm.JsonlArtifactStore
JsonlArtifactStore(path: str | Path, *, identity: ArtifactIdentity | None = None, user_metadata: Mapping[str, JSONValue] | None = None, include_output: bool = True, include_metadata: bool = True, include_prompt: bool = False, include_context: bool = False, context_in_identity: bool = True, encoder: ValueEncoder | None = None, output_decoder: ValueDecoder | None = None, context_decoder: ValueDecoder | None = None, context_fingerprinter: ContextFingerprinter | None = None, cost_calculator: CostCalculator | None = None, fsync: bool = False)
Append-only version-1 JSONL artifact store.
Prompt and context text are excluded by default; their SHA-256 hashes are
always recorded for compatibility. Output and metadata are included by
default because successful replay requires output. Set include_output
false for audit-only artifacts; those successful records are not replayable.
Source code in src/async_batch_llm/artifacts.py
prepare_item
async
Create/validate the artifact and fingerprint input before provider work.
Source code in src/async_batch_llm/artifacts.py
read_results
classmethod
read_results(path: str | Path, *, successes_only: bool = False, output_decoder: ValueDecoder | None = None, context_decoder: ValueDecoder | None = None) -> BatchResult[Any, Any]
Read stored results without opening a writer or calling a provider.
Source code in src/async_batch_llm/artifacts.py
ResultSerializationError
async_batch_llm.ResultSerializationError
Bases: ValueError
A result value or serialized payload is not safely supported.
Artifact errors
async_batch_llm.ArtifactError
Bases: RuntimeError
Base class for artifact preparation, format, and persistence failures.
async_batch_llm.ArtifactSerializationError
Bases: ArtifactError
An artifact identity/input/result could not be canonically serialized.
async_batch_llm.ArtifactIOError
Bases: ArtifactError
An artifact could not be read, written, flushed, or closed.
async_batch_llm.ArtifactFormatError
Bases: ArtifactError
An artifact is malformed or uses an unsupported schema version.