Home / Function/ __init__() — langchain Function Reference

__init__() — langchain Function Reference

Architecture documentation for the __init__() function in bash.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  8fe68124_9d88_a35c_da48_d4babf4a2b1f["__init__()"]
  546b3f0b_6988_ae2d_a04f_e60cc048d3ff["ClaudeBashToolMiddleware"]
  8fe68124_9d88_a35c_da48_d4babf4a2b1f -->|defined in| 546b3f0b_6988_ae2d_a04f_e60cc048d3ff
  style 8fe68124_9d88_a35c_da48_d4babf4a2b1f fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/partners/anthropic/langchain_anthropic/middleware/bash.py lines 22–57

    def __init__(
        self,
        workspace_root: str | None = None,
        *,
        startup_commands: tuple[str, ...] | list[str] | str | None = None,
        shutdown_commands: tuple[str, ...] | list[str] | str | None = None,
        execution_policy: Any | None = None,
        redaction_rules: tuple[Any, ...] | list[Any] | None = None,
        tool_description: str | None = None,
        env: dict[str, Any] | None = None,
    ) -> None:
        """Initialize middleware for Claude's native bash tool.

        Args:
            workspace_root: Base directory for the shell session.

                If omitted, a temporary directory is created.
            startup_commands: Optional commands executed after the session starts.
            shutdown_commands: Optional commands executed before session shutdown.
            execution_policy: Execution policy controlling timeouts and limits.
            redaction_rules: Optional redaction rules to sanitize output.
            tool_description: Optional override for tool description.
            env: Optional environment variables for the shell session.
        """
        super().__init__(
            workspace_root=workspace_root,
            startup_commands=startup_commands,
            shutdown_commands=shutdown_commands,
            execution_policy=execution_policy,
            redaction_rules=redaction_rules,
            tool_description=tool_description,
            tool_name=BASH_TOOL_NAME,
            shell_command=("/bin/bash",),
            env=env,
        )
        # Parent class now creates the tool with name "bash" via tool_name parameter

Domain

Subdomains

Frequently Asked Questions

What does __init__() do?
__init__() is a function in the langchain codebase, defined in libs/partners/anthropic/langchain_anthropic/middleware/bash.py.
Where is __init__() defined?
__init__() is defined in libs/partners/anthropic/langchain_anthropic/middleware/bash.py at line 22.

Analyze Your Own Codebase

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

Try Supermodel Free