Skip to content

Commit 57f4949

Browse files
committed
fix: change running code
1 parent e57a3b2 commit 57f4949

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

veadk/tools/builtin_tools/execute_skills.py

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def execute_skills(
3838
Args:
3939
workflow_prompt (str): instruction of workflow
4040
skills (Optional[List[str]]): The skills will be invoked
41-
timeout (int, optional): The timeout in seconds for the code execution. Defaults to 300.
41+
timeout (int, optional): The timeout in seconds for the code execution, less than or equal to 300. Defaults to 300.
4242
4343
Returns:
4444
str: The output of the code execution.
@@ -65,8 +65,8 @@ def execute_skills(
6565
f"Execute skills in session_id={session_id}, tool_id={tool_id}, host={host}, service={service}, region={region}, timeout={timeout}"
6666
)
6767

68-
ak = tool_context.state.get("VOLCENGINE_ACCESS_KEY")
69-
sk = tool_context.state.get("VOLCENGINE_SECRET_KEY")
68+
ak = getenv("VOLCENGINE_ACCESS_KEY")
69+
sk = getenv("VOLCENGINE_SECRET_KEY")
7070
header = {}
7171

7272
if not (ak and sk):
@@ -90,13 +90,26 @@ def execute_skills(
9090
if skills:
9191
cmd.extend(["--skills"] + skills)
9292

93+
# TODO: remove after agentkit supports custom environment variables setting
94+
env_vars = {
95+
"MODEL_AGENT_API_KEY": os.getenv("MODEL_AGENT_API_KEY"),
96+
"TOS_SKILLS_DIR": os.getenv("TOS_SKILLS_DIR"),
97+
}
98+
9399
code = f"""
94100
import subprocess
101+
import os
102+
103+
env = os.environ.copy()
104+
env.update({env_vars!r})
105+
95106
result = subprocess.run(
96107
{cmd!r},
97108
cwd='/home/gem/veadk_skills',
98109
capture_output=True,
99-
text=True
110+
text=True,
111+
env=env,
112+
timeout={timeout - 10},
100113
)
101114
print(result.stdout)
102115
if result.stderr:

0 commit comments

Comments
 (0)