fix: use .get() to avoid KeyError in skills_tool _load()
When skills_tool:load is called for the first time in a fresh agent session, the "loaded_skills" key does not yet exist in agent.data. Direct dict access (agent.data[key]) raises KeyError which is caught and returned as "Error in skills_tool: loaded_skills". Fix: replace with agent.data.get(key) which safely returns None, matching the pattern already used correctly in the companion extension _65_include_loaded_skills.py.
Vanja Emichi committed
Mar 4, 2026 at 22:46 UTC
e8abe7101fb9e9fd15a6e28ebd38ebb150b419a2
1 file changed
+1
-1
python/tools/skills_tool.py
+1
-1
@@ -123,7 +123,7 @@ class SkillsTool(Tool):
123
return f"Error: skill not found: {skill_name!r}. Try skills_tool method=list or method=search."
124
125
# Store skill name for fresh loading each turn
126
- if not self.agent.data[DATA_NAME_LOADED_SKILLS]:
126
+ if not self.agent.data.get(DATA_NAME_LOADED_SKILLS):
127
self.agent.data[DATA_NAME_LOADED_SKILLS] = []
128
loaded = self.agent.data[DATA_NAME_LOADED_SKILLS]
129
if skill.name in loaded: