libs/partners/quickjs/README.md
langchain-quickjs provides a QuickJS-backed REPL middleware for Deep Agents. It adds a repl tool that can evaluate small JavaScript snippets for computation, control flow, JSON manipulation, and calls to exposed Python foreign functions.
from deepagents import create_deep_agent
from langchain_quickjs import QuickJSMiddleware
def normalize_name(name: str) -> str:
return name.strip().lower()
agent = create_deep_agent(
model="openai:gpt-4.1",
tools=[],
middleware=[
QuickJSMiddleware(
ptc=[normalize_name],
add_ptc_docs=True,
)
],
)
With this middleware installed, the agent receives a repl tool that runs each JavaScript evaluation in a fresh QuickJS context. If you expose Python callables through ptc, they are available inside the REPL as foreign functions.
repl call are not available in the next one.int, float, bool, str, and None. Lists and dictionaries returned from Python are also supported and are bridged back into JavaScript arrays and objects.ToolRuntime yet.