Skip to content

MAINT: Store a template hash in PromptTemplateConverter identifiers #3339

Closed

Description

@romanlutz

Is your feature request related to a problem? Please describe.

PromptTemplateConverter._build_identifier() currently stores the complete template string in params["template"]. Long templates therefore make the identifier metadata larger wherever it is serialized or persisted.

The template already contributes to the overall identifier hash, so this is not a missing-identity or hash-collision bug. The goal is smaller identifier metadata and consistency with converters that identify templates by a content hash.

Describe the solution you'd like

Replace the full template in PromptTemplateConverter identifier params with a deterministic template_hash, following the existing convention in LLMGenericTextConverter and TemplateSegmentConverter: SHA-256 of the template's UTF-8 bytes, truncated to 16 hexadecimal characters.

Keep strip_characters in the identifier and leave conversion output unchanged. Hash the configured template, not the rendered prompt or input text.

Add regression tests covering equivalent independently constructed templates, different templates, changes to strip_characters, and a long template whose identifier contains only the fixed-size template hash rather than its full text. Document the resulting one-time change to identifier hashes and autogenerated registry names. Preserve the deprecated TaskFramingConverter identifier compatibility.

Describe alternatives you've considered, if relevant

Keep the full template in identifier params. This preserves existing hashes and makes the template directly inspectable, but retains potentially large metadata. Do not simply truncate the template text, since templates that differ after the cutoff must still have different identities.

Additional context

This issue is scoped to the representation of the template in PromptTemplateConverter identifiers, not a broader converter refactor.

Activity

  1. romanlutz commented on Oct 19, 2026

    @romanlutz
    ContributorAuthor

    this is assigned to Isaac Emmanuel (@1cbyc) (even though the GH UI doesn't let me assign without them having commented here). Please don't submit duplicate PRs!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions