Skip to main content

langchain-submilli

Submilli is a dedicated secure runtime for code-mode agents, with built-in isolation, governance, and permissions.

langchain-submilli is the Python integration for LangChain and Deep Agents. It lets your agent execute TypeScript code in Submilli's runtime.

Install

Python 3.11 or later and a server with batch package documentation support (SUB-2074) are required. Selective function documentation additionally requires SUB-2193 server support.

pip install langchain-submilli

Deep Agents is optional. Install the extra when you use it:

pip install "langchain-submilli[deepagents]"

Follow Connect Deep Agents for a complete setup with a server, Blueprint, model provider, agent, and session cleanup.

Middleware reference

SubmilliMiddleware is async only. Use ainvoke or astream.

SubmilliMiddleware(
    blueprint="research",
    server=None,
    token=None,
    variables=None,
    secrets=None,
    hide_filesystem_tools=False,
    client=None,
    ptc=None,
    interrupt_on=None,
)
Setting Contract
blueprint Name of a Blueprint already registered on the server; used for every program
server submilli-server URL; defaults to $SUBMILLI_SERVER, then http://127.0.0.1:8128
token Server token; defaults to $SUBMILLI_SERVER_TOKEN
variables Fixed dict[str, str], or a function from the run context to one; defaults to mapping context user_id to Blueprint variable userId
secrets Fixed dict[str, str], or a function from the run context to one, for the Blueprint's harness secrets
hide_filesystem_tools Hides and refuses Deep Agents' file and shell tools on this agent. Subagents need separate configuration.
client Existing submilli.AsyncSubmilli; replaces server and token
ptc Application tools that programs may call through the @tools Package
interrupt_on LangChain human-in-the-loop settings for calls to tools in ptc

The middleware gives your agent the six tools below. Before the first model call, it fetches the instructions for using them from the Submilli server.

Tool Does
submilli__typescript__execute Runs a program
submilli__typescript__last_run Returns the thread's last run and full console
submilli__typescript__packages__search Searches Packages available to the program
submilli__typescript__packages__docs Returns a Package's documentation and declarations
submilli__typescript__builtins__list Lists built-ins available without an import
submilli__typescript__builtins__docs Returns declarations for selected built-ins

Sessions, retries, and results

  • The first program run opens a Submilli session for the conversation. LangGraph can save the session ID with the conversation state using a checkpointer, so later turns reuse it. To reuse it after your application restarts, use persistent storage for the checkpointer. Close the session with await middleware.aclose_thread(agent, config).
  • Blueprint variables are fixed when the session opens. A later run on the same thread with different values raises SubmilliSessionMismatchError before the model is called.
  • Harness secrets are sent when a session opens and are never stored in agent state. End the session before using rotated secrets.
  • Each execute call sends an Idempotency-Key derived from the LangChain tool call id. A repeated call replays the recorded result. The middleware reports conflicts and incomplete, in-progress, or unavailable replays without silently rerunning the program.
  • When a session has ended, the middleware opens a replacement. If a restarted server asks for the session's secrets, it rebinds them once and retries.
  • On a server with durable execution, the middleware waits for a queued run. A run that stops without a result, such as one that is stuck or cancelled, comes back to the model as an error with the run's status and reason, and the artifact's run_status names it.
  • The execute tool message contains result, console, error, and denied. Its artifact contains execution_id, session_id, and any application-tool calls.

Submilli enforces the Blueprint only for code that runs through Submilli. Other LangChain tools keep their own permission boundaries.

Application tools

Let programs reuse your existing LangChain tools. A model-written program can combine calls, loop over results, branch on conditions, and process the results in one run.

The ptc parameter (programmatic tool calling) tells SubmilliMiddleware which LangChain tools programs can use. Submilli makes those tools available to the program through the @tools Package, so the program can import and call them. In your Blueprint, grant tools.call with a filter for each allowed tool name.

The middleware runs each call through a LangGraph ToolNode with the run's state, context, and store. Input types come from the tool schema, and return types come from annotations. Use a TypedDict or Pydantic model for typed objects. A raised exception becomes an Error in the TypeScript program.

Tools in ptc are not given to the model directly. If you also pass them to the agent, direct model calls bypass Submilli's Blueprint checks.

A session keeps the application-tool catalog it opened with. Changing the catalog causes the thread's next call to open a new session.

Submilli documentation

Development

This package lives in the submilli-python workspace. See the repository README for workspace setup, checks, and releases.

uv run pytest                          # unit tests; the HTTP API is mocked
uv run pytest tests/integration_tests  # requires a server

The integration tests use a scripted model and need no model provider key. Most use a server at $SUBMILLI_SERVER with the research Blueprint; the others start a server from $SUBMILLI_BIN or PATH.

export SUBMILLI_SERVER_TOKEN=$(openssl rand -hex 32)
scripts/test-server.sh &
SUBMILLI_SERVER=http://127.0.0.1:8128 uv run pytest tests/integration_tests

Implementation notes are in NOTES.md.

Function documentation mode

Pass function_docs=True to the middleware/toolkit constructor to fetch compact package indexes before selected declarations. The docs tool accepts names, and submilli__typescript__packages__functions accepts a cross-package batch:

{"requests": [{"name": "@submilli/jina", "functions": ["searchJson"]}, {"name": "submilli:crypto", "functions": ["sha256"]}]}

Each package returns its own result, including referenced types or an error. The default remains full documentation with the original tool list.

License

Apache-2.0.

Metadata

Release files for langchain-submilli 0.1.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for langchain-submilli 0.1.4
File Size Uploaded Provenance Actions
langchain_submilli-0.1.4.tar.gz 54.1 kB With provenance Details for langchain_submilli-0.1.4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for langchain-submilli 0.1.4
File Interpreter ABI Platform Actions
langchain_submilli-0.1.4-py3-none-any.whl Python 3 none any Details for langchain_submilli-0.1.4-py3-none-any.whl

Total release size: 81.0 kB

Release files / langchain_submilli-0.1.4.tar.gz

Download URL langchain_submilli-0.1.4.tar.gz
Size 54.1 kB
Tags Source
SHA-256 checksum
How to use checksums
0b5cef9f6ae0fb3ac1a53b0436b5d6aba73945b0d48151c9dc9c947948016541
BLAKE2b-256 checksum
How to use checksums
3e5c265c2de7c624f8ee881e70b7216d3992727e789cde7ea750efc5a329d3f0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 17, 2026.

Transparency log

Release files / langchain_submilli-0.1.4-py3-none-any.whl

Download URL langchain_submilli-0.1.4-py3-none-any.whl
Size 26.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a5048f2988ed0377f569b08c7ebf20e57ece70cf7a5a0e1a58b0c8e700547e7f
BLAKE2b-256 checksum
How to use checksums
a15dcbcd9ecf0b747e5f46d49bdb037abcbd13ab96928f28ba2b80af2261c5ec
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 17, 2026.

Transparency log

Security for langchain-submilli 0.1.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for langchain_submilli-0.1.4.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 17, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page