Repository navigation
langchain-quickjs==0.4.0
langchain-quickjs 0.4.0 is out! Code mode gets a real filesystem, tools that actually update your agent's state, and a much lighter footprint.
📁 fs in code mode
Code can now read and write the agent's files directly, the same files its file tools see, through a Node-style fs global. Pass fs=True with create_deep_agent (or pass any backend yourself):
agent = create_deep_agent(
model,
middleware=[CodeInterpreterMiddleware(ptc=True, fs=True)],
)One eval can now do what used to take a dozen file-tool round trips:
const files = await fs.readdir("/reports");
const totals = {};
for (const name of files.filter((f) => f.endsWith(".json"))) {
const { region, revenue } = JSON.parse(await fs.readFile(`/reports/${name}`));
totals[region] = (totals[region] ?? 0) + revenue;
}
await fs.writeFile("/summary.json", JSON.stringify(totals, null, 2));It has readFile, writeFile, readdir, access and rm, all async, and errors come back as Node errors (err.code === "ENOENT").
🔁 Tools called from code now respect Command
Before, when a tool returned Command(update=...) and you called it from code, the update was silently dropped. Now it lands in graph state just like a normal tool call, later calls in the same eval see it, and your JS gets the tool's message back:
@tool
def save_plan(plan: str, tool_call_id: Annotated[str, InjectedToolCallId]) -> Command:
"""Save the plan to state."""
return Command(update={
"plan": plan,
"messages": [ToolMessage("plan saved", tool_call_id=tool_call_id)],
})await tools.savePlan({ plan: "1. research 2. draft" }); // "plan saved", and state.plan is set⚡ Faster startup, lower overhead
Interpreters are now created on the first eval, not when the agent starts, so threads that never run code never pay for one. Closing them no longer blocks the event loop, and runs that error or get cancelled release their interpreter cleanly. The code-mode system prompt is cached by content, so it isn't re-rendered every turn.
Also in this release: one tools.* proxy (with defer_loading tools still callable), typed signatures for MCP tools, and quickjs-rs 0.3.0.
Heads up: JS state saved by 0.3.x won't restore, so existing threads start from a fresh JS context on their next eval.
⚠ BREAKING CHANGES
- Upgrade to quickjs-rs 0.3.0. JavaScript state saved by 0.3.x cannot be restored; existing threads start with a fresh JavaScript context on their next evaluation.
- Keep QuickJS interpreters warm in a process-wide LRU cache. (#7790, #7262, #5387, #4546, #6311)
Features
- Add an opt-in, Node-style
fsglobal with asyncreadFile,writeFile,readdir,access, andrmmethods and Node-style errors. Setfs=Trueto use the agent's backend, or supply a backend explicitly. (#7638, #7637, #7669) - Unify tool access through a single
tools.*proxy while keeping tools configured withdefer_loadingcallable.
Bug Fixes
- Apply
Commandstate updates returned by tools called from code. Later calls in the same evaluation see the updated state, and JavaScript receives the tool's message. (#7838) - Clean up interpreters left open by failed runs or inactivity, and prevent eviction while a cancelled evaluation is still running. (#7463, #7850)
- Correctly parent programmatic tool calls and
task()subagents under the evaluation run. (#7665) - Render dictionary-based MCP argument schemas inline as typed signatures for programmatic tool calling. (#7464)
- Update code-mode guidance to prefer
Promise.allSettledfor parallel calls. (#7871)
Performance Improvements
- Create interpreters only on the first evaluation, avoiding interpreter overhead for threads that never run code, and close interpreters without blocking the event loop.
- Cache the code-mode system prompt by content to avoid re-rendering it every turn.
Special thanks to everyone who reported the issues addressed in this release: Jesse Mazzella (@ozyx) (#5652), Connor Imes (@connorimes) (#3991, #4546), Hendrik Hogertz (@hendrik-hog) (#5387), Radu Mocanu (@radu-mocanu) (#6311, #6401), Ramon Nogueira (@ramon-langchain) (#7262)
Internal maintainers: Baihao Wang (@byhow), Hunter Lovell (@hntrl), Mason Daugherty (@mdrxy)
Released by: Hunter Lovell (@hntrl)
Git log since langchain-quickjs==0.3.12
This commit history includes changes to this package. The most recent commit is at the top; older commits follow below.
3285b5crelease(langchain-quickjs): 0.4.0 (#7672)40cdd33fix(quickjs): steer code mode toPromise.allSettledfor parallel calls (#7871)73df26ftest(quickjs): cover ending a turn while a cancelled tool call unwinds (#7864)c6bde12fix(quickjs): apply state updates fromtools.*calls in eval (#7838)41841fcfix(quickjs): render dict (MCP)args_schemainline in PTC signatures (#7464)161d107refactor(quickjs): resolvetools.*on the Python side through one proxy (#7799)533e4b3fix(quickjs): don't evict a slot while a cancelled eval still runs (#7850)beeb0a0fix(quickjs)!: keep QuickJS slots warm in a process-wide LRU (#7790)0e76f59chore(deps): raise dependency minimums (#7832)9b754bcrelease(deepagents): 0.7.40 (#7757)469bd64chore(deps): raise dependency minimums (#7816)c9732c8fix(sdk): avoid warning-filter races inwarn_deprecated(#7749)eaefb46chore(deps): raiselangchainminimum to 1.5.1 (#7817)f6b17cdchore(deps): raise dependency minimums (#7802)1a7d602fix(quickjs): close slots left open by failed runs and idle slots (#7463)d60e40efeat(quickjs)!: upgrade to quickjs-rs 0.3.053e09096release(deepagents): 0.7.39 (#7711)18b61aechore(deps): raise dependency minimums (#7751)eab9304chore(deps): raise dependency minimums (#7746)b7be9fcchore(deps): raise dependency minimums (#7721)dcba1a8chore(deps): raise dependency minimums (#7704)c858b36release(deepagents): 0.7.38 (#7707)0ec4244release(deepagents): 0.7.37 (#7699)d9c6ad0chore(deps): raise dependency minimums (#7698)f1ae345release(deepagents): 0.7.36 (#7670)f2a6e02fix(quickjs): parent PTC calls andtask()subagents on the eval run (#7665)94657a4feat(quickjs): letfs=Trueuse the agent's backend (#7669)0cef0a8feat(quickjs): addwriteFile,readdir,access, andrmtofs(#7638)e4c8748feat(quickjs): add an opt-infs.readFileover the agent's backend (#7637)de00d21chore(deps): raise dependency minimums (#7653)079d590chore(deps): raise dependency minimums (#7649)18930b5release(deepagents): 0.7.35 (#7590)d848f21chore(deps): raise dependency minimums (#7595)