Home / Class/ _ShellToolInput Class — langchain Architecture

_ShellToolInput Class — langchain Architecture

Architecture documentation for the _ShellToolInput class in shell_tool.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  c45f8d5a_ae16_b5a8_9671_5eb4440ec745["_ShellToolInput"]
  943b36d5_cd9f_c106_7d11_56e39e63078a["shell_tool.py"]
  c45f8d5a_ae16_b5a8_9671_5eb4440ec745 -->|defined in| 943b36d5_cd9f_c106_7d11_56e39e63078a
  577808c7_3d4f_c97e_63e5_a48464fcbc9b["validate_payload()"]
  c45f8d5a_ae16_b5a8_9671_5eb4440ec745 -->|method| 577808c7_3d4f_c97e_63e5_a48464fcbc9b

Relationship Graph

Source Code

libs/langchain_v1/langchain/agents/middleware/shell_tool.py lines 462–486

class _ShellToolInput(BaseModel):
    """Input schema for the persistent shell tool."""

    command: str | None = None
    """The shell command to execute."""

    restart: bool | None = None
    """Whether to restart the shell session."""

    runtime: Annotated[Any, SkipJsonSchema()] = None
    """The runtime for the shell tool.

    Included as a workaround at the moment bc args_schema doesn't work with
    injected ToolRuntime.
    """

    @model_validator(mode="after")
    def validate_payload(self) -> _ShellToolInput:
        if self.command is None and not self.restart:
            msg = "Shell tool requires either 'command' or 'restart'."
            raise ValueError(msg)
        if self.command is not None and self.restart:
            msg = "Specify only one of 'command' or 'restart'."
            raise ValueError(msg)
        return self

Frequently Asked Questions

What is the _ShellToolInput class?
_ShellToolInput is a class in the langchain codebase, defined in libs/langchain_v1/langchain/agents/middleware/shell_tool.py.
Where is _ShellToolInput defined?
_ShellToolInput is defined in libs/langchain_v1/langchain/agents/middleware/shell_tool.py at line 462.

Analyze Your Own Codebase

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

Try Supermodel Free