mirror of
https://github.com/bytedance/deer-flow.git
synced 2026-08-01 19:06:01 +00:00
chore: remove unused private helper functions (dead code) (#3749)
These three module-private helpers have no callers anywhere in the repo (verified by a repo-wide identifier scan + direct greps; each appears only at its own definition): - agents/memory/updater.py: _create_empty_memory (a no-caller wrapper around storage.create_empty_memory, which is used directly elsewhere) - runtime/runs/worker.py: _extract_human_message (also drops the now-unused HumanMessage TYPE_CHECKING import and TYPE_CHECKING from typing) - sandbox/tools.py: _looks_like_unsafe_cwd_target (cwd safety is enforced via _is_allowed_local_bash_absolute_path) Underscore-prefixed = module-internal, so zero references is conclusive. Route handlers and @compiles-registered functions were excluded as false positives. Public-surface candidates are noted in the issue, not touched here. Fixes #3748.
This commit is contained in:
parent
fde6885aea
commit
67dd75db62
@ -38,11 +38,6 @@ _SYNC_MEMORY_UPDATER_EXECUTOR = concurrent.futures.ThreadPoolExecutor(
|
|||||||
atexit.register(lambda: _SYNC_MEMORY_UPDATER_EXECUTOR.shutdown(wait=False))
|
atexit.register(lambda: _SYNC_MEMORY_UPDATER_EXECUTOR.shutdown(wait=False))
|
||||||
|
|
||||||
|
|
||||||
def _create_empty_memory() -> dict[str, Any]:
|
|
||||||
"""Backward-compatible wrapper around the storage-layer empty-memory factory."""
|
|
||||||
return create_empty_memory()
|
|
||||||
|
|
||||||
|
|
||||||
def _save_memory_to_file(memory_data: dict[str, Any], agent_name: str | None = None, *, user_id: str | None = None) -> bool:
|
def _save_memory_to_file(memory_data: dict[str, Any], agent_name: str | None = None, *, user_id: str | None = None) -> bool:
|
||||||
"""Backward-compatible wrapper around the configured memory storage save path."""
|
"""Backward-compatible wrapper around the configured memory storage save path."""
|
||||||
return get_memory_storage().save(memory_data, agent_name, user_id=user_id)
|
return get_memory_storage().save(memory_data, agent_name, user_id=user_id)
|
||||||
|
|||||||
@ -22,13 +22,10 @@ import logging
|
|||||||
import os
|
import os
|
||||||
from dataclasses import dataclass, field
|
from dataclasses import dataclass, field
|
||||||
from functools import lru_cache
|
from functools import lru_cache
|
||||||
from typing import TYPE_CHECKING, Any, Literal, cast
|
from typing import Any, Literal, cast
|
||||||
|
|
||||||
from langgraph.checkpoint.base import empty_checkpoint
|
from langgraph.checkpoint.base import empty_checkpoint
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
|
||||||
from langchain_core.messages import HumanMessage
|
|
||||||
|
|
||||||
from deerflow.config.app_config import AppConfig
|
from deerflow.config.app_config import AppConfig
|
||||||
from deerflow.runtime.serialization import serialize
|
from deerflow.runtime.serialization import serialize
|
||||||
from deerflow.runtime.stream_bridge import StreamBridge
|
from deerflow.runtime.stream_bridge import StreamBridge
|
||||||
@ -642,31 +639,6 @@ def _extract_llm_error_fallback_message(value: Any) -> str | None:
|
|||||||
return walk(value)
|
return walk(value)
|
||||||
|
|
||||||
|
|
||||||
def _extract_human_message(graph_input: dict) -> HumanMessage | None:
|
|
||||||
"""Extract or construct a HumanMessage from graph_input for event recording.
|
|
||||||
|
|
||||||
Returns a LangChain HumanMessage so callers can use .model_dump() to get
|
|
||||||
the checkpoint-aligned serialization format.
|
|
||||||
"""
|
|
||||||
from langchain_core.messages import HumanMessage
|
|
||||||
|
|
||||||
messages = graph_input.get("messages")
|
|
||||||
if not messages:
|
|
||||||
return None
|
|
||||||
last = messages[-1] if isinstance(messages, list) else messages
|
|
||||||
if isinstance(last, HumanMessage):
|
|
||||||
return last
|
|
||||||
if isinstance(last, str):
|
|
||||||
return HumanMessage(content=last) if last else None
|
|
||||||
if hasattr(last, "content"):
|
|
||||||
content = last.content
|
|
||||||
return HumanMessage(content=content)
|
|
||||||
if isinstance(last, dict):
|
|
||||||
content = last.get("content", "")
|
|
||||||
return HumanMessage(content=content) if content else None
|
|
||||||
return None
|
|
||||||
|
|
||||||
|
|
||||||
def _unpack_stream_item(
|
def _unpack_stream_item(
|
||||||
item: Any,
|
item: Any,
|
||||||
lg_modes: list[str],
|
lg_modes: list[str],
|
||||||
|
|||||||
@ -855,12 +855,6 @@ def _validate_local_bash_cwd_target(command_name: str, target: str | None, allow
|
|||||||
raise PermissionError(f"Unsafe working directory change in command: {command_name} {target}. Use paths under {VIRTUAL_PATH_PREFIX}")
|
raise PermissionError(f"Unsafe working directory change in command: {command_name} {target}. Use paths under {VIRTUAL_PATH_PREFIX}")
|
||||||
|
|
||||||
|
|
||||||
def _looks_like_unsafe_cwd_target(target: str | None) -> bool:
|
|
||||||
if target is None:
|
|
||||||
return False
|
|
||||||
return target == "-" or target.startswith(("$", "`", "~", "/", "..")) or _has_dotdot_path_segment(target)
|
|
||||||
|
|
||||||
|
|
||||||
def _validate_local_bash_root_path_args(command_name: str, tokens: list[str], start_index: int) -> None:
|
def _validate_local_bash_root_path_args(command_name: str, tokens: list[str], start_index: int) -> None:
|
||||||
if command_name not in _LOCAL_BASH_ROOT_PATH_COMMANDS:
|
if command_name not in _LOCAL_BASH_ROOT_PATH_COMMANDS:
|
||||||
return
|
return
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user