Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Principle:869413421 Ai moive studio Generation History

From Leeroopedia
Knowledge Sources
Domains Architecture, Observability
Last Updated 2026-10-23 12:00 GMT

Overview

Technique for recording generation provenance metadata (prompt, model, result URL, resource type) for audit, reproducibility, and reference management in AI content generation pipelines.

Description

Generation History tracks the provenance of every AI-generated asset in the system. Each generation record captures: the resource type (character avatar, scene image, keyframe, canvas generation), the resource ID, the result URL (object key in storage), the prompt used, the media type (image/video), the model, and the API key used.

This metadata enables:

  • Reproducibility: Re-generate an asset with the same prompt and model
  • Reference management: Use prior generations as reference images for new generations
  • Token sanitization: @-mention tokens in canvas prompts are sanitized (URLs → object keys) before storage to avoid storing presigned URLs

The sanitize_prompt_tokens_for_storage function normalizes prompt token data, replacing presigned media URLs with stable object keys. This ensures that stored generation history references remain valid even after presigned URLs expire.

Usage

Use this principle when building systems that need to track AI generation provenance. Apply when generated assets need reproducibility metadata or when prior generations should be reusable as references. Use when stored prompt data may contain expiring URLs that need normalization.

Theoretical Basis

# Abstract generation history record
record = GenerationHistory(
    resource_type="character_avatar",
    resource_id=character.id,
    result_url=object_key,  # MinIO object key, not presigned URL
    prompt=enhanced_prompt,
    media_type="image",
    model=model,
    api_key_id=api_key.id,
)
await history_service.create_history(record)

# Token sanitization for storage
def sanitize_prompt_tokens(tokens):
    for token in tokens:
        if token["type"] == "mention":
            object_key = extract_object_key(token["nodePreviewUrlSnapshot"])
            token["nodePreviewObjectKeySnapshot"] = object_key
            token.pop("nodePreviewUrlSnapshot", None)  # remove expiring URL
    return tokens

Practical Guide

  • Store object keys, not presigned URLs, in generation history
  • Sanitize @-mention tokens before storage (replace URLs with object keys)
  • Record the model, API key, prompt, and result for every generation
  • Support querying history by resource type and resource ID
  • Use history records as reference sources for new generations

Related Pages

Implemented By

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment