langclaw 0.2.0 — workflows and the code interpreter¶
0.2.0 introduces two major primitives: the @app.workflow decorator for durable multi-step routines, and an opt-in sandboxed code interpreter that lets the agent author and run its own workflows at runtime.
Workflows¶
A workflow is a typed, multi-step routine the agent can call as a tool, a user can trigger via /workflows run, and a cron job can fire on schedule.
from pydantic import BaseModel
from langclaw import Langclaw
app = Langclaw()
class Brief(BaseModel):
topic: str
angles: list[str] = ["overview", "risks", "recent news"]
@app.workflow(
"research",
input=Brief,
max_concurrency=4,
description="Search several angles in parallel, then synthesize.",
)
async def research(ctx, inp: Brief) -> str:
ctx.phase("gather")
findings = await ctx.parallel([
lambda c, a=a: c.tool("web_search", query=f"{inp.topic} {a}")
for a in inp.angles
])
ctx.phase("synthesize")
return "\n\n".join(f"## {a}\n{r}" for a, r in zip(inp.angles, findings))
Three authoring modes ship in 0.2:
| Mode | Who writes the body | When |
|---|---|---|
python |
You | Typed, testable, deterministic control flow |
saved |
The agent (once) | Agent writes a JS body, saved to workflows/<name>.js, loads as a tool |
llm_authored (experimental) |
The model, per run | Model writes the body fresh each run from a typed contract |
Live progress streams to the channel as the workflow runs — users see phase headers and results as they come in.
Code interpreter (RLM)¶
An opt-in sandboxed JavaScript eval tool backed by langchain-quickjs. The agent writes a program that can call tools, loop, branch, and fan out — including spawning subagents via tools.task.
The sandbox is capability-scoped: the agent can only call tools from an allowlist, and RBAC middleware runs before it. No ambient filesystem or network access.
This is what powers saved and llm_authored workflow bodies — the interpreter is the runtime for both.
Matrix channel¶
uv add "langclaw[matrix]"
LANGCLAW__CHANNELS__MATRIX__ENABLED=true
LANGCLAW__CHANNELS__MATRIX__HOMESERVER_URL=https://matrix.org
LANGCLAW__CHANNELS__MATRIX__ACCESS_TOKEN=...
RBAC: subagents and workflows axes¶
app.role() now accepts subagents and workflows lists alongside tools. Both default-deny — a role must explicitly opt in:
app.role("analyst", tools=["*"], subagents=["researcher"], workflows=["digest"])
app.role("free", tools=["web_search"], subagents=[], workflows=[])
What's in 0.2¶
@app.workflow()— durable, typed, multi-step routinesctx.parallel,ctx.tool,ctx.subagentworkflow steps- Three authoring modes: python (recommended), saved, llm_authored
- Sandboxed code interpreter (
langclaw[interpreter]) - Matrix channel
- RBAC
subagentsandworkflowsaxes onapp.role() - Named agent
display_namesupport - Streaming fix: only model chunks reach the channel (not middleware nodes)