Language Machine Protocol (LMP) 🚀
LMP (Language Machine Protocol) is the open standard designed to bridge higher-level AI logic (like LLMs and Agent frameworks) with low-level, sandboxed execution environments.
Think of it like LSP (Language Server Protocol), but instead of connecting your code editor to a language analyzer, it connects your AI Agent to a Stateful Sandbox Engine.
✨ Key Features
- 🧠 Stateful Execution: Variables, functions, and memory persist between code executions. You no longer have to pass giant state strings back and forth.
- 🔒 Capability-Based Security: (Coming soon) Strict bounds on CPU, memory, and filesystem access to run untrusted agent code safely.
- 🛠️ JSON-RPC 2.0: Completely standard, language-agnostic message protocol over standard input/output (
stdio). - 🤖 Agent Framework Ready: Drop-in adapters for LangChain out-of-the-box.
📦 Installation
Installing LMP is incredibly simple. You can install it globally via pip:
pip install lmp-protocol
💻 The LMP CLI (Inspector)
LMP comes with a built-in CLI to help you start servers or debug your execution engine interactively.
To launch the LMP Inspector (an interactive terminal where you can type code and inspect memory), run:
lmp repl
Example Session:
Welcome to the LMP Inspector (REPL)!
lmp> x = [1, 2, 3, 4]
lmp> sum_x = sum(x)
lmp> inspect()
--- Variables ---
x (list): [1, 2, 3, 4]
sum_x (int): 10
-----------------
To start a standalone headless daemon process:
lmp start
🐍 Python SDK Usage
If you are building custom tools, you can use the LMPClient to manage background sandboxes effortlessly.
from lmp.client.client import LMPClient
# The context manager automatically boots and terminates the daemon process
with LMPClient() as client:
# 1. Execute Code
client.execute("a = 10\nb = 20")
# 2. Stateful Memory persists!
res = client.execute("print(a + b)")
print(res["result"]["pipes"]["stdout"]) # Outputs: 30
# 3. Inspect Memory dynamically
memory = client.inspect()
print(memory["result"]["variables"]["a"]["value"]) # Outputs: 10
🦜🔗 LangChain Integration
If you are building an AI Agent using LangChain, giving it a secure, stateful Python environment is just one line of code.
from lmp.adapters.langchain import LMPTool
from langchain.agents import initialize_agent, AgentType
from langchain.llms import OpenAI
# Initialize the stateful LMP tool
python_tool = LMPTool()
llm = OpenAI(temperature=0)
agent = initialize_agent(
tools=[python_tool],
llm=llm,
agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION,
verbose=True
)
agent.run("Calculate the first 10 numbers of the Fibonacci sequence and print them.")
📖 Specifications
The core protocol relies on the following core JSON-RPC methods:
lmp.initialize: Establish a sandboxed session.lmp.execute: Run raw text or AST JSON payloads.lmp.inspect: Introspect memory structures without triggering side effects.lmp.terminate: Destroy the environment safely.
For deep architectural details, please see the Full Protocol Specification.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file lmp_protocol-0.2.0.tar.gz.
File metadata
- Download URL: lmp_protocol-0.2.0.tar.gz
- Upload date:
- Size: 13.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/7.0.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fb387cd41aa51c4e9a69c4b79740cc420f53213feecfa3d8e3a30e5097a77ede
|
|
| MD5 |
df6020c428e1a8aec80899bbaa8bc715
|
|
| BLAKE2b-256 |
7d27a9a5021d6b47be3b899949b56a79939c97ed82f047654f5b2cfbe6e63d2e
|
File details
Details for the file lmp_protocol-0.2.0-py3-none-any.whl.
File metadata
- Download URL: lmp_protocol-0.2.0-py3-none-any.whl
- Upload date:
- Size: 12.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/7.0.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
47433864b9e2ff24b3ca60656dab2cc799fe784559bd2f6f304326994a754e54
|
|
| MD5 |
72b3546fd2d15774ec5ae3073eb69efd
|
|
| BLAKE2b-256 |
bc94414af93e223c18279489dd99dd29f79e49a63c3de2a057f2a5bd6a5bd6d2
|