QuickJS integration package for Deep Agents
Project description
langchain-quickjs
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.
Basic usage
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 behavior
- The REPL is stateless. Each call starts from a fresh QuickJS context, so variables, functions, and other values defined in one
replcall are not available in the next one. - Execution uses QuickJS, so JavaScript support is limited to what QuickJS provides. It is good for small computations, control flow, JSON manipulation, and calling exposed foreign functions, but it is not a browser or Node.js runtime and does not provide their APIs.
- Foreign functions support passing primitive values between JavaScript and Python, including
int,float,bool,str, andNone. Lists and dictionaries returned from Python are also supported and are bridged back into JavaScript arrays and objects. - Async foreign functions are supported. Because QuickJS callbacks are synchronous, awaitables are delegated to a dedicated daemon-thread event loop and their resolved results are returned back into the REPL call.
Current limitations
- Does not work with HIL in the REPL.
- Does not support
ToolRuntimeyet.
Project details
Release history Release notifications | RSS feed
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 langchain_quickjs-0.0.1.tar.gz.
File metadata
- Download URL: langchain_quickjs-0.0.1.tar.gz
- Upload date:
- Size: 136.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9a75fadda31eae075ba50d49c07c4a6c8244d9d3eba00998522ad52055f152ca
|
|
| MD5 |
b93da24e65942258665a4d5fff56bd4e
|
|
| BLAKE2b-256 |
5f0e6cf8c5a487ce76f6c8ea199cf6622bbbadf5f937d8d8d628efc8c7e9d4a7
|
File details
Details for the file langchain_quickjs-0.0.1-py3-none-any.whl.
File metadata
- Download URL: langchain_quickjs-0.0.1-py3-none-any.whl
- Upload date:
- Size: 12.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4d1c5caec4de370d963e6d0df898ce5f6f950b2b75cd841753b079ccb1d3e77b
|
|
| MD5 |
8c4f3b92814831aae22f456c115ce31b
|
|
| BLAKE2b-256 |
2472925cbad2460e07b00a9e4fa2be6c2e2fec2067feb2e2f906060e0be41548
|