PlimsollCodeTool gives a LangChain or LangGraphagent one tool, plimsoll_run_code, that runs the model's Python or JavaScript in a fresh plimsoll sandbox and tells the model whether the code ran, failed, or was refused before it could run.
LangChain: an open-source framework for building agents on language models. A LangChaintool is also a LangGraph tool, so LangChain's create_agent, LangGraph's ToolNode and graphs of your own all call it the same way. LangChain (EXTERNAL · official docs ↗)
The Professor (a fictional narrator)
LangChain links the steps, LangGraph draws the map, and plimsoll keeps the code in a room it cannot leave. Somebody had to take the job with no windows.
Real quote
Donald E. Knuth: “Beware of bugs in the above code; I have only proved it correct, not tried it.”
Replay a recorded scenario. The diagram lights each hop the call passes; a refused call stops where it is refused.
These buttons send no execution requests. Each answer's source states how it was recorded, including any fixture used.
Exception panels show what reached the application, rather than an invented code result.
The model asks for
The tool answers the model
The Professor (a fictional narrator)
Each step of the call
The model: The language model decides to run code and writes the arguments: the code, its language and any input files.
LangChain: LangChain checks the model's arguments against the tool's args_schema (the language list included) and calls the tool; a call that does not fit stops here. LangGraph's ToolNode calls the tool through the same method.
PlimsollCodeTool: Checks the arguments, hands them to the executor, and turns whatever comes back into the JSON the model reads: ran true, false or "unknown".
CodeExecutor: Asks the daemon what it is, refuses if its isolation tier is below the floor or it lacks the language, then sends the code and files as one fresh project with a fixed command.
plimsolld: Checks the floor again against its current evidence, admits the run if it has capacity, and states a run record of exactly what it ran and answered.
Fresh sandbox: A new locked-down container with no network: the files are written, the code runs once, and the container is removed.
How thick should the walls be?
The executor carries a floor; the daemon states its
isolation tier. This picker is a teaching simulation:
change either to see whether the tier meets the floor. It sends no request and does not check other capabilities.
The Professor (a fictional narrator)
The executor's floor defaults to kernel: docker under runc is the container tier and refuses every call until it runs gVisor, or the executor is built with an explicit container floor, which is for development on your own code only. Use the spelling shown in this page's wiring example.
Surprises and limits
One tool for LangChain and LangGraphPlimsollCodeTool is a LangChainBaseTool, so LangChain's create_agent, LangGraph's ToolNode and a graph of your own call it the same way, with invoke or ainvoke. The extra installs only langchain-core; create_agent comes with the langchain package.
The default floor refuses plain DockerCodeExecutor's floor is kernel. A daemon on docker under runc is the container tier and refuses every call until it runs gVisor, or until the executor is built with minimum_isolation="container", which is for development on your own code only.
Nothing persists between callsEvery call is a fresh sandbox: no variable, import or file from an earlier call is there, and the tool's description says so. An agent that needs files and a shell kept from one command to the next wants plimsoll's Deep Agents backend instead, which serves one session for the agent's whole run.
The answer is the JSON textThe tool answers with its JSON as the ToolMessage's content, which already carries the run record's digest. It refuses a response_format other than "content", so the answer always reaches the model whole.
Cancelling ainvoke cancels the callainvoke runs the call in a worker thread with a cancel handle that is cancelled with the await. Cancelled before the run request is sent (while the daemon is still answering Describe, say), the call never sends it. Cancelled while the run is in flight, its connection is cut and the thread ends at once. The code may have run by then; the daemon stops it only if its provider honors the closed connection.