Skip to content

Commit 7e7073b

Browse files
committed
fix: save to file tool
1 parent 8bfc8f8 commit 7e7073b

File tree

2 files changed

+18
-11
lines changed

2 files changed

+18
-11
lines changed

lfx/src/lfx/components/data/save_file.py

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -427,8 +427,12 @@ def _save_data(self, data: Data, path: Path, fmt: str) -> str:
427427
)
428428

429429
if is_text_empty and is_data_empty:
430-
print(f"[SaveFile] ⚠️ SKIP: Data content is empty, skipping write. data.data={repr(data.data)}, text={repr(text_content)}", flush=True)
430+
print(
431+
f"[SaveFile] ⚠️ SKIP: Data content is empty, skipping write. data.data={repr(data.data)}, text={repr(text_content)}",
432+
flush=True,
433+
)
431434
logger.info(f"[SaveFile] Skipping write to '{path}' - content is empty")
435+
setattr(self, "_skipped_last_write", True)
432436
return f"Skipped writing empty content to '{path}'"
433437

434438
file_exists = path.exists()
@@ -609,8 +613,12 @@ async def _save_message(self, message: Message, path: Path, fmt: str) -> str:
609613
# This prevents writing empty files which indicates a problem in the workflow
610614
print(f"[SaveFile] 💾 Final content: type={type(content).__name__}, length={len(content) if isinstance(content, str) else 'N/A'}, value={repr(content)[:200]}", flush=True)
611615
if not content or (isinstance(content, str) and content.strip() == ""):
612-
print(f"[SaveFile] ⚠️ SKIP: Content is empty, skipping write. message.text={repr(message.text)}, content={repr(content)}", flush=True)
616+
print(
617+
f"[SaveFile] ⚠️ SKIP: Content is empty, skipping write. message.text={repr(message.text)}, content={repr(content)}",
618+
flush=True,
619+
)
613620
logger.info(f"[SaveFile] Skipping write to '{path}' - content is empty")
621+
setattr(self, "_skipped_last_write", True)
614622
return f"Skipped writing empty content to '{path}'"
615623

616624
if fmt == "txt":
@@ -788,6 +796,9 @@ async def _save_to_local(self) -> Message:
788796
print(f"[SaveFile] 📁 Target file path: {file_path}", flush=True)
789797
print(f"[SaveFile] 📁 File exists: {file_path.exists()}", flush=True)
790798

799+
# Track whether we skipped writing due to empty content
800+
setattr(self, "_skipped_last_write", False)
801+
791802
# Save the input to file based on type
792803
if input_type == "DataFrame":
793804
confirmation = self._save_dataframe(self.input, file_path, file_format)
@@ -801,8 +812,11 @@ async def _save_to_local(self) -> Message:
801812

802813
print(f"[SaveFile] ✅ Save result: {confirmation}", flush=True)
803814

804-
# Upload the saved file
805-
await self._upload_file(file_path)
815+
# Upload the saved file only if we actually wrote content
816+
if not getattr(self, "_skipped_last_write", False):
817+
await self._upload_file(file_path)
818+
else:
819+
print("[SaveFile] ⏭️ Upload skipped because no content was written.", flush=True)
806820

807821
# Return the final file path and confirmation message
808822
final_path = Path.cwd() / file_path if not file_path.is_absolute() else file_path

src/tool_executor/api.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -757,13 +757,6 @@ async def execute_component(request: ExecutionRequest) -> ExecutionResponse:
757757
deserialized_inputs["tools"] = sanitized_tools
758758

759759
_summarize_parameters("parameters/final", component_params)
760-
761-
# DEBUG: Log api_key before instantiation for AgentQL
762-
if request.component_state.component_class == "AgentQL" and "api_key" in component_params:
763-
api_key_val = component_params.get("api_key")
764-
print(f"[EXECUTOR] 🎯 AgentQL api_key in component_params BEFORE instantiation: {repr(api_key_val)}", flush=True)
765-
logger.info(f"[EXECUTOR] 🎯 AgentQL api_key in component_params: {repr(api_key_val)}")
766-
767760
component = component_class(**component_params)
768761

769762
# DEBUG: Verify api_key is set on component instance

0 commit comments

Comments
 (0)