Home / Class/ StateClaudeTextEditorMiddleware Class — langchain Architecture

StateClaudeTextEditorMiddleware Class — langchain Architecture

Architecture documentation for the StateClaudeTextEditorMiddleware class in anthropic_tools.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  ba1d700c_cfc4_61d4_2b3c_6d382a654377["StateClaudeTextEditorMiddleware"]
  2e6eda6f_54cd_9575_7c70_af4582d5a816["_StateClaudeFileToolMiddleware"]
  ba1d700c_cfc4_61d4_2b3c_6d382a654377 -->|extends| 2e6eda6f_54cd_9575_7c70_af4582d5a816
  5f8ab4b6_f98f_f653_1208_76332f94ecba["anthropic_tools.py"]
  ba1d700c_cfc4_61d4_2b3c_6d382a654377 -->|defined in| 5f8ab4b6_f98f_f653_1208_76332f94ecba
  34564434_b2a3_0763_63c1_b0a9630a6d8a["__init__()"]
  ba1d700c_cfc4_61d4_2b3c_6d382a654377 -->|method| 34564434_b2a3_0763_63c1_b0a9630a6d8a

Relationship Graph

Source Code

libs/partners/anthropic/langchain_anthropic/middleware/anthropic_tools.py lines 572–608

class StateClaudeTextEditorMiddleware(_StateClaudeFileToolMiddleware):
    """State-based text editor tool middleware.

    Provides Anthropic's `text_editor` tool using LangGraph state for storage.
    Files persist for the conversation thread.

    Example:
        ```python
        from langchain.agents import create_agent
        from langchain.agents.middleware import StateTextEditorToolMiddleware

        agent = create_agent(
            model=model,
            tools=[],
            middleware=[StateTextEditorToolMiddleware()],
        )
        ```
    """

    def __init__(
        self,
        *,
        allowed_path_prefixes: Sequence[str] | None = None,
    ) -> None:
        """Initialize the text editor middleware.

        Args:
            allowed_path_prefixes: Optional list of allowed path prefixes.

                If specified, only paths starting with these prefixes are allowed.
        """
        super().__init__(
            tool_type=TEXT_EDITOR_TOOL_TYPE,
            tool_name=TEXT_EDITOR_TOOL_NAME,
            state_key="text_editor_files",
            allowed_path_prefixes=allowed_path_prefixes,
        )

Frequently Asked Questions

What is the StateClaudeTextEditorMiddleware class?
StateClaudeTextEditorMiddleware is a class in the langchain codebase, defined in libs/partners/anthropic/langchain_anthropic/middleware/anthropic_tools.py.
Where is StateClaudeTextEditorMiddleware defined?
StateClaudeTextEditorMiddleware is defined in libs/partners/anthropic/langchain_anthropic/middleware/anthropic_tools.py at line 572.
What does StateClaudeTextEditorMiddleware extend?
StateClaudeTextEditorMiddleware extends _StateClaudeFileToolMiddleware.

Analyze Your Own Codebase

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

Try Supermodel Free