Skip to content

Avoid mutating LLM prompt dataframes#12440

Open
pragnyanramtha wants to merge 1 commit into
mindsdb:mainfrom
pragnyanramtha:codex/llm-prompt-template-no-mutation
Open

Avoid mutating LLM prompt dataframes#12440
pragnyanramtha wants to merge 1 commit into
mindsdb:mainfrom
pragnyanramtha:codex/llm-prompt-template-no-mutation

Conversation

@pragnyanramtha
Copy link
Copy Markdown

Summary

  • build LLM prompt template completions without writing an internal __mdb_prompt column into the caller DataFrame
  • return a typed empty integer array for no-placeholder non-strict prompt templates
  • add a regression test that preserves a user-provided __mdb_prompt column

Why

get_completed_prompts is used by LLM/model handlers to render prompt templates. The helper previously mutated its input DataFrame by adding __mdb_prompt, which could leak internal state into downstream code or overwrite a real user column with the same name.

Validation

  • .test-venv/bin/python -m pytest tests/unit/various/test_llm_utils.py -q -> 2 passed in 13.09s
  • /tmp/mindsdb-ruff-venv/bin/ruff check mindsdb/integrations/libs/llm/utils.py tests/unit/various/test_llm_utils.py -> All checks passed!

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 17, 2026

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@pragnyanramtha pragnyanramtha marked this pull request as ready for review May 17, 2026 02:59
Copilot AI review requested due to automatic review settings May 17, 2026 02:59
@pragnyanramtha
Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

@pragnyanramtha
Copy link
Copy Markdown
Author

recheck

github-actions Bot added a commit that referenced this pull request May 17, 2026
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.

1 participant