Skip to content

Comments

fix: KeyError on first skills_tool:load call#1095

Open
QuantFoundry wants to merge 1 commit intoagent0ai:mainfrom
QuantFoundry:fix/skills-tool-keyerror
Open

fix: KeyError on first skills_tool:load call#1095
QuantFoundry wants to merge 1 commit intoagent0ai:mainfrom
QuantFoundry:fix/skills-tool-keyerror

Conversation

@QuantFoundry
Copy link

Problem

skills_tool._load() raises KeyError: 'loaded_skills' on the first call in any session because agent.data is a plain dict and the key has not been initialized yet.

# This line throws KeyError on first call:
if not self.agent.data[DATA_NAME_LOADED_SKILLS]:

The except block in execute() catches the exception and returns it to the agent as:

Error in skills_tool: 'loaded_skills'

This silently breaks every skills_tool:load call 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 — returns None (falsy) when the key does not exist, allowing the initialization on the next line to proceed normally.

- if not self.agent.data[DATA_NAME_LOADED_SKILLS]:
+ if not self.agent.data.get(DATA_NAME_LOADED_SKILLS):

Testing

Verified in a live Agent Zero session: skills_tool:load now succeeds on the first call with no errors.

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.
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