_create_resources() — langchain Function Reference
Architecture documentation for the _create_resources() function in shell_tool.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 3d2455b7_eaeb_053d_fc17_21aaa32050ca["_create_resources()"] 4e57a0ff_f1a5_e2e9_6949_569d7cd6d70a["ShellToolMiddleware"] 3d2455b7_eaeb_053d_fc17_21aaa32050ca -->|defined in| 4e57a0ff_f1a5_e2e9_6949_569d7cd6d70a d039cdea_065a_8bce_2925_ec6f88d67fb1["_get_or_create_resources()"] d039cdea_065a_8bce_2925_ec6f88d67fb1 -->|calls| 3d2455b7_eaeb_053d_fc17_21aaa32050ca c6011545_45bb_9aa6_7568_fa418072d163["_run_startup_commands()"] 3d2455b7_eaeb_053d_fc17_21aaa32050ca -->|calls| c6011545_45bb_9aa6_7568_fa418072d163 a66768b0_c906_c61b_b24b_37fd445b1af9["start()"] 3d2455b7_eaeb_053d_fc17_21aaa32050ca -->|calls| a66768b0_c906_c61b_b24b_37fd445b1af9 8e7ca27f_5ba4_f43b_b7dd_ea19f14cf7c4["stop()"] 3d2455b7_eaeb_053d_fc17_21aaa32050ca -->|calls| 8e7ca27f_5ba4_f43b_b7dd_ea19f14cf7c4 style 3d2455b7_eaeb_053d_fc17_21aaa32050ca fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/langchain_v1/langchain/agents/middleware/shell_tool.py lines 696–723
def _create_resources(self) -> _SessionResources:
workspace = self._workspace_root
tempdir: tempfile.TemporaryDirectory[str] | None = None
if workspace is None:
tempdir = tempfile.TemporaryDirectory(prefix=SHELL_TEMP_PREFIX)
workspace_path = Path(tempdir.name)
else:
workspace_path = workspace
workspace_path.mkdir(parents=True, exist_ok=True)
session = ShellSession(
workspace_path,
self._execution_policy,
self._shell_command,
self._environment or {},
)
try:
session.start()
LOGGER.info("Started shell session in %s", workspace_path)
self._run_startup_commands(session)
except BaseException:
LOGGER.exception("Starting shell session failed; cleaning up resources.")
session.stop(self._execution_policy.termination_timeout)
if tempdir is not None:
tempdir.cleanup()
raise
return _SessionResources(session=session, tempdir=tempdir, policy=self._execution_policy)
Domain
Subdomains
Called By
Source
Frequently Asked Questions
What does _create_resources() do?
_create_resources() is a function in the langchain codebase, defined in libs/langchain_v1/langchain/agents/middleware/shell_tool.py.
Where is _create_resources() defined?
_create_resources() is defined in libs/langchain_v1/langchain/agents/middleware/shell_tool.py at line 696.
What does _create_resources() call?
_create_resources() calls 3 function(s): _run_startup_commands, start, stop.
What calls _create_resources()?
_create_resources() is called by 1 function(s): _get_or_create_resources.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free