Skip to content

FIX: include template kwargs in LLMGenericTextConverter identifier - #3397

Open
Pushpak Siva Sai (Pushpak731) wants to merge 1 commit into
microsoft:mainfrom
Pushpak731:fix/llm-generic-text-converter-identifier
Open

Pushpak Siva Sai (Pushpak731) wants to merge 1 commit into
microsoft:mainfrom
Pushpak731:fix/llm-generic-text-converter-identifier

Conversation

@Pushpak731

Copy link
Copy Markdown
Contributor

Closes #3385

Problem

LLMGenericTextConverter forwards **kwargs (_prompt_kwargs) to both templates when rendering, but _build_identifier() hashed only the unrendered templates. Two converters built from the same template with different parameters — the docstring's own language=... example — shared one identifier: the second ConverterRegistry registration raised ValueError: Instance 'LLMGenericTextConverter::<hash>' already exists, and memory/analytics could not tell the configurations apart. Subclasses (ToneConverter, TranslationConverter, …) already promote their own parameter, so this hit the documented direct-use path.

Fix

The resolved template parameters are included in the identifier under a nested prompt_template_kwargs key:

Tests (8 new)

  • different kwargs → different unique_name and hash (the issue's scenario)
  • identical kwargs → stable hash
  • params expose prompt_template_kwargs == {"language": "French"}
  • no kwargs → params.get("prompt_template_kwargs") is None
  • user-prompt-template converters distinguished by kwargs too
  • structured kwargs (lists) distinguish and stay JSON-serializable
  • the issue's registry failure mode: two registrations succeed
  • subclass non-regression: ToneConverter keeps its promoted tone param and distinct hashes

Verification

  • tests/unit/converter/ — 2776 passed, 74 skipped
  • tests/unit/registry/ + tests/unit/models/identifiers/ + identifier filters — 1114 passed
  • ruff check + format clean

I used AI to assist me with this change.

The converter forwards its extra keyword arguments to both templates when
rendering, but the identifier recorded only the unrendered template
hashes, so converters sharing templates with different parameters (the
documented language=... pattern) shared one identifier: the second
registry registration raised a duplicate-name error and analytics could
not tell the configurations apart (microsoft#3385).

The resolved parameters now ride the identifier under a nested
prompt_template_kwargs key (empty collapsed to None, mirroring the
AzureMLChatTarget extra_parameters fix in microsoft#3332), nested so a template
parameter can never collide with the hash params. Subclasses keep their
own promoted parameter next to it.

Closes microsoft#3385
Copilot AI balanced review requested due to automatic review settings October 20, 2026 13:03

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BUG: LLMGenericTextConverter identifier ignores the template parameters it renders

2 participants