What's new in llm4ts

In August llm4ts was a library: a typed seat, a structured reply, a tool. The shell got one paragraph, and I said it deserved its own post. This is that post, written against 4.17.0.

If you are new to it, ignore the version history and start here. You install nothing for the first run, you watch the work in a browser, and the interesting code lives in @llm4ts/flow.

Watch a run

Every run writes a trace. llm4ts watch --web draws it, live or finished, as the agent tree: the agents in flight, the judge’s verdicts, the session log, and the epic and story boards.

llm4ts watch --web --repo ~/work/portal            # the newest trace, live
llm4ts watch --web --replay .llm4ts/trace-….jsonl  # a finished run, with step and scrub

The page takes the same keys as the terminal tree. enter expands the selected story, b opens the boards, e shows one card per executor, t tails the selection’s transcript, l shows the log. In the executors view the arrow keys move the selection. A replay steps and scrubs, and ?seq=33 opens it at that trace line.

It listens on 127.0.0.1 and a free port. --port and --host choose them, and both need --web. --host 0.0.0.0 answers on any address of the machine, and watch says so when it starts. The page loads nothing from the network.

llm4ts watch without --web is the same tree in the terminal. llm4ts costs reads the traces for tokens and cost per day, run, and model. llm4ts profile --epic <id> says where the time went, biggest sinks first, and the report holds no prompts.

A flow that finishes the work

The built-in to run first is implement. It plans the task, then implements, reviews, and commits one task at a time, and a second run of the same command resumes where the first stopped.

llm4ts run implement --coder codex "Add a multiply function next to add, with a node:test test file"

--coder is the agent you have installed and logged in. The default is claude. The plan is a Markdown checklist under .llm4ts/, named from a hash of the prompt, so the same words find the same file. Each task becomes a commit on the flow’s branch. Re-running skips the tasks already ticked.

That loop is implementPlanFlow in @llm4ts/flow/Flow. Inside the built-in, after coderFromEnvironment() has filled the coder seat, the call is:

import { join } from "node:path"
import { withContract } from "@llm4ts/flow/AutonomyContract"
import {
  defaultPlanPath,
  implementPlanFlow,
  makePlanStore,
  nodePlainFileStore,
  planFrom
} from "@llm4ts/runner"

const planPath = join(input.workDir, defaultPlanPath(input.prompt))

yield* implementPlanFlow(context, {
  store: makePlanStore(nodePlainFileStore),
  planPath,
  plan: planFrom(context.reasoning, input.prompt),
  system: withContract("Implement one task at a time in the current repository.")
})

planFrom runs only when no plan is on disk. recoverOrCreate loads the checklist otherwise, so a resumed run spends no reasoning call on a plan it already has. The task loop skips anything marked completed, reviews the diff, and refuses to commit while a lint gate you configured is still red. A task that changed nothing is not an empty commit.

If the process dies mid-task, the next run tells the coder that an earlier attempt may have gone part way, and to start from the uncommitted changes. Ctrl-C, a red gate, or a failed review does not count. Three cut-offs and the plan stops. makePlanStore(files, { cutOffLimit }) changes that limit. The journal sits beside the plan as <plan>.attempts.json.

Stories write their tests first

epic-stories is the same loop over a list of stories, and since 4.10.0 it is test-first. Before a story’s tasks are planned, its coder writes a test for each acceptance criterion, tagged [story#n] in the test name. A reviewer reads them. The test gate has to fail. The flow commits those tests as <story>: red tests and freezes them, so the implementation cannot edit its own exam. Stories with no acceptance criteria skip it, and so do testsDeferred, testsChange, a story already in flight, and a run under --defer-tests or --harden.

llm4ts run epic-stories --no-test-first "…"   # or LLM4TS_TEST_FIRST=off

It costs one more coder conversation, one review, and one test-gate run per story. I would rather pay that than discover, three tasks later, that nobody named the behaviour.

Since 4.11.0 a story gets one rescue before it fails. When the last round still leaves the gates red, or the judge not cleared, the judge’s agent takes the coder’s seat for one turn, with write access, in the story’s worktree, on every open finding. That work is committed as <story>: rescue. The gates have to be green, and the judge gives one more verdict. Cleared, the story merges. Otherwise it fails, and the message says the rescue did not clear it.

An executor listed only as a judge is never given write access. With no roster, the rescuer is LLM4TS_REASONER. It is on unless you pass --no-rescue or LLM4TS_RESCUE=off. In a flow of your own the knob is StoriesOptions.rescue, and the prompt is rescuePrompt in @llm4ts/flow/Stories.

A run that finishes with a story failed, waiting, or skipped exits 1. The board and the report are written first. epic-stories, epic-stories-board, epic-mvp, and epic-draft all do this. The trace ends failed.

A flow of your own is one file

A flow is a TypeScript file under .llm4ts/flows/ of the directory you launch from. The shell resolves @llm4ts/runner and effect from its own installation, so the file needs no npm install. Copy the built-in and it is yours:

mkdir -p .llm4ts/flows && llm4ts view hello > .llm4ts/flows/hello.ts
// Hello: send one prompt to the configured provider and print the answer.
import * as Effect from "effect/Effect"
import {
  apiConnectorFromEnvironment,
  completeAndPublish,
  resolveFlowInput,
  runFlowMain,
  runNode
} from "@llm4ts/runner"

const program = Effect.gen(function* () {
  const input = yield* resolveFlowInput("Say hello and name one thing you can do.")
  const coder = yield* apiConnectorFromEnvironment()
  yield* runNode(
    {
      workDir: input.workDir,
      workspace: input.workspace,
      userPrompt: input.prompt,
      coder,
      environment: process.env
    },
    (context) => completeAndPublish(context.coder, context.events, input.prompt)
  )
})

runFlowMain(program)

The first // line is the description llm4ts list prints. completeAndPublish is the short form of “ask once, publish the answer” from @llm4ts/flow/Flow. Swap apiConnectorFromEnvironment() for coderFromEnvironment() and the same prompt goes to your coding agent.

To change the built-in loop instead of starting over:

llm4ts view implement > .llm4ts/flows/my-implement.ts

The review rounds, the lint gate, and the system prompt are fields of the object passed to implementPlanFlow. The flow authoring guide is the rest of that ladder, down to a custom task loop.

The zero-setup check, before any of this, is the mock provider:

npx -y @llm4ts/shell run hello "What is llm4ts?"

Node 22.6 or newer, macOS or Linux. No credentials.

Upgrading from 0.10

Pin effect at 4.1.5, exactly. Node is >=22.6.0. Windows is not supported; use macOS, Linux, or WSL.

copilot is gone as of 4.1.0. The registry answers Unknown connector: copilot. There is no replacement.

The imports from the August post are still exported: runNode and runFlowMain from @llm4ts/runner/FlowRunner, makeChat from @llm4ts/flow/Chat, CliConnectorConfig from @llm4ts/core/ConnectorConfig. 4.0 removed a long list of other names. coderFromEnv is one; coderFromEnvironment returns an Effect, and an unknown LLM4TS_CODER fails with ScriptUsage. The changelog names each removal and what replaces it.

@llm4ts/shell, @llm4ts/core, @llm4ts/flow, @llm4ts/runner, and @llm4ts/js are on npm at 4.17.0.

Where to look