mirror of
https://github.com/encounter/adk-python.git
synced 2026-07-09 18:19:28 -07:00
chore: Let tools to handle root directory resolvement and model only knows the project name and always use relative path
PiperOrigin-RevId: 816213558
This commit is contained in:
committed by
Copybara-Service
parent
3f4bd67b49
commit
3be9cd844c
@@ -20,9 +20,14 @@ import shutil
|
||||
from typing import Any
|
||||
from typing import Dict
|
||||
|
||||
from google.adk.tools.tool_context import ToolContext
|
||||
|
||||
from ..utils.resolve_root_directory import resolve_file_path
|
||||
|
||||
|
||||
async def write_files(
|
||||
files: Dict[str, str],
|
||||
tool_context: ToolContext,
|
||||
create_backup: bool = False,
|
||||
create_directories: bool = True,
|
||||
) -> Dict[str, Any]:
|
||||
@@ -50,6 +55,9 @@ async def write_files(
|
||||
- errors: list of general error messages
|
||||
"""
|
||||
try:
|
||||
# Get session state for path resolution
|
||||
session_state = tool_context._invocation_context.session.state
|
||||
|
||||
result = {
|
||||
"success": True,
|
||||
"files": {},
|
||||
@@ -59,7 +67,9 @@ async def write_files(
|
||||
}
|
||||
|
||||
for file_path, content in files.items():
|
||||
file_path_obj = Path(file_path).resolve()
|
||||
# Resolve file path using session state
|
||||
resolved_path = resolve_file_path(file_path, session_state)
|
||||
file_path_obj = resolved_path.resolve()
|
||||
file_info = {
|
||||
"file_size": 0,
|
||||
"existed_before": False,
|
||||
|
||||
Reference in New Issue
Block a user