Recursive Language Model
A durable RLM built from Tardigrade components.
What is an RLM?
An RLM puts long context inside a code environment. The model inspects and partitions that context, calls models over smaller pieces, and combines their work into one answer.
context[0..n]inspect(context)partition(context)recursive model callsBuild it with Tardigrade
Code mode provides the environment. Packages expose fetch, workspace storage, and child agents. Budgets and compaction keep the recursive work bounded.
import { actor } from "tardie/deprecated/core"
import { agentMethods, agents, budget, caller, escalate, codeMode, compact, messages, infer, outputValidateOnce, system } from "tardie/deprecated/agent"
import { fetch, workspace } from "tardie/code"
const instructions = system(
"Investigate with code and delegate independent work."
)
const rlm = actor({
name: "researcher",
methods: agentMethods,
components: [
infer([
instructions,
escalate(
budget(codeMode([
fetch(),
agents(),
workspace()
]), {
limit: 40,
usage: ({ calls }) => calls.length,
onExhausted: (reason, settle) => settle({ error: reason })
}),
{ authority: caller(), requests: { decide: request => request.grant() } }
),
compact(messages()),
outputValidateOnce
])
]
})
The budget component records its starting allowance as BudgetGranted before inference. Set { limit: 20, authority: caller() } to start with 20 tool calls; the default is DEFAULT_BUDGET_POLICY.limit, which is 40. Further grants add to that allowance. Each tool call uses only the grants recorded before it, so a later grant cannot admit an earlier refused call. Restarting with a different default leaves a recorded allowance unchanged.
How it is assembled
codeModeLets the model act by writing JavaScript.
agentsPackageLets that code spawn durable child agents.
workspacePackageStores large values outside the model context.
budget + compactionBounds delegated work and the context sent to the model.
Start from the quickstart
Initialize a project with the RLM template to get this assembly directly.
tdg init researcher --template rlm