Repository navigation
Clear /llm schema cache on completion refresh - #2498
Merged
rolandwalker merged 2 commits intoDec 5, 2026
Merged
Conversation
rolandwalker
requested changes
Dec 5, 2026
rolandwalker
approved these changes
Dec 5, 2026
Contributor
|
@leninworld you are great, and your PRs are great! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR fixes issue #2497.
Description
/llmcaches the schema and sample rows it puts in its prompt (SCHEMA_DATA_CACHE,SAMPLE_DATA_CACHE), keyed by database name, and nothing cleared them. After the first/llmquestion, a table created, altered or dropped later in the session never reached the prompt, andrehash(\#) could not pick up schema changes made from another session.This change adds
clear_llm_cache()tospecial_commands/llm.py(with a no-op stand-in whenMYCLI_LLM_OFFis set) and calls it at the start ofrefresh_completions(). That method already runs after DDL,use,connect/\randrehash(\#), so the next/llmquestion reads the schema and sample rows again. Within an unchanged session the cache still saves the schema queries.Tests:
test_special_llm.py::test_clear_llm_cache_refreshes_schema_and_sample_data: a table added after the first call stays missing untilclear_llm_cache(), then both the schema and the sample data include it and the queries run again.test_client_query.py::test_refresh_completions_clears_llm_cache:refresh_completions()empties both caches.test_special_commands_init.py: the export and theMYCLI_LLM_OFFstand-in.The two new tests fail on main and pass with the change. Locally (Python 3.11,
[all,dev]extras):pytest mycli_test/pytests3893 passed, 88 skipped, 8 xfailed;ruff check,ruff formatandmypy --install-types .clean. The behave tests need a MySQL server and were not run.Not covered, since they follow when mycli refreshes completions: data changes (
INSERT/DELETE) keep the cached sample rows, and DDL run throughsource file.sql, or in a multi-statement input that fails after the DDL, doesn't trigger a refresh.Fixes #2497
Checklist
changelog.mdfile.mycli/AUTHORS.txtfile (or it's already there).