Skip to content

langchain-quickjs==0.4.0

Choose a tag to compare

@github-actions github-actions released this 19 Nov 23:25
3285b5c

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 fs global with async readFile, writeFile, readdir, access, and rm methods and Node-style errors. Set fs=True to 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 with defer_loading callable.

Bug Fixes

  • Apply Command state 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.allSettled for 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.

Full changelog


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.

  • 3285b5c release(langchain-quickjs): 0.4.0 (#7672)
  • 40cdd33 fix(quickjs): steer code mode to Promise.allSettled for parallel calls (#7871)
  • 73df26f test(quickjs): cover ending a turn while a cancelled tool call unwinds (#7864)
  • c6bde12 fix(quickjs): apply state updates from tools.* calls in eval (#7838)
  • 41841fc fix(quickjs): render dict (MCP) args_schema inline in PTC signatures (#7464)
  • 161d107 refactor(quickjs): resolve tools.* on the Python side through one proxy (#7799)
  • 533e4b3 fix(quickjs): don't evict a slot while a cancelled eval still runs (#7850)
  • beeb0a0 fix(quickjs)!: keep QuickJS slots warm in a process-wide LRU (#7790)
  • 0e76f59 chore(deps): raise dependency minimums (#7832)
  • 9b754bc release(deepagents): 0.7.40 (#7757)
  • 469bd64 chore(deps): raise dependency minimums (#7816)
  • c9732c8 fix(sdk): avoid warning-filter races in warn_deprecated (#7749)
  • eaefb46 chore(deps): raise langchain minimum to 1.5.1 (#7817)
  • f6b17cd chore(deps): raise dependency minimums (#7802)
  • 1a7d602 fix(quickjs): close slots left open by failed runs and idle slots (#7463)
  • d60e40e feat(quickjs)!: upgrade to quickjs-rs 0.3.0
  • 53e09096 release(deepagents): 0.7.39 (#7711)
  • 18b61ae chore(deps): raise dependency minimums (#7751)
  • eab9304 chore(deps): raise dependency minimums (#7746)
  • b7be9fc chore(deps): raise dependency minimums (#7721)
  • dcba1a8 chore(deps): raise dependency minimums (#7704)
  • c858b36 release(deepagents): 0.7.38 (#7707)
  • 0ec4244 release(deepagents): 0.7.37 (#7699)
  • d9c6ad0 chore(deps): raise dependency minimums (#7698)
  • f1ae345 release(deepagents): 0.7.36 (#7670)
  • f2a6e02 fix(quickjs): parent PTC calls and task() subagents on the eval run (#7665)
  • 94657a4 feat(quickjs): let fs=True use the agent's backend (#7669)
  • 0cef0a8 feat(quickjs): add writeFile, readdir, access, and rm to fs (#7638)
  • e4c8748 feat(quickjs): add an opt-in fs.readFile over the agent's backend (#7637)
  • de00d21 chore(deps): raise dependency minimums (#7653)
  • 079d590 chore(deps): raise dependency minimums (#7649)
  • 18930b5 release(deepagents): 0.7.35 (#7590)
  • d848f21 chore(deps): raise dependency minimums (#7595)