Home / Function/ _handle_rename() — langchain Function Reference

_handle_rename() — langchain Function Reference

Architecture documentation for the _handle_rename() function in anthropic_tools.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  e036d288_ed03_4984_8199_018cccb818c3["_handle_rename()"]
  87c73dc6_9eac_4f37_3263_c6a4d3764b6e["_FilesystemClaudeFileToolMiddleware"]
  e036d288_ed03_4984_8199_018cccb818c3 -->|defined in| 87c73dc6_9eac_4f37_3263_c6a4d3764b6e
  d5828fea_01d0_2456_5f33_0a53ee547827["_handle_rename()"]
  d5828fea_01d0_2456_5f33_0a53ee547827 -->|calls| e036d288_ed03_4984_8199_018cccb818c3
  32d77b79_4a98_2de5_3e92_7514829faaa3["__init__()"]
  32d77b79_4a98_2de5_3e92_7514829faaa3 -->|calls| e036d288_ed03_4984_8199_018cccb818c3
  f268378f_de49_cc43_eb3b_bb6313c21433["_validate_and_resolve_path()"]
  e036d288_ed03_4984_8199_018cccb818c3 -->|calls| f268378f_de49_cc43_eb3b_bb6313c21433
  d5828fea_01d0_2456_5f33_0a53ee547827["_handle_rename()"]
  e036d288_ed03_4984_8199_018cccb818c3 -->|calls| d5828fea_01d0_2456_5f33_0a53ee547827
  style e036d288_ed03_4984_8199_018cccb818c3 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/partners/anthropic/langchain_anthropic/middleware/anthropic_tools.py lines 1033–1061

    def _handle_rename(self, args: dict, tool_call_id: str | None) -> Command:
        """Handle rename command."""
        old_path = args["old_path"]
        new_path = args["new_path"]

        old_full = self._validate_and_resolve_path(old_path)
        new_full = self._validate_and_resolve_path(new_path)

        if not old_full.exists():
            msg = f"File not found: {old_path}"
            raise ValueError(msg)

        # Create parent directory for new path
        new_full.parent.mkdir(parents=True, exist_ok=True)

        # Rename
        old_full.rename(new_full)

        return Command(
            update={
                "messages": [
                    ToolMessage(
                        content=f"File renamed: {old_path} -> {new_path}",
                        tool_call_id=tool_call_id,
                        name=self.tool_name,
                    )
                ]
            }
        )

Domain

Subdomains

Frequently Asked Questions

What does _handle_rename() do?
_handle_rename() is a function in the langchain codebase, defined in libs/partners/anthropic/langchain_anthropic/middleware/anthropic_tools.py.
Where is _handle_rename() defined?
_handle_rename() is defined in libs/partners/anthropic/langchain_anthropic/middleware/anthropic_tools.py at line 1033.
What does _handle_rename() call?
_handle_rename() calls 2 function(s): _handle_rename, _validate_and_resolve_path.
What calls _handle_rename()?
_handle_rename() is called by 2 function(s): __init__, _handle_rename.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free