Skip to content

Commit 19d820f

Browse files
committed
fix: add SKILL_SPACE_NAME env in execute_skills tool
1 parent 28735b7 commit 19d820f

2 files changed

Lines changed: 13 additions & 8 deletions

File tree

veadk/tools/builtin_tools/execute_skills.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,19 +71,18 @@ def execute_skills(
7171
workflow_prompt: str,
7272
skills: Optional[List[str]] = None,
7373
tool_context: ToolContext = None,
74-
timeout: int = 900,
7574
) -> str:
7675
"""execute skills in a code sandbox and return the output.
7776
For C++ code, don't execute it directly, compile and execute via Python; write sources and object files to /tmp.
7877
7978
Args:
8079
workflow_prompt (str): instruction of workflow
8180
skills (Optional[List[str]]): The skills will be invoked
82-
timeout (int, optional): The timeout in seconds for the code execution, less than or equal to 900. Defaults to 900.
8381
8482
Returns:
8583
str: The output of the code execution.
8684
"""
85+
timeout = 900 # The timeout in seconds for the code execution, less than or equal to 900. Defaults to 900. Hard-coded to prevent the Agent from adjusting this parameter.
8786

8887
tool_id = getenv("AGENTKIT_TOOL_ID")
8988

@@ -131,7 +130,10 @@ def execute_skills(
131130
if skills:
132131
cmd.extend(["--skills"] + skills)
133132

134-
env_vars = {"TOOL_USER_SESSION_ID": tool_user_session_id}
133+
env_vars = {
134+
"SKILL_SPACE_NAME": os.getenv("SKILL_SPACE_NAME", ""),
135+
"TOOL_USER_SESSION_ID": tool_user_session_id,
136+
}
135137

136138
code = f"""
137139
import subprocess

veadk/tools/skills_tools/skills_tool.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,9 @@ class SkillsTool(BaseTool):
3838
def __init__(self, skills_directory: str | Path, skills_space_name: Optional[str]):
3939
self.skills_directory = Path(skills_directory).resolve()
4040
if not self.skills_directory.exists():
41-
raise ValueError(
42-
f"Skills directory does not exist: {self.skills_directory}"
41+
self.skills_directory.mkdir(parents=True, exist_ok=True)
42+
logger.info(
43+
f"Skills directory does not exist: {self.skills_directory}, automatically created"
4344
)
4445

4546
self.skills_space_name = skills_space_name
@@ -171,6 +172,7 @@ def _discover_skills(self) -> str:
171172
logger.error(f"Failed to discover skill from skill space: {e}")
172173

173174
if not skills_entries:
175+
logger.warning("No skills found in local and skill space.")
174176
return "<available_skills>\n<!-- No skills found in skills directory and skill space -->\n</available_skills>\n"
175177

176178
return (
@@ -210,6 +212,7 @@ def _invoke_skill(self, skill_name: str) -> str:
210212
"""Load and return the full content of a skill."""
211213
# Check cache first
212214
if skill_name in self._skill_cache:
215+
logger.info(f"Invoke skill '{skill_name}' from cache successfully.")
213216
return self._skill_cache[skill_name]
214217

215218
# Find skill directory
@@ -325,12 +328,12 @@ def _invoke_skill(self, skill_name: str) -> str:
325328
# Cache the formatted content
326329
self._skill_cache[skill_name] = formatted_content
327330

328-
logger.info(f"Loaded skill '{skill_name}' successfully.")
331+
logger.info(f"Invoke skill '{skill_name}' successfully.")
329332
return formatted_content
330333

331334
except Exception as e:
332-
logger.error(f"Failed to load skill {skill_name}: {e}")
333-
return f"Error loading skill '{skill_name}': {e}"
335+
logger.error(f"Failed to invoke skill {skill_name}: {e}")
336+
return f"Error invoking skill '{skill_name}': {e}"
334337

335338
def _parse_skill_metadata(self, skill_file: Path) -> Dict[str, str] | None:
336339
"""Parse YAML frontmatter from a SKILL.md file."""

0 commit comments

Comments
 (0)