fix(db): persist tools by class key, not localized display name - #123
Open
naw103 wants to merge 1 commit into
Open
fix(db): persist tools by class key, not localized display name#123naw103 wants to merge 1 commit into
naw103 wants to merge 1 commit into
Conversation
The recent i18n changes made MyTool.name a translated display string (e.g. "Write File" for CustomFileWriteTool under en.json). save_tool stored that value, but load_tools looks it up in TOOL_CLASSES, whose keys are class identifiers. The mismatch raises KeyError: 'Write File' on the next app start for any locale where the display name differs from the class key, which is every locale. This change: - Persists the stable TOOL_CLASSES key in save_tool. - Makes load_tools accept either format so existing databases keep working, and transparently rewrites legacy rows on load. - Skips unknown tool entries with a warning instead of crashing the whole load_data pass.
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.
Summary
After the recent i18n changes (commits c1dbabd / 14eca77 / c1b6460),
MyTool.namebecame a locale-dependent display string.db_utils.save_toolstill stores that value, anddb_utils.load_toolsuses it as a key intoTOOL_CLASSES— whose keys are class identifiers likeCustomFileWriteTool. Because e.g.t('tool.custom_file_write')resolves to"Write File"underen.json, every subsequent app start raises:…in
load_tools->load_agents->load_data. This reproduces for anyone on any locale as soon as a tool row exists in the DB.What this PR does
save_toolnow stores the stableTOOL_CLASSESkey (CustomFileWriteTool) instead of the translatedtool.name("Write File").load_toolsaccepts either format:.nameto map the stored display string back to a class.load_datapass.Repro (before this PR)
main, run the app.load_agents->load_toolsraisesKeyError: 'Write File'.Test plan
CustomFileWriteTool, restart -> tool loads.name='Write File'-> row loads and is rewritten toCustomFileWriteToolon first read.zhand restart -> tools still load (persisted key is locale-independent).TOOL_CLASSESentry removed -> that row is skipped with a warning; other tools still load.Notes
load_toolscall.app/db_utils.pyis touched.