langchain-plimsoll 0.28.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- langchain_plimsoll-0.28.0/LICENSE +201 -0
- langchain_plimsoll-0.28.0/PKG-INFO +223 -0
- langchain_plimsoll-0.28.0/README.md +202 -0
- langchain_plimsoll-0.28.0/pyproject.toml +43 -0
- langchain_plimsoll-0.28.0/setup.cfg +4 -0
- langchain_plimsoll-0.28.0/src/langchain_plimsoll/__init__.py +45 -0
- langchain_plimsoll-0.28.0/src/langchain_plimsoll/py.typed +0 -0
- langchain_plimsoll-0.28.0/src/langchain_plimsoll.egg-info/PKG-INFO +223 -0
- langchain_plimsoll-0.28.0/src/langchain_plimsoll.egg-info/SOURCES.txt +10 -0
- langchain_plimsoll-0.28.0/src/langchain_plimsoll.egg-info/dependency_links.txt +1 -0
- langchain_plimsoll-0.28.0/src/langchain_plimsoll.egg-info/requires.txt +5 -0
- langchain_plimsoll-0.28.0/src/langchain_plimsoll.egg-info/top_level.txt +1 -0
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2026 Carroll Guertin
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: langchain-plimsoll
|
|
3
|
+
Version: 0.28.0
|
|
4
|
+
Summary: A LangChain tool and a Deep Agents sandbox backend that run agent-written code in plimsoll, a self-hosted sandbox that refuses to run below the isolation you require
|
|
5
|
+
License-Expression: Apache-2.0
|
|
6
|
+
Project-URL: Homepage, https://github.com/plimsollmark/plimsoll/tree/main/clients/python/langchain-plimsoll
|
|
7
|
+
Project-URL: Source, https://github.com/plimsollmark/plimsoll/tree/main/clients/python/langchain-plimsoll
|
|
8
|
+
Project-URL: Issues, https://github.com/plimsollmark/plimsoll/issues
|
|
9
|
+
Keywords: langchain,langgraph,deepagents,sandbox,code execution,agents,gvisor
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
12
|
+
Classifier: Typing :: Typed
|
|
13
|
+
Requires-Python: >=3.11
|
|
14
|
+
Description-Content-Type: text/markdown
|
|
15
|
+
License-File: LICENSE
|
|
16
|
+
Requires-Dist: langchain-core==1.8.0
|
|
17
|
+
Requires-Dist: plimsoll-client==0.28.0
|
|
18
|
+
Provides-Extra: deepagents
|
|
19
|
+
Requires-Dist: deepagents==0.7.38; extra == "deepagents"
|
|
20
|
+
Dynamic: license-file
|
|
21
|
+
|
|
22
|
+
# langchain-plimsoll
|
|
23
|
+
|
|
24
|
+
An agent that writes code has to run it somewhere, and "somewhere" is usually your machine or a hosted sandbox you
|
|
25
|
+
cannot inspect. This package runs a LangChain, LangGraph or Deep Agents agent's code in plimsoll, a sandbox service you
|
|
26
|
+
run yourself, and it has no fallback: if the sandbox is weaker than you asked for, nothing runs.
|
|
27
|
+
|
|
28
|
+
It has two parts:
|
|
29
|
+
|
|
30
|
+
- **`PlimsollCodeTool`**, a LangChain tool (`plimsoll_run_code`) that runs each call in a fresh sandbox. LangGraph's
|
|
31
|
+
`ToolNode`, `create_agent` and any graph of your own call it like any other LangChain tool.
|
|
32
|
+
- **`PlimsollSandbox`**, a Deep Agents sandbox backend over one plimsoll session: one sandbox kept for the agent's whole
|
|
33
|
+
run, so the files it writes and the shell's directory are there for its next command. Deep Agents gives the agent its
|
|
34
|
+
`execute` tool and its file tools (`ls`, `read_file`, `write_file`, `edit_file`, `glob`, `grep`) on top of it
|
|
35
|
+
([Deep Agents sandboxes (EXTERNAL · official docs ↗)](https://docs.langchain.com/oss/python/deepagents/sandboxes)).
|
|
36
|
+
|
|
37
|
+
## Install
|
|
38
|
+
|
|
39
|
+
```sh
|
|
40
|
+
pip install langchain-plimsoll # the tool: needs only langchain-core
|
|
41
|
+
pip install 'langchain-plimsoll[deepagents]' # and the Deep Agents backend
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
The tool needs only `langchain-core`. The example below builds its agent with `create_agent`, which is in `langchain`:
|
|
45
|
+
`pip install langchain` for it.
|
|
46
|
+
|
|
47
|
+
It needs a running `plimsolld`, the plimsoll daemon, reachable from the agent
|
|
48
|
+
([getting started (EXTERNAL · source repo ↗)](https://github.com/plimsollmark/plimsoll/blob/main/docs/getting-started.md)).
|
|
49
|
+
The tool's default language is Python, which on docker needs a project image with `python3` in it
|
|
50
|
+
(`SANDBOX_DOCKER_PROJECT_IMAGE=plimsoll/sandbox-python:latest`): on the default image every Python call comes back
|
|
51
|
+
refused. Python 3.11 or later, as langchain-core requires.
|
|
52
|
+
|
|
53
|
+
## Use the tool
|
|
54
|
+
|
|
55
|
+
```python
|
|
56
|
+
from langchain.agents import create_agent
|
|
57
|
+
from langchain_plimsoll import Client, CodeExecutor, PlimsollCodeTool
|
|
58
|
+
|
|
59
|
+
executor = CodeExecutor(Client("https://plimsoll.internal:8746", token=TOKEN))
|
|
60
|
+
agent = create_agent(model, tools=[PlimsollCodeTool(executor)])
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
The agent passes the tool code (Python or JavaScript) and optional input files, and gets back JSON saying whether the code
|
|
64
|
+
ran (yes, no with the reason, or unknown), the output, the exit code, whether anything was cut short or timed out, the
|
|
65
|
+
isolation tier the code ran behind, and the SHA-256 of the run's record.
|
|
66
|
+
|
|
67
|
+
## Use the Deep Agents backend
|
|
68
|
+
|
|
69
|
+
```python
|
|
70
|
+
from deepagents import create_deep_agent
|
|
71
|
+
from langchain_plimsoll import Client, PlimsollSandbox
|
|
72
|
+
|
|
73
|
+
with PlimsollSandbox.open(Client("https://plimsoll.internal:8746", token=TOKEN)) as backend:
|
|
74
|
+
agent = create_deep_agent(model=model, backend=backend, system_prompt=f"Work in {backend.root}.")
|
|
75
|
+
agent.invoke({"messages": [{"role": "user", "content": "Write and test a CSV parser."}]})
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
Deep Agents does not tell the model where to work; `backend.root` is the sandbox's work directory (`/work` on docker),
|
|
79
|
+
which is where the agent's files belong. Leaving the `with` block closes the session, and the sandbox and its files are
|
|
80
|
+
gone.
|
|
81
|
+
|
|
82
|
+
What the backend needs and does:
|
|
83
|
+
|
|
84
|
+
- **Python 3 in the sandbox.** Deep Agents' file tools are small `python3` scripts it runs through `execute`. `open`
|
|
85
|
+
refuses a daemon that does not state Python before any sandbox is made; on docker that is the `plimsoll/sandbox-python`
|
|
86
|
+
image (`SANDBOX_DOCKER_PROJECT_IMAGE`).
|
|
87
|
+
- **Searches that never answer "no matches" by mistake.** Deep Agents' `grep` sends GNU grep options with its errors
|
|
88
|
+
discarded. plimsoll's docker images are Alpine Linux, whose `grep` is BusyBox's and has neither option, so every such
|
|
89
|
+
search would come back empty. When the sandbox's `grep` is not GNU grep, the backend sends each search through Deep
|
|
90
|
+
Agents' own `python3` search instead, which reports its errors. It skips hidden files, as Python's glob does.
|
|
91
|
+
- **A refusal stops the run.** If plimsoll refuses a command (the daemon is at capacity, the session has ended, the tier
|
|
92
|
+
is too low), or a command may have run without an answer to show for it, the backend raises. It never hands the model a
|
|
93
|
+
refusal dressed as command output, because Deep Agents reads that output as data: its `ls` reads text it cannot parse
|
|
94
|
+
as an empty directory. A command that runs and fails is a normal result with its exit code.
|
|
95
|
+
- **A thread resumed on another worker keeps its sandbox.** Open the backend with a checkpoint store and a key, and
|
|
96
|
+
attach to it from the worker that resumes the thread:
|
|
97
|
+
|
|
98
|
+
```python
|
|
99
|
+
from plimsoll_client import MemoryCheckpointStore # for tests: use storage only your app can write
|
|
100
|
+
|
|
101
|
+
key = f"{user_id}/{thread_id}" # from identities your app verified, never from model or user text
|
|
102
|
+
backend = PlimsollSandbox.open(Client(url, token, daemon_name="prod"), checkpoint_store=store, checkpoint_key=key)
|
|
103
|
+
# On the worker that resumes the thread:
|
|
104
|
+
backend = PlimsollSandbox.attach(Client(url, token, daemon_name="prod"), key, store=store)
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
The second worker gets the same sandbox and its files, and the first is refused from then on. A store is an object
|
|
108
|
+
with `load` and an atomic `compare_and_set`; every call passes through it, so two workers never send at once, and a
|
|
109
|
+
worker that died mid-command leaves a record the next one takes over from (if that command ran with its answer lost,
|
|
110
|
+
the next one's first command may not repeat it). A missing key raises `LookupError`, never a new sandbox. The daemon
|
|
111
|
+
needs callers with tokens: open development mode refuses the takeover, and anyone holding the token and a session's run
|
|
112
|
+
records can take it over. The rules:
|
|
113
|
+
[carrying a session on from another worker (EXTERNAL · source repo ↗)](https://github.com/plimsollmark/plimsoll/blob/main/docs/sessions.md#carrying-a-session-on-from-another-worker).
|
|
114
|
+
When the session ends (the daemon's lifetime or idle limit), every later call raises; the backend never opens a fresh
|
|
115
|
+
sandbox in its place, since the agent would take it for the one holding its files.
|
|
116
|
+
- **Every command has a budget.** A command with no timeout gets the backend's default (120 s); `timeout=0` gets the
|
|
117
|
+
daemon's longest; a command past its budget answers exit 124 with what it printed. A process left in the background is
|
|
118
|
+
stopped when its command ends.
|
|
119
|
+
|
|
120
|
+
## Retries
|
|
121
|
+
|
|
122
|
+
LangGraph and LangChain retry nothing unless you ask: retries are off by default in both. You turn them on with a
|
|
123
|
+
`RetryPolicy` on a graph node (or on every node, with `set_node_defaults`), or with `ToolRetryMiddleware` on an agent.
|
|
124
|
+
Once on, both frameworks' default rules retry a plimsoll error, including one after which the code may already have run,
|
|
125
|
+
so a retry can run it a second time: a file appended to twice, a request sent twice. `retry_on` is the rule to give them
|
|
126
|
+
instead. It retries only a refusal plimsoll marked as having run nothing, and only when another try may pass: the daemon
|
|
127
|
+
was at capacity, or could not be reached before anything was sent. Every other error is left to stop the run.
|
|
128
|
+
|
|
129
|
+
```python
|
|
130
|
+
from langchain.agents.middleware import ToolRetryMiddleware
|
|
131
|
+
from langgraph.types import RetryPolicy
|
|
132
|
+
from langchain_plimsoll import retry_on
|
|
133
|
+
|
|
134
|
+
# A graph node that calls plimsoll
|
|
135
|
+
builder.add_node("run", node, retry_policy=RetryPolicy(retry_on=retry_on))
|
|
136
|
+
|
|
137
|
+
# A Deep Agents agent: its execute and file tools
|
|
138
|
+
agent = create_deep_agent(model=model, backend=backend, middleware=[ToolRetryMiddleware(retry_on=retry_on)])
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
- **Where it matters.** The Deep Agents backend raises on a refusal (above), and so do `Client` and `CodeExecutor`
|
|
142
|
+
called from a node of your own: that is where a retry rule meets plimsoll. `PlimsollCodeTool` never raises for a
|
|
143
|
+
refusal or a lost answer; it answers with them as its JSON (`ran` false or `"unknown"`), so no retry rule sees them.
|
|
144
|
+
- **Which refusals.** Every plimsoll error says whether anything ran: a refusal raised before any code was handed to the
|
|
145
|
+
sandbox carries a reason, and an error without one may have followed execution
|
|
146
|
+
([what comes back, and what it means (EXTERNAL · source repo ↗)](https://github.com/plimsollmark/plimsoll/blob/main/docs/run-results.md)).
|
|
147
|
+
`retry_on` says yes to the reasons `capacity` (the daemon was full or over a rate limit and turned the run away) and
|
|
148
|
+
`environment` (the daemon or its token check could not be reached before anything was sent, or a session's sandbox
|
|
149
|
+
could not be read back before the call). It says no to the others, since the same daemon answers them the same way:
|
|
150
|
+
`request`, `permission`, `protocol`, `unsupported` and `isolation`. One `environment` cause, an image outside your
|
|
151
|
+
software rule, fails the same way each time; a retry of it costs the policy's few attempts and runs nothing.
|
|
152
|
+
- **Only plimsoll's errors.** It says no to every exception that is not plimsoll's (every plimsoll error is a
|
|
153
|
+
`plimsoll_client.PlimsollError`). For a node that also calls a service whose errors you want retried, decide both in
|
|
154
|
+
one rule: `RetryPolicy(retry_on=lambda e: retry_on(e) if isinstance(e, PlimsollError) else your_rule(e))`. A second
|
|
155
|
+
`RetryPolicy` on the same node does not do this: LangGraph uses the first policy whose rule says yes, so a later policy
|
|
156
|
+
with LangGraph's default rule would still retry plimsoll's errors.
|
|
157
|
+
|
|
158
|
+
## What it does, and what it refuses to do
|
|
159
|
+
|
|
160
|
+
- **No fallback.** Both parts require the `kernel` isolation tier by default (gVisor, a user-space kernel, or a virtual
|
|
161
|
+
machine). Against a daemon that states less, they refuse before any code is sent. Lowering the floor is a choice you
|
|
162
|
+
make in code: `CodeExecutor(client, minimum_isolation="container")`, `PlimsollSandbox.open(client,
|
|
163
|
+
minimum_isolation="container")`.
|
|
164
|
+
- **A checked record of every run.** Each answer carries a run record, the daemon's statement of what was sent, what came
|
|
165
|
+
back and where it ran, and the client recomputes its digests before handing the result on.
|
|
166
|
+
- **One web API, if you grant one, for the tool.** `CodeExecutor(client, grant_profile="lights", api_description=...)`,
|
|
167
|
+
with a profile the operator configured on the daemon and the description `plimsoll-specgen` wrote for it, lets the
|
|
168
|
+
tool's code call that profile's routes, and nothing else, through plimsoll's broker, which adds the API's key outside
|
|
169
|
+
the sandbox. JavaScript works on every provider that gives a project run a grant; Python too on docker and openshell,
|
|
170
|
+
through `import plimsoll_host`. The tool reads the daemon's answer when it is built, offers only the languages that
|
|
171
|
+
can call the API there, and tells the model the routes; the model never names a profile. The code can do whatever an
|
|
172
|
+
allowed route permits and read whatever it returns
|
|
173
|
+
([capability grants (EXTERNAL · source repo ↗)](https://github.com/plimsollmark/plimsoll/blob/main/docs/capability-grants.md#from-an-agent-kits-code-tool)).
|
|
174
|
+
The Deep Agents backend's calls take no grant.
|
|
175
|
+
- **Tested against LangChain's own suites.** The tool passes LangChain's standard tool tests (`langchain-tests`). The
|
|
176
|
+
backend passes LangChain's standard sandbox tests on a real plimsoll session, except seven cases where
|
|
177
|
+
langchain-tests 1.1.9 and deepagents 0.7.38 disagree with each other (six about what `glob` returns, one about writing
|
|
178
|
+
over an existing file); they fail the same way for any backend built on Deep Agents' `BaseSandbox`.
|
|
179
|
+
|
|
180
|
+
## Tracing
|
|
181
|
+
|
|
182
|
+
If you turn on LangSmith tracing, LangChain sends each tool call's inputs and outputs, which here are the model's code
|
|
183
|
+
and what it printed, to LangSmith. That is LangChain's switch, not this package's; LangSmith's `hide_inputs` and
|
|
184
|
+
`hide_outputs` settings turn it off
|
|
185
|
+
([LangSmith tracing (EXTERNAL · official docs ↗)](https://docs.langchain.com/langsmith/mask-inputs-outputs)).
|
|
186
|
+
|
|
187
|
+
`PlimsollCodeTool` adds two things of its own, and neither carries the code or its output:
|
|
188
|
+
|
|
189
|
+
- **One ID in both logs.** Each call sends the LangChain run ID of the tool call (the ID LangSmith shows for that run) as
|
|
190
|
+
the run's `trace_id`, which the daemon writes on the run's audit line and does nothing else with. To find what the
|
|
191
|
+
daemon did for a traced tool call, search its log for the run's ID. The daemon accepts 1 to 64 characters of letters,
|
|
192
|
+
digits and `.`, `_`, `:` and `-`; LangChain's IDs are UUIDs, which fit. An ID you set yourself (`run_id` in the
|
|
193
|
+
config) that does not fit is not sent at all, never cut short, since a shortened ID would match nothing.
|
|
194
|
+
- **Labels on the tool call's run.** When the call is traced, the tool adds metadata to its run: `plimsoll_record_sha256`
|
|
195
|
+
(the run record's digest, which the client checked), `plimsoll_isolation` (the tier the code ran behind) and
|
|
196
|
+
`plimsoll_isolation_qualification` (the sentence a provider states beside its tier, when it states one),
|
|
197
|
+
`plimsoll_dispatched` (`yes`, `no` or `unknown`: whether the run reached the provider, or an error left that open),
|
|
198
|
+
`plimsoll_refused` (the reason, when it did not) and `plimsoll_outcome` (how the run ended: `completed`,
|
|
199
|
+
`setup_failed`, `timed_out`, `protocol_error` or `runner_failed`). Each value is checked against the values plimsoll
|
|
200
|
+
can state and left out if it does not match, so nothing the code printed can reach these fields. In LangSmith you can
|
|
201
|
+
then filter for runs that were refused, ran below a tier, or may have run without an answer. With tracing off the tool
|
|
202
|
+
adds nothing, and it imports no part of LangSmith that is not already loaded.
|
|
203
|
+
|
|
204
|
+
## What it is not
|
|
205
|
+
|
|
206
|
+
- **Not a hosted service.** You run `plimsolld` on your own machine or cluster, with a provider you pick: docker under
|
|
207
|
+
gVisor, an E2B or Docker Cloud microVM, a Kubernetes agent-sandbox pod, and others
|
|
208
|
+
([isolation tiers (EXTERNAL · source repo ↗)](https://github.com/plimsollmark/plimsoll/blob/main/docs/isolation-tiers.md)).
|
|
209
|
+
The Deep Agents backend needs a provider with sessions: docker, E2B or OpenShell.
|
|
210
|
+
- **Not attestation.** A reported tier is the daemon's configuration and provider evidence plus a startup check, not
|
|
211
|
+
hardware proof.
|
|
212
|
+
|
|
213
|
+
## Versions
|
|
214
|
+
|
|
215
|
+
This package's version moves with plimsoll's releases, and each version requires the `plimsoll-client` release of the same
|
|
216
|
+
number, which holds the code (`plimsoll_client.langchain` and `plimsoll_client.deepagents`). `Client`, `CodeExecutor`,
|
|
217
|
+
`PlimsollCodeTool` and `PlimsollSandbox` here are plimsoll-client's own classes, gathered so an agent imports from one
|
|
218
|
+
place. It is tested with, and installs with, exactly langchain-core 1.8.0, and its `deepagents` extra with exactly
|
|
219
|
+
deepagents 0.7.38: pip installs those versions beside it and refuses others, and each new release of either is tested
|
|
220
|
+
before its pin moves.
|
|
221
|
+
|
|
222
|
+
Licensed under the Apache License 2.0. Source:
|
|
223
|
+
[plimsoll on GitHub (EXTERNAL · source repo ↗)](https://github.com/plimsollmark/plimsoll/tree/main/clients/python/langchain-plimsoll).
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
# langchain-plimsoll
|
|
2
|
+
|
|
3
|
+
An agent that writes code has to run it somewhere, and "somewhere" is usually your machine or a hosted sandbox you
|
|
4
|
+
cannot inspect. This package runs a LangChain, LangGraph or Deep Agents agent's code in plimsoll, a sandbox service you
|
|
5
|
+
run yourself, and it has no fallback: if the sandbox is weaker than you asked for, nothing runs.
|
|
6
|
+
|
|
7
|
+
It has two parts:
|
|
8
|
+
|
|
9
|
+
- **`PlimsollCodeTool`**, a LangChain tool (`plimsoll_run_code`) that runs each call in a fresh sandbox. LangGraph's
|
|
10
|
+
`ToolNode`, `create_agent` and any graph of your own call it like any other LangChain tool.
|
|
11
|
+
- **`PlimsollSandbox`**, a Deep Agents sandbox backend over one plimsoll session: one sandbox kept for the agent's whole
|
|
12
|
+
run, so the files it writes and the shell's directory are there for its next command. Deep Agents gives the agent its
|
|
13
|
+
`execute` tool and its file tools (`ls`, `read_file`, `write_file`, `edit_file`, `glob`, `grep`) on top of it
|
|
14
|
+
([Deep Agents sandboxes (EXTERNAL · official docs ↗)](https://docs.langchain.com/oss/python/deepagents/sandboxes)).
|
|
15
|
+
|
|
16
|
+
## Install
|
|
17
|
+
|
|
18
|
+
```sh
|
|
19
|
+
pip install langchain-plimsoll # the tool: needs only langchain-core
|
|
20
|
+
pip install 'langchain-plimsoll[deepagents]' # and the Deep Agents backend
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
The tool needs only `langchain-core`. The example below builds its agent with `create_agent`, which is in `langchain`:
|
|
24
|
+
`pip install langchain` for it.
|
|
25
|
+
|
|
26
|
+
It needs a running `plimsolld`, the plimsoll daemon, reachable from the agent
|
|
27
|
+
([getting started (EXTERNAL · source repo ↗)](https://github.com/plimsollmark/plimsoll/blob/main/docs/getting-started.md)).
|
|
28
|
+
The tool's default language is Python, which on docker needs a project image with `python3` in it
|
|
29
|
+
(`SANDBOX_DOCKER_PROJECT_IMAGE=plimsoll/sandbox-python:latest`): on the default image every Python call comes back
|
|
30
|
+
refused. Python 3.11 or later, as langchain-core requires.
|
|
31
|
+
|
|
32
|
+
## Use the tool
|
|
33
|
+
|
|
34
|
+
```python
|
|
35
|
+
from langchain.agents import create_agent
|
|
36
|
+
from langchain_plimsoll import Client, CodeExecutor, PlimsollCodeTool
|
|
37
|
+
|
|
38
|
+
executor = CodeExecutor(Client("https://plimsoll.internal:8746", token=TOKEN))
|
|
39
|
+
agent = create_agent(model, tools=[PlimsollCodeTool(executor)])
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
The agent passes the tool code (Python or JavaScript) and optional input files, and gets back JSON saying whether the code
|
|
43
|
+
ran (yes, no with the reason, or unknown), the output, the exit code, whether anything was cut short or timed out, the
|
|
44
|
+
isolation tier the code ran behind, and the SHA-256 of the run's record.
|
|
45
|
+
|
|
46
|
+
## Use the Deep Agents backend
|
|
47
|
+
|
|
48
|
+
```python
|
|
49
|
+
from deepagents import create_deep_agent
|
|
50
|
+
from langchain_plimsoll import Client, PlimsollSandbox
|
|
51
|
+
|
|
52
|
+
with PlimsollSandbox.open(Client("https://plimsoll.internal:8746", token=TOKEN)) as backend:
|
|
53
|
+
agent = create_deep_agent(model=model, backend=backend, system_prompt=f"Work in {backend.root}.")
|
|
54
|
+
agent.invoke({"messages": [{"role": "user", "content": "Write and test a CSV parser."}]})
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
Deep Agents does not tell the model where to work; `backend.root` is the sandbox's work directory (`/work` on docker),
|
|
58
|
+
which is where the agent's files belong. Leaving the `with` block closes the session, and the sandbox and its files are
|
|
59
|
+
gone.
|
|
60
|
+
|
|
61
|
+
What the backend needs and does:
|
|
62
|
+
|
|
63
|
+
- **Python 3 in the sandbox.** Deep Agents' file tools are small `python3` scripts it runs through `execute`. `open`
|
|
64
|
+
refuses a daemon that does not state Python before any sandbox is made; on docker that is the `plimsoll/sandbox-python`
|
|
65
|
+
image (`SANDBOX_DOCKER_PROJECT_IMAGE`).
|
|
66
|
+
- **Searches that never answer "no matches" by mistake.** Deep Agents' `grep` sends GNU grep options with its errors
|
|
67
|
+
discarded. plimsoll's docker images are Alpine Linux, whose `grep` is BusyBox's and has neither option, so every such
|
|
68
|
+
search would come back empty. When the sandbox's `grep` is not GNU grep, the backend sends each search through Deep
|
|
69
|
+
Agents' own `python3` search instead, which reports its errors. It skips hidden files, as Python's glob does.
|
|
70
|
+
- **A refusal stops the run.** If plimsoll refuses a command (the daemon is at capacity, the session has ended, the tier
|
|
71
|
+
is too low), or a command may have run without an answer to show for it, the backend raises. It never hands the model a
|
|
72
|
+
refusal dressed as command output, because Deep Agents reads that output as data: its `ls` reads text it cannot parse
|
|
73
|
+
as an empty directory. A command that runs and fails is a normal result with its exit code.
|
|
74
|
+
- **A thread resumed on another worker keeps its sandbox.** Open the backend with a checkpoint store and a key, and
|
|
75
|
+
attach to it from the worker that resumes the thread:
|
|
76
|
+
|
|
77
|
+
```python
|
|
78
|
+
from plimsoll_client import MemoryCheckpointStore # for tests: use storage only your app can write
|
|
79
|
+
|
|
80
|
+
key = f"{user_id}/{thread_id}" # from identities your app verified, never from model or user text
|
|
81
|
+
backend = PlimsollSandbox.open(Client(url, token, daemon_name="prod"), checkpoint_store=store, checkpoint_key=key)
|
|
82
|
+
# On the worker that resumes the thread:
|
|
83
|
+
backend = PlimsollSandbox.attach(Client(url, token, daemon_name="prod"), key, store=store)
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
The second worker gets the same sandbox and its files, and the first is refused from then on. A store is an object
|
|
87
|
+
with `load` and an atomic `compare_and_set`; every call passes through it, so two workers never send at once, and a
|
|
88
|
+
worker that died mid-command leaves a record the next one takes over from (if that command ran with its answer lost,
|
|
89
|
+
the next one's first command may not repeat it). A missing key raises `LookupError`, never a new sandbox. The daemon
|
|
90
|
+
needs callers with tokens: open development mode refuses the takeover, and anyone holding the token and a session's run
|
|
91
|
+
records can take it over. The rules:
|
|
92
|
+
[carrying a session on from another worker (EXTERNAL · source repo ↗)](https://github.com/plimsollmark/plimsoll/blob/main/docs/sessions.md#carrying-a-session-on-from-another-worker).
|
|
93
|
+
When the session ends (the daemon's lifetime or idle limit), every later call raises; the backend never opens a fresh
|
|
94
|
+
sandbox in its place, since the agent would take it for the one holding its files.
|
|
95
|
+
- **Every command has a budget.** A command with no timeout gets the backend's default (120 s); `timeout=0` gets the
|
|
96
|
+
daemon's longest; a command past its budget answers exit 124 with what it printed. A process left in the background is
|
|
97
|
+
stopped when its command ends.
|
|
98
|
+
|
|
99
|
+
## Retries
|
|
100
|
+
|
|
101
|
+
LangGraph and LangChain retry nothing unless you ask: retries are off by default in both. You turn them on with a
|
|
102
|
+
`RetryPolicy` on a graph node (or on every node, with `set_node_defaults`), or with `ToolRetryMiddleware` on an agent.
|
|
103
|
+
Once on, both frameworks' default rules retry a plimsoll error, including one after which the code may already have run,
|
|
104
|
+
so a retry can run it a second time: a file appended to twice, a request sent twice. `retry_on` is the rule to give them
|
|
105
|
+
instead. It retries only a refusal plimsoll marked as having run nothing, and only when another try may pass: the daemon
|
|
106
|
+
was at capacity, or could not be reached before anything was sent. Every other error is left to stop the run.
|
|
107
|
+
|
|
108
|
+
```python
|
|
109
|
+
from langchain.agents.middleware import ToolRetryMiddleware
|
|
110
|
+
from langgraph.types import RetryPolicy
|
|
111
|
+
from langchain_plimsoll import retry_on
|
|
112
|
+
|
|
113
|
+
# A graph node that calls plimsoll
|
|
114
|
+
builder.add_node("run", node, retry_policy=RetryPolicy(retry_on=retry_on))
|
|
115
|
+
|
|
116
|
+
# A Deep Agents agent: its execute and file tools
|
|
117
|
+
agent = create_deep_agent(model=model, backend=backend, middleware=[ToolRetryMiddleware(retry_on=retry_on)])
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
- **Where it matters.** The Deep Agents backend raises on a refusal (above), and so do `Client` and `CodeExecutor`
|
|
121
|
+
called from a node of your own: that is where a retry rule meets plimsoll. `PlimsollCodeTool` never raises for a
|
|
122
|
+
refusal or a lost answer; it answers with them as its JSON (`ran` false or `"unknown"`), so no retry rule sees them.
|
|
123
|
+
- **Which refusals.** Every plimsoll error says whether anything ran: a refusal raised before any code was handed to the
|
|
124
|
+
sandbox carries a reason, and an error without one may have followed execution
|
|
125
|
+
([what comes back, and what it means (EXTERNAL · source repo ↗)](https://github.com/plimsollmark/plimsoll/blob/main/docs/run-results.md)).
|
|
126
|
+
`retry_on` says yes to the reasons `capacity` (the daemon was full or over a rate limit and turned the run away) and
|
|
127
|
+
`environment` (the daemon or its token check could not be reached before anything was sent, or a session's sandbox
|
|
128
|
+
could not be read back before the call). It says no to the others, since the same daemon answers them the same way:
|
|
129
|
+
`request`, `permission`, `protocol`, `unsupported` and `isolation`. One `environment` cause, an image outside your
|
|
130
|
+
software rule, fails the same way each time; a retry of it costs the policy's few attempts and runs nothing.
|
|
131
|
+
- **Only plimsoll's errors.** It says no to every exception that is not plimsoll's (every plimsoll error is a
|
|
132
|
+
`plimsoll_client.PlimsollError`). For a node that also calls a service whose errors you want retried, decide both in
|
|
133
|
+
one rule: `RetryPolicy(retry_on=lambda e: retry_on(e) if isinstance(e, PlimsollError) else your_rule(e))`. A second
|
|
134
|
+
`RetryPolicy` on the same node does not do this: LangGraph uses the first policy whose rule says yes, so a later policy
|
|
135
|
+
with LangGraph's default rule would still retry plimsoll's errors.
|
|
136
|
+
|
|
137
|
+
## What it does, and what it refuses to do
|
|
138
|
+
|
|
139
|
+
- **No fallback.** Both parts require the `kernel` isolation tier by default (gVisor, a user-space kernel, or a virtual
|
|
140
|
+
machine). Against a daemon that states less, they refuse before any code is sent. Lowering the floor is a choice you
|
|
141
|
+
make in code: `CodeExecutor(client, minimum_isolation="container")`, `PlimsollSandbox.open(client,
|
|
142
|
+
minimum_isolation="container")`.
|
|
143
|
+
- **A checked record of every run.** Each answer carries a run record, the daemon's statement of what was sent, what came
|
|
144
|
+
back and where it ran, and the client recomputes its digests before handing the result on.
|
|
145
|
+
- **One web API, if you grant one, for the tool.** `CodeExecutor(client, grant_profile="lights", api_description=...)`,
|
|
146
|
+
with a profile the operator configured on the daemon and the description `plimsoll-specgen` wrote for it, lets the
|
|
147
|
+
tool's code call that profile's routes, and nothing else, through plimsoll's broker, which adds the API's key outside
|
|
148
|
+
the sandbox. JavaScript works on every provider that gives a project run a grant; Python too on docker and openshell,
|
|
149
|
+
through `import plimsoll_host`. The tool reads the daemon's answer when it is built, offers only the languages that
|
|
150
|
+
can call the API there, and tells the model the routes; the model never names a profile. The code can do whatever an
|
|
151
|
+
allowed route permits and read whatever it returns
|
|
152
|
+
([capability grants (EXTERNAL · source repo ↗)](https://github.com/plimsollmark/plimsoll/blob/main/docs/capability-grants.md#from-an-agent-kits-code-tool)).
|
|
153
|
+
The Deep Agents backend's calls take no grant.
|
|
154
|
+
- **Tested against LangChain's own suites.** The tool passes LangChain's standard tool tests (`langchain-tests`). The
|
|
155
|
+
backend passes LangChain's standard sandbox tests on a real plimsoll session, except seven cases where
|
|
156
|
+
langchain-tests 1.1.9 and deepagents 0.7.38 disagree with each other (six about what `glob` returns, one about writing
|
|
157
|
+
over an existing file); they fail the same way for any backend built on Deep Agents' `BaseSandbox`.
|
|
158
|
+
|
|
159
|
+
## Tracing
|
|
160
|
+
|
|
161
|
+
If you turn on LangSmith tracing, LangChain sends each tool call's inputs and outputs, which here are the model's code
|
|
162
|
+
and what it printed, to LangSmith. That is LangChain's switch, not this package's; LangSmith's `hide_inputs` and
|
|
163
|
+
`hide_outputs` settings turn it off
|
|
164
|
+
([LangSmith tracing (EXTERNAL · official docs ↗)](https://docs.langchain.com/langsmith/mask-inputs-outputs)).
|
|
165
|
+
|
|
166
|
+
`PlimsollCodeTool` adds two things of its own, and neither carries the code or its output:
|
|
167
|
+
|
|
168
|
+
- **One ID in both logs.** Each call sends the LangChain run ID of the tool call (the ID LangSmith shows for that run) as
|
|
169
|
+
the run's `trace_id`, which the daemon writes on the run's audit line and does nothing else with. To find what the
|
|
170
|
+
daemon did for a traced tool call, search its log for the run's ID. The daemon accepts 1 to 64 characters of letters,
|
|
171
|
+
digits and `.`, `_`, `:` and `-`; LangChain's IDs are UUIDs, which fit. An ID you set yourself (`run_id` in the
|
|
172
|
+
config) that does not fit is not sent at all, never cut short, since a shortened ID would match nothing.
|
|
173
|
+
- **Labels on the tool call's run.** When the call is traced, the tool adds metadata to its run: `plimsoll_record_sha256`
|
|
174
|
+
(the run record's digest, which the client checked), `plimsoll_isolation` (the tier the code ran behind) and
|
|
175
|
+
`plimsoll_isolation_qualification` (the sentence a provider states beside its tier, when it states one),
|
|
176
|
+
`plimsoll_dispatched` (`yes`, `no` or `unknown`: whether the run reached the provider, or an error left that open),
|
|
177
|
+
`plimsoll_refused` (the reason, when it did not) and `plimsoll_outcome` (how the run ended: `completed`,
|
|
178
|
+
`setup_failed`, `timed_out`, `protocol_error` or `runner_failed`). Each value is checked against the values plimsoll
|
|
179
|
+
can state and left out if it does not match, so nothing the code printed can reach these fields. In LangSmith you can
|
|
180
|
+
then filter for runs that were refused, ran below a tier, or may have run without an answer. With tracing off the tool
|
|
181
|
+
adds nothing, and it imports no part of LangSmith that is not already loaded.
|
|
182
|
+
|
|
183
|
+
## What it is not
|
|
184
|
+
|
|
185
|
+
- **Not a hosted service.** You run `plimsolld` on your own machine or cluster, with a provider you pick: docker under
|
|
186
|
+
gVisor, an E2B or Docker Cloud microVM, a Kubernetes agent-sandbox pod, and others
|
|
187
|
+
([isolation tiers (EXTERNAL · source repo ↗)](https://github.com/plimsollmark/plimsoll/blob/main/docs/isolation-tiers.md)).
|
|
188
|
+
The Deep Agents backend needs a provider with sessions: docker, E2B or OpenShell.
|
|
189
|
+
- **Not attestation.** A reported tier is the daemon's configuration and provider evidence plus a startup check, not
|
|
190
|
+
hardware proof.
|
|
191
|
+
|
|
192
|
+
## Versions
|
|
193
|
+
|
|
194
|
+
This package's version moves with plimsoll's releases, and each version requires the `plimsoll-client` release of the same
|
|
195
|
+
number, which holds the code (`plimsoll_client.langchain` and `plimsoll_client.deepagents`). `Client`, `CodeExecutor`,
|
|
196
|
+
`PlimsollCodeTool` and `PlimsollSandbox` here are plimsoll-client's own classes, gathered so an agent imports from one
|
|
197
|
+
place. It is tested with, and installs with, exactly langchain-core 1.8.0, and its `deepagents` extra with exactly
|
|
198
|
+
deepagents 0.7.38: pip installs those versions beside it and refuses others, and each new release of either is tested
|
|
199
|
+
before its pin moves.
|
|
200
|
+
|
|
201
|
+
Licensed under the Apache License 2.0. Source:
|
|
202
|
+
[plimsoll on GitHub (EXTERNAL · source repo ↗)](https://github.com/plimsollmark/plimsoll/tree/main/clients/python/langchain-plimsoll).
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=77"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
# A LangChain integration package, named as LangChain's integration guide asks (an
|
|
6
|
+
# independent langchain-<provider> package on PyPI; LangChain accepts no new integrations
|
|
7
|
+
# into its own repositories). The tool is plimsoll_client.langchain.PlimsollCodeTool and the
|
|
8
|
+
# Deep Agents backend plimsoll_client.deepagents.PlimsollSandbox; this package depends on
|
|
9
|
+
# that exact plimsoll-client release, and its version moves with plimsoll's releases
|
|
10
|
+
# (TestClientVersionsAgree in clients/typescript checks both). langchain-core and deepagents
|
|
11
|
+
# need Python 3.11 or later.
|
|
12
|
+
[project]
|
|
13
|
+
name = "langchain-plimsoll"
|
|
14
|
+
version = "0.28.0"
|
|
15
|
+
description = "A LangChain tool and a Deep Agents sandbox backend that run agent-written code in plimsoll, a self-hosted sandbox that refuses to run below the isolation you require"
|
|
16
|
+
readme = "README.md"
|
|
17
|
+
license = "Apache-2.0"
|
|
18
|
+
license-files = ["LICENSE"]
|
|
19
|
+
requires-python = ">=3.11"
|
|
20
|
+
dependencies = [
|
|
21
|
+
"langchain-core==1.8.0",
|
|
22
|
+
"plimsoll-client==0.28.0",
|
|
23
|
+
]
|
|
24
|
+
keywords = ["langchain", "langgraph", "deepagents", "sandbox", "code execution", "agents", "gvisor"]
|
|
25
|
+
classifiers = [
|
|
26
|
+
"Programming Language :: Python :: 3",
|
|
27
|
+
"Programming Language :: Python :: 3 :: Only",
|
|
28
|
+
"Typing :: Typed",
|
|
29
|
+
]
|
|
30
|
+
|
|
31
|
+
[project.optional-dependencies]
|
|
32
|
+
deepagents = ["deepagents==0.7.38"]
|
|
33
|
+
|
|
34
|
+
[project.urls]
|
|
35
|
+
Homepage = "https://github.com/plimsollmark/plimsoll/tree/main/clients/python/langchain-plimsoll"
|
|
36
|
+
Source = "https://github.com/plimsollmark/plimsoll/tree/main/clients/python/langchain-plimsoll"
|
|
37
|
+
Issues = "https://github.com/plimsollmark/plimsoll/issues"
|
|
38
|
+
|
|
39
|
+
[tool.setuptools.packages.find]
|
|
40
|
+
where = ["src"]
|
|
41
|
+
|
|
42
|
+
[tool.setuptools.package-data]
|
|
43
|
+
langchain_plimsoll = ["py.typed"]
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"""Run a LangChain, LangGraph or Deep Agents agent's code in plimsoll.
|
|
2
|
+
|
|
3
|
+
from langchain_plimsoll import Client, CodeExecutor, PlimsollCodeTool
|
|
4
|
+
|
|
5
|
+
executor = CodeExecutor(Client("https://plimsoll.internal:8746", token=TOKEN))
|
|
6
|
+
tools = [PlimsollCodeTool(executor)] # create_agent, ToolNode, any LangGraph graph
|
|
7
|
+
|
|
8
|
+
from langchain_plimsoll import PlimsollSandbox # pip install 'langchain-plimsoll[deepagents]'
|
|
9
|
+
|
|
10
|
+
with PlimsollSandbox.open(Client("https://plimsoll.internal:8746", token=TOKEN)) as backend:
|
|
11
|
+
agent = create_deep_agent(model=..., backend=backend, system_prompt=f"Work in {backend.root}.")
|
|
12
|
+
|
|
13
|
+
from langchain_plimsoll import retry_on # LangGraph's RetryPolicy, LangChain's ToolRetryMiddleware
|
|
14
|
+
|
|
15
|
+
builder.add_node("run", node, retry_policy=RetryPolicy(retry_on=retry_on))
|
|
16
|
+
|
|
17
|
+
The names are plimsoll-client's own, gathered here so an agent imports from one place:
|
|
18
|
+
PlimsollCodeTool is plimsoll_client.langchain.PlimsollCodeTool (a fresh sandbox per call),
|
|
19
|
+
PlimsollSandbox is plimsoll_client.deepagents.PlimsollSandbox (one plimsoll session as a Deep
|
|
20
|
+
Agents backend), Client is plimsoll_client.Client, CodeExecutor is
|
|
21
|
+
plimsoll_client.execution.CodeExecutor and retry_on is plimsoll_client.retry_on (retry only a
|
|
22
|
+
refusal that ran nothing and may pass on another try). Both require the kernel isolation tier
|
|
23
|
+
by default and refuse, before any code is sent, a daemon that states less.
|
|
24
|
+
"""
|
|
25
|
+
|
|
26
|
+
from typing import Any
|
|
27
|
+
|
|
28
|
+
from plimsoll_client import Client, retry_on
|
|
29
|
+
from plimsoll_client.execution import CodeExecutor
|
|
30
|
+
from plimsoll_client.langchain import PlimsollCodeTool
|
|
31
|
+
|
|
32
|
+
__all__ = ["Client", "CodeExecutor", "PlimsollCodeTool", "PlimsollSandbox", "retry_on"]
|
|
33
|
+
__version__ = "0.28.0"
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def __getattr__(name: str) -> Any:
|
|
37
|
+
# The backend needs deepagents, an extra: imported on first use, so the tool alone
|
|
38
|
+
# needs only langchain-core.
|
|
39
|
+
if name == "PlimsollSandbox":
|
|
40
|
+
try:
|
|
41
|
+
from plimsoll_client.deepagents import PlimsollSandbox
|
|
42
|
+
except ImportError as e:
|
|
43
|
+
raise ImportError("langchain_plimsoll.PlimsollSandbox needs Deep Agents: pip install 'langchain-plimsoll[deepagents]'") from e
|
|
44
|
+
return PlimsollSandbox
|
|
45
|
+
raise AttributeError(f"module 'langchain_plimsoll' has no attribute {name!r}")
|
|
File without changes
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: langchain-plimsoll
|
|
3
|
+
Version: 0.28.0
|
|
4
|
+
Summary: A LangChain tool and a Deep Agents sandbox backend that run agent-written code in plimsoll, a self-hosted sandbox that refuses to run below the isolation you require
|
|
5
|
+
License-Expression: Apache-2.0
|
|
6
|
+
Project-URL: Homepage, https://github.com/plimsollmark/plimsoll/tree/main/clients/python/langchain-plimsoll
|
|
7
|
+
Project-URL: Source, https://github.com/plimsollmark/plimsoll/tree/main/clients/python/langchain-plimsoll
|
|
8
|
+
Project-URL: Issues, https://github.com/plimsollmark/plimsoll/issues
|
|
9
|
+
Keywords: langchain,langgraph,deepagents,sandbox,code execution,agents,gvisor
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
12
|
+
Classifier: Typing :: Typed
|
|
13
|
+
Requires-Python: >=3.11
|
|
14
|
+
Description-Content-Type: text/markdown
|
|
15
|
+
License-File: LICENSE
|
|
16
|
+
Requires-Dist: langchain-core==1.8.0
|
|
17
|
+
Requires-Dist: plimsoll-client==0.28.0
|
|
18
|
+
Provides-Extra: deepagents
|
|
19
|
+
Requires-Dist: deepagents==0.7.38; extra == "deepagents"
|
|
20
|
+
Dynamic: license-file
|
|
21
|
+
|
|
22
|
+
# langchain-plimsoll
|
|
23
|
+
|
|
24
|
+
An agent that writes code has to run it somewhere, and "somewhere" is usually your machine or a hosted sandbox you
|
|
25
|
+
cannot inspect. This package runs a LangChain, LangGraph or Deep Agents agent's code in plimsoll, a sandbox service you
|
|
26
|
+
run yourself, and it has no fallback: if the sandbox is weaker than you asked for, nothing runs.
|
|
27
|
+
|
|
28
|
+
It has two parts:
|
|
29
|
+
|
|
30
|
+
- **`PlimsollCodeTool`**, a LangChain tool (`plimsoll_run_code`) that runs each call in a fresh sandbox. LangGraph's
|
|
31
|
+
`ToolNode`, `create_agent` and any graph of your own call it like any other LangChain tool.
|
|
32
|
+
- **`PlimsollSandbox`**, a Deep Agents sandbox backend over one plimsoll session: one sandbox kept for the agent's whole
|
|
33
|
+
run, so the files it writes and the shell's directory are there for its next command. Deep Agents gives the agent its
|
|
34
|
+
`execute` tool and its file tools (`ls`, `read_file`, `write_file`, `edit_file`, `glob`, `grep`) on top of it
|
|
35
|
+
([Deep Agents sandboxes (EXTERNAL · official docs ↗)](https://docs.langchain.com/oss/python/deepagents/sandboxes)).
|
|
36
|
+
|
|
37
|
+
## Install
|
|
38
|
+
|
|
39
|
+
```sh
|
|
40
|
+
pip install langchain-plimsoll # the tool: needs only langchain-core
|
|
41
|
+
pip install 'langchain-plimsoll[deepagents]' # and the Deep Agents backend
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
The tool needs only `langchain-core`. The example below builds its agent with `create_agent`, which is in `langchain`:
|
|
45
|
+
`pip install langchain` for it.
|
|
46
|
+
|
|
47
|
+
It needs a running `plimsolld`, the plimsoll daemon, reachable from the agent
|
|
48
|
+
([getting started (EXTERNAL · source repo ↗)](https://github.com/plimsollmark/plimsoll/blob/main/docs/getting-started.md)).
|
|
49
|
+
The tool's default language is Python, which on docker needs a project image with `python3` in it
|
|
50
|
+
(`SANDBOX_DOCKER_PROJECT_IMAGE=plimsoll/sandbox-python:latest`): on the default image every Python call comes back
|
|
51
|
+
refused. Python 3.11 or later, as langchain-core requires.
|
|
52
|
+
|
|
53
|
+
## Use the tool
|
|
54
|
+
|
|
55
|
+
```python
|
|
56
|
+
from langchain.agents import create_agent
|
|
57
|
+
from langchain_plimsoll import Client, CodeExecutor, PlimsollCodeTool
|
|
58
|
+
|
|
59
|
+
executor = CodeExecutor(Client("https://plimsoll.internal:8746", token=TOKEN))
|
|
60
|
+
agent = create_agent(model, tools=[PlimsollCodeTool(executor)])
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
The agent passes the tool code (Python or JavaScript) and optional input files, and gets back JSON saying whether the code
|
|
64
|
+
ran (yes, no with the reason, or unknown), the output, the exit code, whether anything was cut short or timed out, the
|
|
65
|
+
isolation tier the code ran behind, and the SHA-256 of the run's record.
|
|
66
|
+
|
|
67
|
+
## Use the Deep Agents backend
|
|
68
|
+
|
|
69
|
+
```python
|
|
70
|
+
from deepagents import create_deep_agent
|
|
71
|
+
from langchain_plimsoll import Client, PlimsollSandbox
|
|
72
|
+
|
|
73
|
+
with PlimsollSandbox.open(Client("https://plimsoll.internal:8746", token=TOKEN)) as backend:
|
|
74
|
+
agent = create_deep_agent(model=model, backend=backend, system_prompt=f"Work in {backend.root}.")
|
|
75
|
+
agent.invoke({"messages": [{"role": "user", "content": "Write and test a CSV parser."}]})
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
Deep Agents does not tell the model where to work; `backend.root` is the sandbox's work directory (`/work` on docker),
|
|
79
|
+
which is where the agent's files belong. Leaving the `with` block closes the session, and the sandbox and its files are
|
|
80
|
+
gone.
|
|
81
|
+
|
|
82
|
+
What the backend needs and does:
|
|
83
|
+
|
|
84
|
+
- **Python 3 in the sandbox.** Deep Agents' file tools are small `python3` scripts it runs through `execute`. `open`
|
|
85
|
+
refuses a daemon that does not state Python before any sandbox is made; on docker that is the `plimsoll/sandbox-python`
|
|
86
|
+
image (`SANDBOX_DOCKER_PROJECT_IMAGE`).
|
|
87
|
+
- **Searches that never answer "no matches" by mistake.** Deep Agents' `grep` sends GNU grep options with its errors
|
|
88
|
+
discarded. plimsoll's docker images are Alpine Linux, whose `grep` is BusyBox's and has neither option, so every such
|
|
89
|
+
search would come back empty. When the sandbox's `grep` is not GNU grep, the backend sends each search through Deep
|
|
90
|
+
Agents' own `python3` search instead, which reports its errors. It skips hidden files, as Python's glob does.
|
|
91
|
+
- **A refusal stops the run.** If plimsoll refuses a command (the daemon is at capacity, the session has ended, the tier
|
|
92
|
+
is too low), or a command may have run without an answer to show for it, the backend raises. It never hands the model a
|
|
93
|
+
refusal dressed as command output, because Deep Agents reads that output as data: its `ls` reads text it cannot parse
|
|
94
|
+
as an empty directory. A command that runs and fails is a normal result with its exit code.
|
|
95
|
+
- **A thread resumed on another worker keeps its sandbox.** Open the backend with a checkpoint store and a key, and
|
|
96
|
+
attach to it from the worker that resumes the thread:
|
|
97
|
+
|
|
98
|
+
```python
|
|
99
|
+
from plimsoll_client import MemoryCheckpointStore # for tests: use storage only your app can write
|
|
100
|
+
|
|
101
|
+
key = f"{user_id}/{thread_id}" # from identities your app verified, never from model or user text
|
|
102
|
+
backend = PlimsollSandbox.open(Client(url, token, daemon_name="prod"), checkpoint_store=store, checkpoint_key=key)
|
|
103
|
+
# On the worker that resumes the thread:
|
|
104
|
+
backend = PlimsollSandbox.attach(Client(url, token, daemon_name="prod"), key, store=store)
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
The second worker gets the same sandbox and its files, and the first is refused from then on. A store is an object
|
|
108
|
+
with `load` and an atomic `compare_and_set`; every call passes through it, so two workers never send at once, and a
|
|
109
|
+
worker that died mid-command leaves a record the next one takes over from (if that command ran with its answer lost,
|
|
110
|
+
the next one's first command may not repeat it). A missing key raises `LookupError`, never a new sandbox. The daemon
|
|
111
|
+
needs callers with tokens: open development mode refuses the takeover, and anyone holding the token and a session's run
|
|
112
|
+
records can take it over. The rules:
|
|
113
|
+
[carrying a session on from another worker (EXTERNAL · source repo ↗)](https://github.com/plimsollmark/plimsoll/blob/main/docs/sessions.md#carrying-a-session-on-from-another-worker).
|
|
114
|
+
When the session ends (the daemon's lifetime or idle limit), every later call raises; the backend never opens a fresh
|
|
115
|
+
sandbox in its place, since the agent would take it for the one holding its files.
|
|
116
|
+
- **Every command has a budget.** A command with no timeout gets the backend's default (120 s); `timeout=0` gets the
|
|
117
|
+
daemon's longest; a command past its budget answers exit 124 with what it printed. A process left in the background is
|
|
118
|
+
stopped when its command ends.
|
|
119
|
+
|
|
120
|
+
## Retries
|
|
121
|
+
|
|
122
|
+
LangGraph and LangChain retry nothing unless you ask: retries are off by default in both. You turn them on with a
|
|
123
|
+
`RetryPolicy` on a graph node (or on every node, with `set_node_defaults`), or with `ToolRetryMiddleware` on an agent.
|
|
124
|
+
Once on, both frameworks' default rules retry a plimsoll error, including one after which the code may already have run,
|
|
125
|
+
so a retry can run it a second time: a file appended to twice, a request sent twice. `retry_on` is the rule to give them
|
|
126
|
+
instead. It retries only a refusal plimsoll marked as having run nothing, and only when another try may pass: the daemon
|
|
127
|
+
was at capacity, or could not be reached before anything was sent. Every other error is left to stop the run.
|
|
128
|
+
|
|
129
|
+
```python
|
|
130
|
+
from langchain.agents.middleware import ToolRetryMiddleware
|
|
131
|
+
from langgraph.types import RetryPolicy
|
|
132
|
+
from langchain_plimsoll import retry_on
|
|
133
|
+
|
|
134
|
+
# A graph node that calls plimsoll
|
|
135
|
+
builder.add_node("run", node, retry_policy=RetryPolicy(retry_on=retry_on))
|
|
136
|
+
|
|
137
|
+
# A Deep Agents agent: its execute and file tools
|
|
138
|
+
agent = create_deep_agent(model=model, backend=backend, middleware=[ToolRetryMiddleware(retry_on=retry_on)])
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
- **Where it matters.** The Deep Agents backend raises on a refusal (above), and so do `Client` and `CodeExecutor`
|
|
142
|
+
called from a node of your own: that is where a retry rule meets plimsoll. `PlimsollCodeTool` never raises for a
|
|
143
|
+
refusal or a lost answer; it answers with them as its JSON (`ran` false or `"unknown"`), so no retry rule sees them.
|
|
144
|
+
- **Which refusals.** Every plimsoll error says whether anything ran: a refusal raised before any code was handed to the
|
|
145
|
+
sandbox carries a reason, and an error without one may have followed execution
|
|
146
|
+
([what comes back, and what it means (EXTERNAL · source repo ↗)](https://github.com/plimsollmark/plimsoll/blob/main/docs/run-results.md)).
|
|
147
|
+
`retry_on` says yes to the reasons `capacity` (the daemon was full or over a rate limit and turned the run away) and
|
|
148
|
+
`environment` (the daemon or its token check could not be reached before anything was sent, or a session's sandbox
|
|
149
|
+
could not be read back before the call). It says no to the others, since the same daemon answers them the same way:
|
|
150
|
+
`request`, `permission`, `protocol`, `unsupported` and `isolation`. One `environment` cause, an image outside your
|
|
151
|
+
software rule, fails the same way each time; a retry of it costs the policy's few attempts and runs nothing.
|
|
152
|
+
- **Only plimsoll's errors.** It says no to every exception that is not plimsoll's (every plimsoll error is a
|
|
153
|
+
`plimsoll_client.PlimsollError`). For a node that also calls a service whose errors you want retried, decide both in
|
|
154
|
+
one rule: `RetryPolicy(retry_on=lambda e: retry_on(e) if isinstance(e, PlimsollError) else your_rule(e))`. A second
|
|
155
|
+
`RetryPolicy` on the same node does not do this: LangGraph uses the first policy whose rule says yes, so a later policy
|
|
156
|
+
with LangGraph's default rule would still retry plimsoll's errors.
|
|
157
|
+
|
|
158
|
+
## What it does, and what it refuses to do
|
|
159
|
+
|
|
160
|
+
- **No fallback.** Both parts require the `kernel` isolation tier by default (gVisor, a user-space kernel, or a virtual
|
|
161
|
+
machine). Against a daemon that states less, they refuse before any code is sent. Lowering the floor is a choice you
|
|
162
|
+
make in code: `CodeExecutor(client, minimum_isolation="container")`, `PlimsollSandbox.open(client,
|
|
163
|
+
minimum_isolation="container")`.
|
|
164
|
+
- **A checked record of every run.** Each answer carries a run record, the daemon's statement of what was sent, what came
|
|
165
|
+
back and where it ran, and the client recomputes its digests before handing the result on.
|
|
166
|
+
- **One web API, if you grant one, for the tool.** `CodeExecutor(client, grant_profile="lights", api_description=...)`,
|
|
167
|
+
with a profile the operator configured on the daemon and the description `plimsoll-specgen` wrote for it, lets the
|
|
168
|
+
tool's code call that profile's routes, and nothing else, through plimsoll's broker, which adds the API's key outside
|
|
169
|
+
the sandbox. JavaScript works on every provider that gives a project run a grant; Python too on docker and openshell,
|
|
170
|
+
through `import plimsoll_host`. The tool reads the daemon's answer when it is built, offers only the languages that
|
|
171
|
+
can call the API there, and tells the model the routes; the model never names a profile. The code can do whatever an
|
|
172
|
+
allowed route permits and read whatever it returns
|
|
173
|
+
([capability grants (EXTERNAL · source repo ↗)](https://github.com/plimsollmark/plimsoll/blob/main/docs/capability-grants.md#from-an-agent-kits-code-tool)).
|
|
174
|
+
The Deep Agents backend's calls take no grant.
|
|
175
|
+
- **Tested against LangChain's own suites.** The tool passes LangChain's standard tool tests (`langchain-tests`). The
|
|
176
|
+
backend passes LangChain's standard sandbox tests on a real plimsoll session, except seven cases where
|
|
177
|
+
langchain-tests 1.1.9 and deepagents 0.7.38 disagree with each other (six about what `glob` returns, one about writing
|
|
178
|
+
over an existing file); they fail the same way for any backend built on Deep Agents' `BaseSandbox`.
|
|
179
|
+
|
|
180
|
+
## Tracing
|
|
181
|
+
|
|
182
|
+
If you turn on LangSmith tracing, LangChain sends each tool call's inputs and outputs, which here are the model's code
|
|
183
|
+
and what it printed, to LangSmith. That is LangChain's switch, not this package's; LangSmith's `hide_inputs` and
|
|
184
|
+
`hide_outputs` settings turn it off
|
|
185
|
+
([LangSmith tracing (EXTERNAL · official docs ↗)](https://docs.langchain.com/langsmith/mask-inputs-outputs)).
|
|
186
|
+
|
|
187
|
+
`PlimsollCodeTool` adds two things of its own, and neither carries the code or its output:
|
|
188
|
+
|
|
189
|
+
- **One ID in both logs.** Each call sends the LangChain run ID of the tool call (the ID LangSmith shows for that run) as
|
|
190
|
+
the run's `trace_id`, which the daemon writes on the run's audit line and does nothing else with. To find what the
|
|
191
|
+
daemon did for a traced tool call, search its log for the run's ID. The daemon accepts 1 to 64 characters of letters,
|
|
192
|
+
digits and `.`, `_`, `:` and `-`; LangChain's IDs are UUIDs, which fit. An ID you set yourself (`run_id` in the
|
|
193
|
+
config) that does not fit is not sent at all, never cut short, since a shortened ID would match nothing.
|
|
194
|
+
- **Labels on the tool call's run.** When the call is traced, the tool adds metadata to its run: `plimsoll_record_sha256`
|
|
195
|
+
(the run record's digest, which the client checked), `plimsoll_isolation` (the tier the code ran behind) and
|
|
196
|
+
`plimsoll_isolation_qualification` (the sentence a provider states beside its tier, when it states one),
|
|
197
|
+
`plimsoll_dispatched` (`yes`, `no` or `unknown`: whether the run reached the provider, or an error left that open),
|
|
198
|
+
`plimsoll_refused` (the reason, when it did not) and `plimsoll_outcome` (how the run ended: `completed`,
|
|
199
|
+
`setup_failed`, `timed_out`, `protocol_error` or `runner_failed`). Each value is checked against the values plimsoll
|
|
200
|
+
can state and left out if it does not match, so nothing the code printed can reach these fields. In LangSmith you can
|
|
201
|
+
then filter for runs that were refused, ran below a tier, or may have run without an answer. With tracing off the tool
|
|
202
|
+
adds nothing, and it imports no part of LangSmith that is not already loaded.
|
|
203
|
+
|
|
204
|
+
## What it is not
|
|
205
|
+
|
|
206
|
+
- **Not a hosted service.** You run `plimsolld` on your own machine or cluster, with a provider you pick: docker under
|
|
207
|
+
gVisor, an E2B or Docker Cloud microVM, a Kubernetes agent-sandbox pod, and others
|
|
208
|
+
([isolation tiers (EXTERNAL · source repo ↗)](https://github.com/plimsollmark/plimsoll/blob/main/docs/isolation-tiers.md)).
|
|
209
|
+
The Deep Agents backend needs a provider with sessions: docker, E2B or OpenShell.
|
|
210
|
+
- **Not attestation.** A reported tier is the daemon's configuration and provider evidence plus a startup check, not
|
|
211
|
+
hardware proof.
|
|
212
|
+
|
|
213
|
+
## Versions
|
|
214
|
+
|
|
215
|
+
This package's version moves with plimsoll's releases, and each version requires the `plimsoll-client` release of the same
|
|
216
|
+
number, which holds the code (`plimsoll_client.langchain` and `plimsoll_client.deepagents`). `Client`, `CodeExecutor`,
|
|
217
|
+
`PlimsollCodeTool` and `PlimsollSandbox` here are plimsoll-client's own classes, gathered so an agent imports from one
|
|
218
|
+
place. It is tested with, and installs with, exactly langchain-core 1.8.0, and its `deepagents` extra with exactly
|
|
219
|
+
deepagents 0.7.38: pip installs those versions beside it and refuses others, and each new release of either is tested
|
|
220
|
+
before its pin moves.
|
|
221
|
+
|
|
222
|
+
Licensed under the Apache License 2.0. Source:
|
|
223
|
+
[plimsoll on GitHub (EXTERNAL · source repo ↗)](https://github.com/plimsollmark/plimsoll/tree/main/clients/python/langchain-plimsoll).
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
README.md
|
|
3
|
+
pyproject.toml
|
|
4
|
+
src/langchain_plimsoll/__init__.py
|
|
5
|
+
src/langchain_plimsoll/py.typed
|
|
6
|
+
src/langchain_plimsoll.egg-info/PKG-INFO
|
|
7
|
+
src/langchain_plimsoll.egg-info/SOURCES.txt
|
|
8
|
+
src/langchain_plimsoll.egg-info/dependency_links.txt
|
|
9
|
+
src/langchain_plimsoll.egg-info/requires.txt
|
|
10
|
+
src/langchain_plimsoll.egg-info/top_level.txt
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
langchain_plimsoll
|