Home / Class/ _SessionResources Class — langchain Architecture

_SessionResources Class — langchain Architecture

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

Entity Profile

Dependency Diagram

graph TD
  5d2512a3_e409_84e0_6a6f_14d3dcc37899["_SessionResources"]
  943b36d5_cd9f_c106_7d11_56e39e63078a["shell_tool.py"]
  5d2512a3_e409_84e0_6a6f_14d3dcc37899 -->|defined in| 943b36d5_cd9f_c106_7d11_56e39e63078a
  401ae78d_a89f_6a3e_a57a_8d63e2751ee0["__post_init__()"]
  5d2512a3_e409_84e0_6a6f_14d3dcc37899 -->|method| 401ae78d_a89f_6a3e_a57a_8d63e2751ee0

Relationship Graph

Source Code

libs/langchain_v1/langchain/agents/middleware/shell_tool.py lines 82–97

class _SessionResources:
    """Container for per-run shell resources."""

    session: ShellSession
    tempdir: tempfile.TemporaryDirectory[str] | None
    policy: BaseExecutionPolicy
    finalizer: weakref.finalize = field(init=False, repr=False)  # type: ignore[type-arg]

    def __post_init__(self) -> None:
        self.finalizer = weakref.finalize(
            self,
            _cleanup_resources,
            self.session,
            self.tempdir,
            self.policy.termination_timeout,
        )

Frequently Asked Questions

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

Analyze Your Own Codebase

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

Try Supermodel Free