Skip to content

Commit 3fa7d47

Browse files
authored
fix: add stdio in execute_skills tool (#445)
1 parent c5d5f13 commit 3fa7d47

File tree

3 files changed

+16
-10
lines changed

3 files changed

+16
-10
lines changed

veadk/tools/builtin_tools/execute_skills.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ def execute_skills(
165165
if time.time() - start_time > timeout:
166166
process.kill()
167167
log_file.write('log_type=stderr request_id=x function_id=y revision_number=1 Process timeout\\n')
168+
print("Process timeout", end='', file=sys.stderr)
168169
break
169170
170171
reads = [process.stdout.fileno(), process.stderr.fileno()]
@@ -176,23 +177,23 @@ def execute_skills(
176177
if line:
177178
log_file.write(f'log_type=stdout request_id=x function_id=y revision_number=1 {{line}}')
178179
log_file.flush()
180+
print(line, end='')
179181
if fd == process.stderr.fileno():
180182
line = process.stderr.readline()
181183
if line:
182184
log_file.write(f'log_type=stderr request_id=x function_id=y revision_number=1 {{line}}')
183185
log_file.flush()
186+
print(line, end='', file=sys.stderr)
184187
185188
if process.poll() is not None:
186189
break
187190
188191
for line in process.stdout:
189192
log_file.write(f'log_type=stdout request_id=x function_id=y revision_number=1 {{line}}')
193+
print(line, end='')
190194
for line in process.stderr:
191195
log_file.write(f'log_type=stderr request_id=x function_id=y revision_number=1 {{line}}')
192-
193-
with open('/tmp/agent.log', 'r') as log_file:
194-
output = log_file.read()
195-
print(output)
196+
print(line, end='', file=sys.stderr)
196197
"""
197198

198199
res = ve_request(

veadk/tools/skills_tools/session_path.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
import platform
1516
import tempfile
1617
from pathlib import Path
1718
from veadk.utils.logger import get_logger
@@ -47,7 +48,11 @@ def initialize_session_path(session_id: str) -> Path:
4748
return _session_path_cache[session_id]
4849

4950
# Initialize new session path
50-
base_path = Path(tempfile.gettempdir()) / "veadk"
51+
if platform.system() in ("Linux", "Darwin"): # Linux or macOS
52+
base_path = Path("/tmp") / "veadk"
53+
else: # Windows
54+
base_path = Path(tempfile.gettempdir()) / "veadk"
55+
5156
session_path = base_path / session_id
5257

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

5863
# Cache and return
59-
resolved_path = session_path.resolve()
64+
resolved_path = session_path
6065
_session_path_cache[session_id] = resolved_path
66+
logger.info(f"Initialized session path for {session_id}: {resolved_path}")
6167
return resolved_path
6268

6369

veadk/tools/skills_tools/skills_tool.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@
1515
from __future__ import annotations
1616

1717
import os
18-
import tempfile
1918
from pathlib import Path
2019
from typing import Any, Dict
2120

2221
from google.adk.tools import BaseTool, ToolContext
2322
from google.genai import types
2423

2524
from veadk.skills.skill import Skill
25+
from veadk.tools.skills_tools.session_path import get_session_path
2626
from veadk.utils.logger import get_logger
2727

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

104104
skill = self.skills[skill_name]
105-
skill_dir = (
106-
Path(tempfile.gettempdir()) / "veadk" / tool_context.session.id / "skills"
107-
)
105+
working_dir = get_session_path(session_id=tool_context.session.id)
106+
skill_dir = working_dir / "skills"
108107

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

0 commit comments

Comments
 (0)