Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions veadk/tools/builtin_tools/execute_skills.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ def execute_skills(
if time.time() - start_time > timeout:
process.kill()
log_file.write('log_type=stderr request_id=x function_id=y revision_number=1 Process timeout\\n')
print("Process timeout", end='', file=sys.stderr)
break

reads = [process.stdout.fileno(), process.stderr.fileno()]
Expand All @@ -176,23 +177,23 @@ def execute_skills(
if line:
log_file.write(f'log_type=stdout request_id=x function_id=y revision_number=1 {{line}}')
log_file.flush()
print(line, end='')
if fd == process.stderr.fileno():
line = process.stderr.readline()
if line:
log_file.write(f'log_type=stderr request_id=x function_id=y revision_number=1 {{line}}')
log_file.flush()
print(line, end='', file=sys.stderr)

if process.poll() is not None:
break

for line in process.stdout:
log_file.write(f'log_type=stdout request_id=x function_id=y revision_number=1 {{line}}')
print(line, end='')
for line in process.stderr:
log_file.write(f'log_type=stderr request_id=x function_id=y revision_number=1 {{line}}')

with open('/tmp/agent.log', 'r') as log_file:
output = log_file.read()
print(output)
print(line, end='', file=sys.stderr)
"""

res = ve_request(
Expand Down
10 changes: 8 additions & 2 deletions veadk/tools/skills_tools/session_path.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import platform
import tempfile
from pathlib import Path
from veadk.utils.logger import get_logger
Expand Down Expand Up @@ -47,7 +48,11 @@ def initialize_session_path(session_id: str) -> Path:
return _session_path_cache[session_id]

# Initialize new session path
base_path = Path(tempfile.gettempdir()) / "veadk"
if platform.system() in ("Linux", "Darwin"): # Linux or macOS
base_path = Path("/tmp") / "veadk"
else: # Windows
base_path = Path(tempfile.gettempdir()) / "veadk"

session_path = base_path / session_id

# Create working directories
Expand All @@ -56,8 +61,9 @@ def initialize_session_path(session_id: str) -> Path:
(session_path / "outputs").mkdir(parents=True, exist_ok=True)

# Cache and return
resolved_path = session_path.resolve()
resolved_path = session_path
_session_path_cache[session_id] = resolved_path
logger.info(f"Initialized session path for {session_id}: {resolved_path}")
return resolved_path


Expand Down
7 changes: 3 additions & 4 deletions veadk/tools/skills_tools/skills_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@
from __future__ import annotations

import os
import tempfile
from pathlib import Path
from typing import Any, Dict

from google.adk.tools import BaseTool, ToolContext
from google.genai import types

from veadk.skills.skill import Skill
from veadk.tools.skills_tools.session_path import get_session_path
from veadk.utils.logger import get_logger

logger = get_logger(__name__)
Expand Down Expand Up @@ -102,9 +102,8 @@ def _invoke_skill(self, skill_name: str, tool_context: ToolContext) -> str:
return f"Error: Skill '{skill_name}' does not exist."

skill = self.skills[skill_name]
skill_dir = (
Path(tempfile.gettempdir()) / "veadk" / tool_context.session.id / "skills"
)
working_dir = get_session_path(session_id=tool_context.session.id)
skill_dir = working_dir / "skills"

if skill.skill_space_id:
logger.info(f"Attempting to download skill '{skill_name}' from skill space")
Expand Down