fix: KeyError on first skills_tool:load call#1095
Open
QuantFoundry wants to merge 1 commit intoagent0ai:mainfrom
Open
fix: KeyError on first skills_tool:load call#1095QuantFoundry wants to merge 1 commit intoagent0ai:mainfrom
QuantFoundry wants to merge 1 commit intoagent0ai:mainfrom
Conversation
agent.data is a plain dict. On the first skills_tool:load call in any session, the 'loaded_skills' key has not been initialized yet, so direct dict access raises KeyError: 'loaded_skills'. The except block in execute() catches it and returns the error to the agent, silently breaking every skills_tool:load call until the key is set by some other path. Fix: use .get() instead of direct access so the check returns None (falsy) on first call, allowing the initialization on the next line to proceed normally.
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.
Problem
skills_tool._load()raisesKeyError: 'loaded_skills'on the first call in any session becauseagent.datais a plain dict and the key has not been initialized yet.The
exceptblock inexecute()catches the exception and returns it to the agent as:This silently breaks every
skills_tool:loadcall in a fresh session. The agent receives an error, cannot load the skill, and falls back to guessing or reading files manually.Fix
Use
.get()instead of direct dict access — returnsNone(falsy) when the key does not exist, allowing the initialization on the next line to proceed normally.Testing
Verified in a live Agent Zero session:
skills_tool:loadnow succeeds on the first call with no errors.