pi-mono/packages/durable/CHANGELOG.md
Mario Zechner 6536f80129 feat(ai,agent,coding-agent): validate tool arguments with pi-schema, drop TypeBox
pi-schema: opt-in coercion, compile(schema, { coerce: true }) with coerce() and
parse(), the superset of TypeBox's Value.Convert rules and pi-ai's old coercion;
unresolvedRefs option; url and json-pointer-uri-fragment formats.
pi-ai: Tool takes any JSON Schema; validation through pi-schema; Type, Static
and TSchema are no longer exported (breaking). pi-agent-core and pi-durable:
tools on pi-schema, no TypeBox dependency. Coding agent: extensions keep Type,
Static, TSchema and StringEnum through an extension view of pi-ai; built-in
tools stay on TypeBox.
2026-11-01 10:08:42 +00:00

76 KiB

Changelog

[Unreleased]

Breaking Changes

  • Tool schemas are JSON Schema typed through @earendil-works/pi-schema: defineTool() and ToolRegistration take any JSON Schema object as parameters and structuredOutputSchema, and type args with pi-schema's Static (ToolArgs<TParameters>; other schemas give unknown). The built-in tools (read, write, edit, bash, powershell, codemode, tool_search, the model tools) are built with pi-schema, with the same JSON Schema up to key order. structuredOutput is validated with pi-schema, so invalid_structured_output messages use its wording. typebox is no longer a dependency. Migration: replace Type.Object({ n: Type.Number() }) from @earendil-works/pi-ai with obj({ n: num() }) from @earendil-works/pi-schema (closed by default; { open: true } allows other properties).

  • SqliteExecutor (re-exported from Chord) gains runCounted(sql, ...params), resolving with the rows the statement changed; custom SqliteDatabase implementations add it.

  • Storage.commit() stores a group of commits in one call: commit(batches, receive, context) resolves with a CommitResult ({ stored, refused? }) and replaces commit(writes, adopt, context). Each batch is one atomic commit with its own seq, checked against the state the batches before it left. The first batch Durable's own checks refuse (global IDs, document actions, copy sources) is not stored, nor anything after it; the batches before it are, and the call resolves with their number in stored and the refusal in refused. Any other failure (a driver or I/O error, a failed COMMIT) rejects the whole call as an unknown outcome and stores nothing the backend could roll back. receive(index, seq) is called once per stored batch, in order, synchronously, once they are durable and before the next call starts; receipts made before a rejection stand. Every batch has at least one write. The optional publishing(publish, context) runs each commit's publication inside the storage's own scope (StoreStorage: the attached host's batch). Memory, SQLite, JSONL, IndexedDB and StoreStorage store a call in one transaction or append, and the storage conformance suite checks the contract. Migration for a custom Storage:

    // Before
    async commit(writes, adopt, context) {
    	const seq = await this.transaction((tx) => {
    		check(tx, writes); // throws when Durable's rules refuse the commit
    		return apply(tx, writes);
    	});
    	adopt(seq);
    	return seq;
    }
    
    // After
    async commit(batches, receive, context) {
    	let refused: { error: unknown } | undefined;
    	const seqs = await this.transaction((tx) => {
    		const stored: Seq[] = [];
    		for (const writes of batches) {
    			try {
    				check(tx, writes); // only Durable's own checks; reads the earlier batches' writes
    			} catch (error) {
    				refused = { error };
    				break; // keep the batches before it
    			}
    			stored.push(apply(tx, writes)); // a throw rejects the call and rolls all of it back
    		}
    		return stored;
    	});
    	seqs.forEach((seq, index) => receive(index, seq));
    	return refused === undefined ? { stored: seqs.length } : { stored: seqs.length, refused: refused.error };
    }
    

    A database error during the checks is not a refusal: it must reject the call. A wrapper forwards commit() and publishing(). Code that called storage.commit(writes, adopt, context) directly, such as a test seeding a storage, calls commitWrites(storage, writes, context) from @earendil-works/pi-durable/testing (one batch; resolves with its seq, throws the refusal).

  • Storage.mintId()'s contract is narrowed to IDs greater than every ID minted since the storage was opened and every ID stored, also across reopen. The bundled storages already behave so.

  • Watches use Chord's WatchHandle and WatchEnd (Durable re-exports both, with WatchChange and NativeWatchChange). End reasons are stopped, cancelled, ended (was session_closed), listener_error, and failed (was session_failed); retired is gone (see below). An ended watch drops its listener and every reference into its Session, so a stopped watch that is still referenced keeps only its last value.

  • Watch listeners take one change object before the context: watch.start(async ({ value, ops, retired }, context) => …) for document, conversation view (Conversation.watch()), and task graph watches. Migration: start(async (value, ops, ctx) => …) becomes start(async ({ value, ops }, ctx) => …).

  • Document watches follow their address (kind, scope, and key) instead of one incarnation: DocumentWatch<T> is WatchHandle<Readonly<T>> (no null). A retirement no longer ends the watch with a last frame [["r", null]] and retired: the next call has retired: true, the last value the watch was given, and no ops (folded with what is pending; a change made in the retiring commit itself is not shown), and a document created at the address later arrives on the same watch as [["r", value]], possibly in the same call. A task document's watch ends ended once the retirement call of the commit that makes its task terminal has returned; Session close or failure still ends it first if that call was not delivered yet (a watch never started). Acquiring an absent document still gives undefined. A watch pins the incarnation at its address, nothing while it is absent. Migration: test change.retired instead of a null value or a retired end, and stop a watch whose document may be retired for good, as it otherwise stays until the Session ends.

  • Document, conversation view, and task graph watches deliver the commits made while their listener runs (or before start()) in one callback: the newest value, the commits' operations folded (appends to one string join, sets of one field keep the last) and the newest commit's Context. Past 10,000 pending operations the callback gets one root replacement [["r", newest]]. Before, each commit was its own callback and more than 100 pending commits became a root replacement.

  • Removed the Chord state getters Session.documentState(), Conversation.viewState(), and Harness.taskGraph(), and the DocumentState type; use watchDoc(), Conversation.watch(), and Harness.watchTaskGraph(). Durable no longer uses Chord's replicatedState().

  • Partial answers and running tool output are stored later than they are shown: their throttled commits are deferred (CommitPersistence, spec §4.1), so watches and views see each at once, while Storage gets them together with the next commit that reads pi.live (the end of the answer, a tool settling, a run ending) and at the latest after settings.progress.persistWithinMs (default 1,000 ms). With 32 streams over SQLite this cuts storage transactions about 5.7x and disk writes about 2.9x for turns with parallel tools, 27x and 9x for long answers, and CPU by about a quarter. A crash now loses up to about a second of streamed content instead of 100 ms; a stream that crashes before its first store leaves no aborted entry, and that attempt's usage is not recorded. subscribeCommits() gets these commits only once they are stored, with exactly what was stored (held operations first; a document the commit retires shows as its retirement only, without the operations stored before it), and gets a publication for a deadline's store too; it no longer sees every partial. Migration: a subscribeCommits() listener that showed live progress should use watchDoc() or Conversation.watch(); one that mirrors Storage keeps working; set settings.progress.persistWithinMs: 0 to store progress right after each commit, about as before (one storage transaction per partial).

  • The change type of FileSystem.watch() in @earendil-works/pi-durable/env is renamed from WatchChange to FileChange (same shape: { paths }, { overflow: true }, or { error }), so WatchChange names only a watch listener's change. Migration: import type FileChange from @earendil-works/pi-durable/env where WatchChange was imported from it.

  • HostCallback gains "telemetry": a host_error report about a telemetry adapter that threw while a commit was published. Exhaustive switches over HostCallback need a case for it.

  • ConversationView.entries is a window over the transcript instead of the active transcript: the fork-aware history Conversation.entries() scans, in entry ID order, with head markers (compaction summaries, resets, handoffs) appended in place instead of cutting the entries before them. A watch starts with the newest 50 entries; new entries are appends, and past 100 the oldest leave in one splice down to 50, which also sets the new ConversationView.before, the ID of the entry just before the window (absent when the window starts the transcript). First values and overflow replacements ([["r", view]]) hold at most max entries, never the whole transcript. Migration: read the active transcript the model sees from Conversation.context(); render a transcript longer than the window with ConversationTranscript, or page older entries with Conversation.entries(); a client that rebuilt the head cut from the view's operations no longer gets one (#11327).

  • Conversation.watch(context, window?) and Harness.observeConversation(id, observer, context, window?) take a ConversationWindow (from, min default 50, max default 2 * min): min/max bound the window, and from starts the first value at that entry ID when at most max entries are at or after it, otherwise at the newest min; it picks only that first value, so every entry committed after the attachment is appended, and a from past the newest entry starts empty. Bounds that are not integers, or max below min, reject with a RangeError. Each watch and observer has its own window, so the observers of one conversation no longer share one change object or one value; they share the document values (#11327).

  • pi.live is no longer empty after a run that ended without an answer: it keeps runFailure (below) until a later run starts. Code that compares an idle pi.live with {}, or tests for idleness that way, checks run === undefined instead (#11327).

  • Removed watchEvents() and its types AgentEvent, AgentEventStream, SnapshotEvent, MessageChange, and ToolEventCall, and spec §9.4. A renderer renders state instead of assembling it from events: everything the events carried that a renderer draws is in the conversation view, typed for producer and consumer, and new information becomes a field there rather than an event type every client must learn (#11327). Migration, for a client of watchEvents():

    Before:

    const stream = await watchEvents(harness, conversation.id, context);
    initialize(stream.snapshot); // entries, run, generation, tools, compactions, inbox, agent, usage
    stream.start(async ({ value: events }) => {
      for (const event of events) {
        if (event.type === "message_update") applyChanges(event.changes); // streamed text
        else if (event.type === "message_end") appendEntry(event.entry);
        else if (event.type === "tool_execution_update") applyOutput(event.toolCallId, event.output);
        else if (event.type === "run_end") showIdle();
        // ... and every other event type
      }
    });
    // After a drop: attach again; the new snapshot replaces everything held.
    

    After:

    const transcript = new ConversationTranscript((query, limit, ctx) => conversation.entries(query, limit, undefined, ctx));
    const watch = await conversation.watch(context);
    render(transcript.merge(watch.value));
    watch.start(async ({ value }) => render(transcript.merge(value)));
    
    function render(view: TranscriptView): void {
      const live = view.docs["pi.live"] as LiveState;
      drawItems(view.items); // entries, a "load more" row per gap, "load earlier" at the top
      if (live.generation?.message !== undefined) drawStreaming(live.generation.message);
      for (const slot of live.tools ?? []) drawTool(slot); // status, running output, details, result entry
      if (live.runFailure !== undefined) drawFailure(live.runFailure); // why the last run ended without an answer
      setBusy(live.run !== undefined);
    }
    // A "load earlier" or "load more" row scrolled into view:
    render(await transcript.loadEarlier(context));
    render(await transcript.fillGap(gap, context));
    // After a drop: only what was missed when it fits the window, otherwise the newest entries and a gap.
    const resumed = await conversation.watch(context, transcript.resume);
    

    The watch's operations carry the same deltas the events did (text and thinking appends, tool-call argument appends, output trims and appends), for a client that forwards them, for example to a remote replica. Where each event went:

    event state
    snapshot the watch's first value, watch.value, its window bounded by max
    run_start, run_end pi.live.run appears, disappears
    turn_start, turn_end pi.live.run.taskId moves to the next generation; the task graph's pi.generation nodes, completing at their hold
    message_start, message_update pi.live.generation.message, the streamed answer, with its usage
    message_end, entry_appended the entry appended to entries
    tool_execution_start, tool_execution_update, tool_execution_end the slot in pi.live.tools or nestedTools: status pending, running, done; output, details, diagnostics; entry once done (absent after a fault); a nested call's arguments, its summary, and its result in the caller's NestedCallDoc
    auto_retry_start, auto_retry_end pi.live.generation.retry set, removed
    deferred_poll pi.live.generation.deferred.pollAt
    compaction_start, compaction_end a status in pi.live.compactions appears, disappears; pi.live.compactionFailure when it failed; the summary entry when it is placed
    inbox_update pi.inbox
    agent_changed, usage_changed pi.agent, pi.usage
    submission Submission.status() and wait(), Harness.submission(id); queued items in pi.inbox, the run's inputs in pi.live.run.inputs
    task_failed the task graph (completing with the outcome's status), Harness.getTask(), and onReport's task_faulted; for a run, pi.live.runFailure; for a compaction, compactionFailure; for a tool, a done slot without entry
    a run that ended without an answer (run_end with an unanswered submission) pi.live.runFailure: reason (model_error, no_model, aborted, reset, faulted, orphaned), detail, taskId, inputs

    Some event data has no state in the view. A tool's arguments after repair and beforeTool at its start: in the nested slot's arguments for a nested call, only in the tool task's checkpoint for a model-issued one. A submission's settlement: Submission.status()/wait() and Harness.submission(id); an input settled without a run (withdrawn, stale, aborted while queued, run_failed) just leaves pi.inbox. A failed task's error: Harness.getTask() and onReport; the task graph keeps only live tasks, not terminal outcomes. A nested call's full result: its caller's NestedCallDoc (watchDoc()), which retires when the caller settles. Exact turn boundaries: the run's taskId and the task graph, with no explicit event. Whether a compaction did anything: its CompactionResult (waitForTask()), and the summary entry when it is placed.

  • Restart-limited tasks no longer park: a task cut off settings.restartLimit times in a row ends instead, visibly. A tool call ends with an error result (diagnostic code restart_limit) and its task fails with detail { reason: "restart_limit" }, a compaction fails into pi.live.compactionFailure, a generation ends its run with pi.live.runFailure reason restart_limit (its inputs settle unanswered with that reason), and a task of an extension's kind ends faulted with detail { reason: "restart_limit" }, reported as task_faulted with reason restart_limit. The built-in tasks are reported as task_interrupted (below). An abort handler cut off at the limit still faults its task, but a run someone aborted now ends with runFailure reason aborted, the cut-off as detail, and an aborted compaction leaves no compactionFailure. Harness.retryTask(), the restart_limit blocked reason of TaskInspection and TaskGraphNode, and the task_parked report (and its telemetry value) are removed. Migration: a parked task kept its conversation busy until retryTask(); it now ends, so show runFailure, compactionFailure, the tool's error result, or the task_interrupted and task_faulted reports instead, and to run the work again, submit it again (a new input, compact(), or a new task); raise restartLimit before the task is next reserved to let it run longer (#11139).

  • A generation whose model request was in flight when the host died no longer resends it on open: the attempt counts as failed under settings.retry. Its partial becomes an aborted entry, as before; the next attempt waits for the backoff, shown in pi.live.generation.retry, and with no retry left the run ends with pi.live.runFailure reason interrupted and the inputs settle unanswered with that reason. A deferred poll whose fetch was in flight is charged the same way, even when the replacement host's clock is behind, and its next attempt polls the same deferred response again instead of submitting a new request; a run that ends instead cancels it. A close still resends. restartLimit still bounds these phases: a charge that itself keeps being cut off ends the run restart_limit, past the limit without converting the partial (#11139).

  • Watch listeners and synchronous observers take Chord's tagged watch shapes. Durable re-exports WatchCall and NativeWatchCall instead of WatchChange and NativeWatchChange; a listener gets { kind: "value", value, ops, retired }. Chord's { kind: "failed", error } call, for a source that recovers, never comes from Durable, whose failures end the watch. WatchEnd is tagged by kind, and a watch whose acquisition context is aborted ends aborted (was cancelled). Before: watch.start(async ({ value, ops }) => render(value, ops)), if (end.reason === "cancelled"). After: watch.start(async (call) => { if (call.kind === "value") render(call.value, call.ops); }), if (end.kind === "aborted").

  • Observer<T> (observeDoc(), observeConversation(), observeTaskGraph()) has the watch's shapes: advance(call: WatchCall<T>, context) (always a value call) and end(end: WatchEnd): ended at close or after a task document's retirement with its task (was undefined), failed with the error that failed the Session (was { error }), and listener_error with the error for an observer that threw (was { error }), now also for one whose advance returns a promise that rejects. Before: { advance: ({ value }) => push(value), end: (failure) => failure && fail(failure.error) }. After: { advance: (call) => call.kind === "value" && push(call.value), end: (end) => end.kind === "failed" && fail(end.error) }.

  • subscribeCommits(listener) is observeCommits(observer) with the observer shape: { advance(publication, context), end(end) }, returning { detach() }. Its observation has no value: commits are events, and the Session does not know Storage's newest seq before its own first commit. end comes once, ended after the last publication at close or failed when the Session fails; an observer that throws (or whose advance rejects) is reported, detached, and ended listener_error (a throwing listener stayed subscribed). Before: const unsubscribe = harness.subscribeCommits((publication) => apply(publication)); unsubscribe();. After: const observation = harness.observeCommits({ advance: (publication) => apply(publication), end: () => {} }); observation.detach();.

  • HarnessOptions.onReport(report) takes one Report: the fields of ReportInfo, tagged by kind (was type), and the error (was the first argument). session_failed is storage_failed, and task_outdated's reason incompatible_task is the scheduler's own word for why the replacement cannot take the task: task_too_old (older than the task) or migration_failed (newer without a migrate), as a blocked task shows. The pi.durable.report event and pi.durable.reports metric keep their type attribute, with the new values. Before: onReport: (error, info) => { if (info.type === "session_failed") restart(error); }. After: onReport: (report) => { if (report.kind === "storage_failed") restart(report.error); }.

  • DocumentCommitChange is tagged: a document change is { type: "document", kind: "change", record, conversationId, version, value, ops } and a retirement { type: "document", kind: "retire", record, conversationId } (was value: null and version: undefined). Before: if (change.type === "document" && change.value !== null) use(change.value). After: if (change.type === "document" && change.kind === "change") use(change.value).

  • CompactionStatus.reason and CompactionFailure.reason in pi.live are trigger (what started the compaction; a run failure's reason is why it failed). pi.live is version 2: its migrate renames the field in a stored version 1 value when it is read, and the next commit that writes pi.live stores it at version 2, so code built against version 1 cannot read a conversation this version wrote to. Before: live.compactionFailure?.reason. After: live.compactionFailure?.trigger.

  • TaskInspection.state uses TaskState's word: { kind: "pending", migrates } (was ready). Before: state.kind === "ready". After: state.kind === "pending".

  • FileChange (FileSystem.watch() in @earendil-works/pi-durable/env) is tagged by kind: { kind: "paths", paths }, { kind: "overflow" }, or { kind: "failed", error } (was { paths }, { overflow: true }, { error }), and FileWatcher.close(context) is stop(context). Before: if ("overflow" in change) rescan(); else if ("paths" in change) reload(change.paths); await watcher.close(ctx);. After: if (change.kind === "overflow") rescan(); else if (change.kind === "paths") reload(change.paths); await watcher.stop(ctx);.

  • SessionEnd (Session.closed, Harness.closed) is tagged by kind: { kind: "closed" } or { kind: "failed", error } (was reason). Before: harness.closed.then((end) => { if (end.reason === "failed") reopen(end.error); }). After: harness.closed.then((end) => { if (end.kind === "failed") reopen(end.error); }).

  • ReportFrom, the second argument of a task's runtime.report(error, from), is tagged by kind: { kind: "extension", extension? } or { kind: "host", callback } (was type). Before: runtime.report(error, { type: "host", callback: "env" }). After: runtime.report(error, { kind: "host", callback: "env" }).

  • afterTool runs on every result a tool task writes, not only on an executed call's: also on the error results the Harness writes itself, for a tool that does not resolve (tool_unavailable), invalid arguments (invalid_arguments, with call.arguments as the model sent them), a block (blocked), an interruption (interrupted), the restart limit (restart_limit), and an abort (aborted, abandoned); the diagnostic code tells them apart. Such a result is bounded with the tool's output limits after the hooks, never keeps a structuredOutput, and applies control only when the call completes; a nested call a hook turns into a success gets its bounded output as value unless the tool declares a schema. Once a tool task was cut off more than settings.restartLimit times its hooks no longer run, nor in the last attempt the scheduler gives its abort handler, and an abort's hooks delay Conversation.abort(). A non-replay-safe tool interrupted that often now ends with restart_limit too. Hooks that assumed the tool ran (cast call.arguments, read structuredOutput) check result.diagnostics first (#11043)

  • A call to a tool its request did not offer gets a pi.tool task like any call, flagged unoffered: true in its input and its pi.live.tools slot, instead of a result the generation wrote without one: the task resolves nothing (a deferred tool the agent has still never runs), settles tool_unavailable, and runs afterTool, whose control then counts toward the round (one such call no longer prevents terminate). Its slot starts pending with a taskId instead of done, and its result entry lands in a later commit than the tool-calling answer. Controls are applied in call order. pi.tool is version 3 and pi.generation version 2 (a sequential round keeps such calls pending until their turn): an older Harness leaves both blocked (task_too_old) instead of resolving the flagged name (#11043)

  • SubmissionRecord gains a type: "continue" variant (placed without entry, done with answer, unanswered), so narrowing a record by status alone no longer guarantees an entry: check type === "input" too. A generation whose context does not end in a user message or tool results, system messages aside, now ends its run unanswered with the new RunFailureReason nothing_to_answer without a request; an empty conversation no longer faults its generation. ConversationHandle.submit() takes any SubmissionDraft (was InputSubmissionDraft), as Conversation.submit() does (#11043)

  • RunFailureReason (pi.live.runFailure.reason) gains nothing_to_answer and turn_limit, also an unanswered submission's reason: exhaustive switches over it need cases (#11043)

  • pi.live.run has a required turns field, the run's tool rounds so far; code that writes run itself sets it (turns: 0). pi.live is version 3: its migrate adds turns: 0 to a stored run without it, version 1 or a version 2 an earlier unreleased build wrote, whose run in flight otherwise failed its next tool round with "Value contains a non-finite number" (#11043)

  • A Session's close ends synchronous observers (observeDoc(), observeConversation(), observeTaskGraph(), observeCommits()) failed with the error "session closed" instead of ended, so an adapter following a Session (Chord's self.follow) fails and follows the next one; ended stays for an observed owner that ended (a task document's task), and watches still end ended. Before: end: (end) => { if (end.kind === "ended") done(); }. After: end: (end) => { if (end.kind === "ended" || end.kind === "failed") done(); }.

Added

  • StoreStorage (@earendil-works/pi-durable/storage/store): Durable's Storage on Chord v2's store. StoreStorage.open(store, owner, context) keeps a Session's records as declared tables of the store under owner and its documents in the store's documents engine, takes its ids from the store's one allocator, and stores each commit() call in one store transaction (ChordStore.commitSeries), one seq and outbox row per batch, publishing each commit in the batch of the host the store serves, so a Chord object and a Durable Session commit through one queue and one outbox. It passes the storage conformance suite; close() leaves the store open (the app owns it).

  • Deferred commits: Session.commit(), Conversation.commit(), TaskRuntime.commit(), and a tool's api.commit() take { persistence: { kind: "deferred", withinMs? } }. A commit that changes only existing conversation documents with history: "latest" and fork: "initial" is then adopted in memory and shown to watches at once, and stored with the next commit that reads or writes the document, before the document leaves memory, at close, or within withinMs (default settings.progress.persistWithinMs, or createSession(storage, { persistWithinMs })); any other write makes it immediate. A crash loses what is held. See spec §4.1.

  • Synchronous observers for adapters, such as a Chord source over a Durable view: Session.observeDoc(token, ...scope, observer, context), Harness.observeConversation(id, observer, context), and Harness.observeTaskGraph(observer, context) attach an Observer<T> (advance(change, context), end(failure)) atomically on the Session line, like a watch, and return an Observation<T> (value, detach(); observeDoc gives undefined for an absent document). advance gets every change unfolded as memory adopts it, for a stored commit when it is published after its storage call settled, and for a deferred one when memory adopts it, before it is stored, so it must only record it: no awaits, no Session calls, no throws. A document observer gets one call per change at its address (two for a commit that retires and recreates it), the task graph also a call outside any commit when a registry change or a failed migration changes a blocked reason, and a change can arrive before the attaching promise resolves. The attaching context governs only the attachment; a closed Session or an invalid argument rejects the promise. One that throws is reported as listener_error, detached, and ended with the error. end comes once, at Session close or failure, or after a task document's retirement with its task. Document, view, and task graph watches are built on them (spec §9.1).

  • ConversationTranscript keeps what a client has of one conversation over any ConversationView: merge(view) returns the view with items, the client's whole transcript (entries, a gap where a later window did not continue it, and an earlier marker until the start is loaded), instead of the window; loadEarlier(context) and fillGap(gap, context) page entries through a loader such as Conversation.entries(), and resume is the window that continues it after a drop: conversation.watch(context, transcript.resume). A merge costs O(items) and returns the same items array when it adds nothing; concurrent loads of the same page are shared (#11327).

  • pi.live.runFailure (RunFailure, RunFailureReason) records why the newest run ended without an answer, model_error, no_model, aborted, reset, faulted, or orphaned, with the run's task and inputs and a detail where one exists (the error text, the missing model, the fault, the orphan reason). The commit that ends the run sets it; a later commit that starts a run removes it (#11327).

  • RunFailureReason gains interrupted (the host stopped while the model was answering, with no retry left) and restart_limit (the run's task was cut off settings.restartLimit times in a row) (#11139).

  • onReport gets task_interrupted (reason restart_limit or interrupted, restarts, and the task) when crashes end a built-in task: a tool call, a compaction, or a generation at the restart limit, or a run that ends interrupted. The telemetry report attributes gain the type task_interrupted and the reason interrupted (#11139).

  • HarnessOptions.readOnly opens a Harness as a viewer of a session another process drives: open leaves running tasks as committed instead of recovering them, every commit with writes rejects with ReadOnlySession before it reaches Storage, and resume() and every call that would run tasks reject with it.

  • Continue submissions: submit({ type: "continue" }) starts a run on the context as it is, without a user message, for example after a run that ended without an answer (pi.live.runFailure). Only an idle conversation admits one (a busy one throws ConversationBusy; it never queues); items a failed run left queued are placed first and join the run. A context that ends in an answer, also a text answer cut off at its output limit, has nothing to continue (nothing_to_answer); a cut-off answer with tool calls is continued, as its calls end in error results. Tasks and tools submit one through ConversationHandle. The pi.durable.submit span starts a root trace for it, as for an input (#11043)

  • Per-conversation turn limits: AgentState.maxTurns (configure({ maxTurns }), null clears; a RangeError for anything but an integer 1 or more) bounds the tool rounds one run takes. The round that reaches it runs its tools, then the run ends unanswered with the new RunFailureReason turn_limit, like a failed run, so settings.afterFailedRun decides the queued inputs and a continue resumes it on the round's results. The count is pi.live.run.turns; every run starts at 0, and an onYield continuation starts it over. Task-owned children and forks inherit the limit; Agent.maxTurns exposes it (#11043)

  • whenIdle: "reject" on input submissions: an idle conversation rejects the input with the new ConversationIdle and writes nothing, so it never starts a run. With whenBusy: "steer" it steers the current run or is refused, in one admission instead of a host's check and a separate submit that can race the run's end. A known request ID still returns its submission (#11149)

  • Conversation.submit(tx, draft) admits a submission inside the caller's commit (Harness.commit(), Conversation.commit()) with the same rules as submit(draft, context), and returns its ID: a host checks its own documents and pi.live, admits, and writes its own state in one commit, which stores all of it or none. ConversationHandle.submit(tx, draft) does the same inside a task's or tool's own commit. The Harness supplies the clock, queue modes, the pi.durable.submit span (covering the admission only; its result is provisional until the commit is stored), and the request for progress. It must come before the commit's first table write, once per commit, and throws ReadAfterWrite otherwise on every path (#11149)

  • HookApi.entry() and entries(), and TaskRuntime.entries(): a hook or task reads the conversation's raw history, which compaction never changes, so a range bounded by entry IDs reads the same before and after a compaction and on a rerun (#11141)

  • Run-end tasks: a GenerationHooks.afterRun(run, api) hook returns { tasks }, built with the typed runEndTask(task, input), after a run answered (a final answer or a terminate round; not when an onYield continuation is taken, not after a failure or an abort). The answer is committed and the run's inputs settle done first, so Submission.wait() resolves at the answer; the generation then creates the tasks as its children and waits for them, keeping pi.live.run (with run.afterRun) and the conversation busy, so idle waits include them, Stop aborts them, and a crash resumes them. Input queued meanwhile, steers included, is placed when they are terminal and starts the next run; a task admits a model-visible write or a fix-run follow-up in its own commit with submit(tx, draft). A crash before the tasks exist asks the hooks again; a broken request (an uninstalled or built-in task, a non-JSON input, a throwing initial()) is reported and skipped. run names the run's entries: first (pi.live.run.first, carried into runFailure.first so a continue covers a failed run's history), answer, and last (#11141)

  • registryReader(value, context): a RegistryReader over a Chord v2 registry value whose composition is a registry snapshot (RegistryValue<RegistrySnapshot>): snapshot() reads the current composition, subscribe observes its compositions synchronously inside Chord's batch, so a Harness opened in a Chord object takes its extensions from a Chord registry.

  • GenerationHooks.beforeProviderRequest({ model, payload }, api) replaces the provider request body of a generation request, for that request only, e.g. to set a provider-specific field. The body is in the provider API's format; the hook returns { payload } or undefined. Hooks chain in extension order and run each time pi-ai builds a body; a throw is reported and the chain continues. Compaction requests do not use it (#10804)

Changed

  • Document, conversation view, and task graph watches use Chord's watch handles (Watch).
  • Group commit: a Session no longer holds its line while a commit is stored. Commits that arrive while one storage call is in flight go out together in the next call, each with its own seq and its own outcome, so the conversations of one Session share storage round trips instead of queueing behind each other's. A job runs while earlier commits are being stored until it touches a key one of them wrote (a record, a document, a conversation's entries, a task's membership or cancellation state); then it waits until that commit is stored and published. Outcomes are delivered in line order, and every job after a commit that fails the Session gets SessionFailed. One Harness serving 128 conversations over storage with a 4 ms round trip went from about 5 to about 440 agent runs per second (median run 25 s to 0.28 s); with local SQLite or the Chord store, throughput at 128 conversations rises by about 30%, while with in-memory storage and no latency each commit costs somewhat more CPU than before (up to 25% fewer runs per second). At most 256 jobs wait for their outcome. See docs/group-commit.md and spec §4.
  • A stored commit is published after its storage call settled, in line order, the commits of one call a macrotask apart (inside the storage's publishing() scope if it has one): the read caches and memory adopt it, then its telemetry events and Durable's own observers (document watches, conversation views, the task graph, the scheduler, and waits) run, so two views never show one commit apart. observeCommits() observers run one microtask later, before every wait the commit resolves and every abort signal it fires; they have no order relative to watch listeners and onWake. A call that settles after something else failed the Session publishes nothing; what it stored is durable and appears after reopen.
  • A normal agent run makes no storage reads: the Session keeps recently read conversation, task and submission records (bounded by count, and by live work for tasks), the newest entry of each conversation, and the task documents of live tasks, and the scheduler keeps the context range of a running conversation. Read results (tx.task(), tx.conversation(), getTask(), runtime.entry(), published entries) are frozen objects shared with these caches; mutating one throws.
  • A tool slot's running status and a nested call's final arguments, and a generation's attempt, are stored with the next commit, like streamed progress: a run with one tool call stores 12 commits instead of 14. After a crash a slot may show pending while its task's checkpoint is at execution; the rerun sets it again.
  • A wait whose commit is still being stored when the Harness closes ends with the closed error; the commit is still stored and published before close completes.
  • Cancellation is checked when a job starts, which can be earlier than before: an invocation-bound submit queued behind an abort mark that is not stored yet lands, and the abort's cascade then aborts its run.
  • The scheduler's per-commit work no longer grows with the number of conversations: after a commit it re-checks idleness only for the conversations above the tasks that became live or ended, expires idle context ranges from an expiry-ordered index, and wake() takes the earliest sleep from the sleeping tasks and scans live tasks only while nothing runs. Before, every commit re-walked every conversation read in the last contextRetentionMs (default 10 minutes). One Session with 2048 conversations went from 100 to 805 agent runs per second (4096: 46 to 772; local SQLite at 2048: 88 to 459), with CPU per run flat at about 1.6 ms instead of growing linearly.
  • subscribeCommits() listeners are read when a commit's dispatch runs: a listener added between publication and the dispatch gets the commit only when one was registered at adoption; one added after the dispatch ran misses it.
  • The abort signal of a newly marked running task fires after subscribeCommits() listeners instead of before them.
  • A throwing Durable commit observer fails the Session after Storage.commit() returned, after the other observers and the host listeners got the commit; the commit still stands. When Storage also rejects that commit after adopting it, the storage error fails the Session and the observer's error is reported as listener_error.

Fixed

  • Fixed a tool round with control.handoff ending the run on the tool-calling answer: the handoff's pi.reset entry is written and the same run continues with a new generation in the new context, so the submission settles with the eventual answer. Queued writes and selected steers are placed after the handoff text, follow-ups wait for the run's final boundary, and a queued reset still ends the run unanswered with reason reset. terminate remains the way to end a round without another model request.
  • Fixed a conversation watcher (conversation views) holding a copy of a streamed text or tool call per partial commit, through Chord append ops that kept the whole string alive; a 140 KB answer followed by a 140 KB tool call held well over 100 MB (#9265)
  • Fixed a nested call's error summary keeping the call's whole output alive through a slice of it (#9265)
  • Fixed task span error messages and codemode call previews keeping the whole text they were cut from alive (#9265)
  • Fixed partial commits of a streamed answer copying every growing text, thinking and tool-call argument string in full on each commit (about 20 s of CPU and a 100 MB heap peak for a 500 KB tool call): they now append new text with Chord's appendText(), and apply the argument changes of their own parse of the streamed argument text (#9265)
  • Fixed stored assistant messages lacking thinkingLevel: a generation records the Pi thinking level its request asked for on the response, also after polling a deferred one, as pi-agent-core's agent loop does
  • Fixed partial commits polluting Object.prototype when a streamed tool call's arguments gained a __proto__ member after an earlier commit: the merge read the missing member through to Object.prototype and wrote into it
  • Fixed a commit that Storage rejects after adopting it (a failed JSONL reclaim) publishing nothing: it is published and its waits resolve before the Session fails, so a replica built from subscribeCommits() stays equal to Storage and pi.durable.tasks.active stays balanced.
  • Fixed a throwing telemetry adapter (a commit's pi.durable.entry or pi.durable.submission event, pi.durable.tasks.active) rejecting a durable commit and leaving the views and the scheduler without it: it is reported as host_error with callback "telemetry", and the commit resolves. A throwing report metric or report event is dropped.
  • Fixed a host that crashes during a model request resending it forever, adding an aborted entry each time: the interrupted request is a failed attempt under the retry policy, and the run ends with runFailure reason interrupted once no retry is left; other work cut off restartLimit times ends instead of keeping its conversation busy (#11139)
  • Fixed the built-in read resolving to "" for an image in Code Mode scripts, so image(await tools.read(...)) threw: read declares a structuredOutputSchema, a text file's text or an image's ImageContent, as the coding agent's read does (#11015)
  • Fixed the Code Mode extension loading pi-codemode's WASM QuickJS runtime (quickjs-wasi) although it only runs scripts in the sandbox the host passes: it imports toCodemodeIdentifier from @earendil-works/pi-codemode/declarations instead of /portable (#11254)
  • Fixed tool_search and Code Mode's searchTools() ranking a tool below tools that only mention its name, as the coding agent did before #11440 and #11625: thread_read with limit: 1 returned queue_read, and peekaboo app missed mcp__peekaboo__app. Both now rank like the coding agent: a query that is exactly a tool's name ranks it first, a tool matching more of the query's words ranks above one matching fewer, a query word in the name outweighs any number of mentions in the description, and a tool whose whole name is in the query gets a large bonus. searchTools() also searches namespace instructions, as a low-weight field that does not lower a tool's score (#11331)
  • Fixed tool_search and Code Mode's searchTools() finding nothing for Chinese, Japanese, Thai, and other non-ASCII queries, because the tokenizer kept only ASCII letters and digits. Words in any script now match, text without spaces between words such as 搜索记录 is split into words, and canonically equivalent text such as café and cafe\u0301 matches (#10816, #11037 by @haoqixu)

[1.4.0] - 2026-10-21

Breaking Changes

  • TaskRuntime.sleep() is removed: it waited inside a phase, which holds an invocation and, after a restart, reruns the phase and restarts the wait. A task now ends its phase asleep with runtime.sleepUntil(until, checkpoint, context) or by returning { status: "sleeping", until, checkpoint } from runtime.commit(); move the work after the wait into the next phase and carry what it needs in the checkpoint. TaskRuntime.setTimer() paces work inside a phase without waiting for it.
  • Tasks have a sleeping status, so code that handles every TaskState, TaskGraphState, or TaskInspection state needs a case for it.
  • Opening a SQLite storage migrates it to schema version 2 automatically, rebuilding its task table. A migrated database cannot be opened by 1.3.0 or earlier, so a deployment cannot roll back past this release. JSONL storage needs no migration, but 1.3.0 or earlier never resumes a sleeping task it finds (a run's conversation stays busy).
  • TaskRuntime has sleepUntil() and setTimer(), and ToolExecutionApi has now(): code that builds either object by hand, such as a test fake or a tool wrapper that does not spread the original, must add them.
  • A task cut off by a crash 5 times in a row without committing a new state is parked instead of run again (see the crash-loop guard under Added); set settings.restartLimit to Infinity to keep the old behavior. TaskInspection's blocked reasons include restart_limit.
  • defineDoc() and defineDocFamily() require an explicit checkpointWhen predicate on every definition; there is no default. Use () => false to keep ordinary changes as deltas, or supply a policy that periodically writes a base.

Added

  • Added IndexedDbStorage (@earendil-works/pi-durable/storage/indexeddb), a browser storage backed by IndexedDB.
  • HarnessOptions.telemetry emits the content-free DURABLE_TELEMETRY_SCHEMA: public submission admission spans, task phase spans (including extension tasks), committed entry and submission events, running phase-change checkpoints, and nested-tool replay events. Optional propagation stores opaque carriers on submissions and tasks so queued inputs and reopened tasks retain their trace; TaskOptions.trace accepts a carrier override or "root" (absence inherits the creator's carrier); creation-time links connect inputs sharing a run, while steer admissions link to the running trace. Internal admissions emit events without a submit span. Optional metrics record phase duration and live task counts. Failed phases record fixed error-status categories (task_faulted, task_failed, task_orphaned) and diagnostics capped at 500 characters; aborted phases keep status ok. Every onReport report also emits a fixed-field pi.durable.report event on its current span (dropped by the NOOP span when there is none), plus a pi.durable.reports counter by type; report telemetry contains no error payload and leaves the callback unchanged. Clock failures report without a phase context. Generation and compaction forward their phase context to pi-ai requests.
  • settings.compaction.modelOverrides sets compaction thresholds per model, keyed by exact "provider/modelId", so one harness can serve small- and large-window models; the threshold check, overflow recovery, and the compaction task use the entry of the model they act for (#10942).
  • Durable sleeps: a sleeping task holds no invocation, survives restarts, and resumes at its checkpoint once the Harness clock reaches until.
  • HarnessOptions.setTimer arms the timers of the Session, the scheduler, and its tasks (progress throttles, idle-memory eviction, sleeps), also for createSession(); with now, they run on a host or fake clock. A foreground timer the host throws on or declines falls back to setTimeout. ToolExecutionApi.now() reads the Harness clock.
  • Harness.wake() and HarnessOptions.onWake tell a host when the Session next needs a process: active while work can run, at for the earliest sleep. With onWake, the Harness keeps no timer for sleeps, so a Cloudflare Durable Object can hibernate and wake on its alarm, calling resume().
  • Crash-loop guard: open counts the restarts of each task that a crash, eviction, or reset cut off (TaskRecord.restarts); a close writes the tasks it stopped back as pending uncounted, and a new state the task commits starts the count over. At settings.restartLimit the task is parked: blocked with reason restart_limit in inspect() and the task graph, not active in wake(), and reported once. Harness.retryTask(id) runs it again. An abort handler cut off that many times ends its task faulted.
  • onReport(error, info): info (ReportInfo) says what happened in type: session_failed; task_faulted, task_parked, migration_failed, task_outdated, or task_error with the task and the extension that installed it; extension_error with the extension's name; host_error with the failing HostCallback; or listener_error.
  • settings.afterFailedRun: a run that fails with model_error or no_model keeps the inputs queued behind it (keep, the default), starts the next run with them (continue), or settles them unanswered with reason run_failed (withdraw).
  • The task graph shows why a task cannot run (TaskGraphNode.blocked: missing_task, task_too_old, migration_failed, or restart_limit) and follows registry changes and failed migrations.
  • Added HarnessOptions.identity (a pi-ai ClientIdentity) to set the User-Agent and provider attribution of every model request through the Harness, including hooks and tools. api.models in tools and hooks is now a wrapper of the host's Models that adds the identity, not the same object.
  • HarnessOptions.models and HarnessOptions.settings also accept a function returning the current value, like env. Generation, compaction, hooks and tools call it at each use (api.models reads the current value at each access), so a host can replace its model configuration or settings without reopening the Harness. A plain object still works.

Changed

  • A task phase that faults is reported through onReport (as task_faulted), not only recorded in its outcome.
  • onReport gets a second argument, info, and TaskRuntime.report() takes an optional from (see Added); an onReport written for one argument still works.
  • Generation retry backoffs, deferred-response polls, and compaction retry backoffs sleep instead of waiting in a running phase, so a process can stop or hibernate during them. A record an earlier version stored mid-backoff sleeps again when it resumes before its time. A deferred poll whose model is gone after a reopen now fails no_model once the poll is due, not at once.
  • Code mode measures script deadlines and wall time on the Harness clock (HarnessOptions.now) instead of Date.now().
  • SQLite drivers, portable interfaces, and the generic migration runner now come from @earendil-works/chord/sqlite. Existing Durable SQLite entry points keep re-exporting their public names; storage helpers and Durable schema migrations stay here.
  • ToolControl.terminate is now typed boolean instead of true, matching pi-agent-core and pi-coding-agent; false does not end the run (#10858).

Fixed

  • In Cloudflare Workers with nodejs_compat, the timers that evict idle documents and contexts were armed, since timers there have an unref(); a pending one kept a Durable Object from hibernating and blocked its eviction. They are now declined in Workers, and memory is freed at later commits.
  • The README's Errors section now limits the StorageRequestError exemption to reads: a StorageRequestError thrown by commit() or mintId() fails the Harness like any other storage error (#11014).
  • The Node environment now detects the legacy WSL bash.exe launcher from %SystemRoot% instead of assuming C:\Windows (#9501 by @petrroll).

[1.3.0] - 2026-10-15

Added

  • SqliteStorage.open(database, { prefix }) can namespace every table and index; openNodeSqliteStorage() and openDurableObjectSqliteStorage() forward it, for databases shared with host tables.

Changed

  • Cloudflare Durable Object SQLite adapters created for the same storage object now coordinate their operations, allowing multiple Pi storages to safely share one Durable Object database.

Fixed

  • The system baseline written after a compaction now leads the model context when the kept history includes an assistant message, as does a first baseline written after earlier answers, instead of following the new input; Anthropic and OpenAI Codex requests sent it as a mid-conversation system message without an initial prompt or tool set. Other system messages after an assistant message stay in place (#10904).
  • toBase64, used by read and the Photon image processor, no longer takes about 140 MB of heap to encode a 3 MiB image, which exceeded the 128 MB memory limit of a Cloudflare Durable Object; it now builds a binary string 8 KiB at a time and encodes it with btoa (#10923).

[1.2.0] - 2026-10-12

Breaking Changes

  • ToolTaskInput and ToolTaskResult are tagged unions: a model-issued call is { kind: "model", ... } with its previous fields, a nested call { kind: "nested", ... }. pi.tool is version 2 and migrates live version 1 tasks.
  • ToolExecutionResult.content is now output, next to the new structuredOutput.
  • bash and powershell answer a nonzero exit with an error result carrying an exit_code diagnostic, instead of throwing (tool_error).
  • Any error a Storage method throws, a read included, now fails the Session, which closes itself: every later call and every pending wait rejects with SessionFailed, whose cause is that error, and nothing is retried. StorageRejected is removed; a storage retries its own transient failures and throws the new StorageRequestError for an invalid request, which fails only that call. A throw in the scheduler's own commits, or in the commit listeners of the Harness's components, fails the Session too.
  • subscribeCommits() and subscribeClose() listeners that throw, or return a rejected promise, are reported through onReport instead of failing the operation that ran them.
  • A display-only write submission, one of only kind and data (no model, head, or edits), is appended and settled done at once, even while the conversation is busy or has queued items, instead of waiting in pi.inbox for the next boundary; only a queued reset still holds it back, so the reset does not hide it. It changes nothing the model sees, so a chat message shows as soon as it is sent, ahead of earlier submissions still queued, and it no longer places items left queued after a failed run (#10407).

Added

  • Optional ExecutionEnv.listFiles(path, options, context) for bounded, gitignore-aware tree listings (ListFilesOptions, FileListing, FileListEntry); registerEnvConformance takes a listFiles option to cover it.
  • Input submissions take entry: { kind, data } (InputEntry): the input is placed as an entry of that kind carrying that data, with its content as the user message, instead of pi.user, and behaves as any other input; the kind must not start with pi.. Queued inputs carry it in their pi.inbox item (#10407).
  • Session.closed settles once the Session has closed, Storage included: { reason: "closed" } after close(), or { reason: "failed", error } after a storage error. WatchEnd gains { reason: "session_failed", error }, and the README has an Errors section.
  • ToolExecutionApi.executeTool(name, args, context, { key?, progress? }): a tool calls another tool as a nested call. The nested call is its own pi.tool task owned by the caller, runs validation, the ToolTask hooks (whose ToolHookCall carries parent), output limits, and its replay policy, and returns a NestedToolExecutionResult (its taskId, structuredOutput, details, diagnostics, usage, isError, durationMs, but not the model's output) to the caller instead of the transcript. Each nested call is a member of NestedCallDoc, a task-scoped document family of the caller keyed by the call's key, holding its taskId and, once it ends, its result as returned, so it is gone from storage once the caller settles; its task's receipt stays small. Keys, by default the call's position, let a replay-safe caller's rerun reattach to its nested calls; a caller that is not replay-safe has its unfinished nested calls abandoned after a restart. Nested calls show in pi.live.nestedTools, with the arguments they run with and a summary (error, duration, usage) once done (progress: false keeps their running output out), and as tool events with parentToolCallId and parentTaskId; every tool event also carries its call's taskId. A caller aborts the nested calls it left running before it settles.
  • Structured tool output: a tool declares structuredOutputSchema and returns structuredOutput, which the Harness validates and gives to programs that call the tool; a tool without a schema gives them its bounded output, one text item as a string, one image as itself, and otherwise the content list, for errors too. structuredOutput is always the tool's own value: a schema tool's error result keeps the value it returned, and the text of one without becomes a tool_error diagnostic of the nested result, as a thrown error's message does. A nested call with invalid structured output gets an error result; a model-issued one only loses it, and the host gets a report. api.retainedOutput() reads the bounded output the model will see. bash and powershell return { output, truncated, fullOutputPath?, exitCode }.
  • ToolRegistration.callers (model, tools, or both, the default) and pi.agent modelTools: who may call a tool, and which of its tools a conversation offers the model; Agent.callable lists the tools nested calls resolve among. addTools also extends modelTools.
  • Deferred tools: ToolRegistration.deferred keeps a tool from the model until modelTools names it, in its array or its new add ({ remove?, add? }); control.addTools writes names to add, and loaded tools follow the others in load order, so a load only appends declarations. Agent.deferred lists the deferred tools not loaded yet. @earendil-works/pi-durable/tool-search provides the coding agent's tool_search tool, which searches them with BM25 and loads the matches. The codemode section leaves deferred tools out.
  • TaskOptions.abandonOnRestart: a task its creator awaits only in memory is aborted, with its owned work, when a later Harness starts scheduling, before any of it runs again. Its mark carries abortReason: "restart", which cascades; such a task waits for a missing definition instead of becoming orphaned. Nested calls and api.createTask() children of tools that are not replay-safe get it by default. No task below an owner with cancellation intent starts a run phase any more, even before the cascade marks it.
  • TaskRuntime.abortOwned(id, context): abort a task this task owns and wait until it is terminal.
  • TaskRuntime.ownedTasks(context): the live tasks a task owns directly, whichever invocation created them, as copies. A tool call settling finds the nested calls it left running with it.
  • @earendil-works/pi-durable/codemode: a codemode tool (createCodemodeExtension({ sandbox })) whose scripts call the conversation's tools as nested calls and survive a restart: the script is replayed deterministically from a journal of the results it got, written before each delivery, reattaching to its nested calls, and then continues. Divergence, a changed sandbox fingerprint or module version, and a passed deadline end the call with an error. As in the coding agent, a codemode prompt section lists the tools scripts can call (namespaces, an inline token budget), scripts find tools with searchTools(), describeTool(), and describeNamespace(), and the result is laid out with a header, text item markers, a console block, truncation to max_output_tokens with a spill file, and saved images. Scripts get models.* (the catalog, models.classify(), models.generateImages(); the last two as nested calls of internal tools, at most four at once), and the tool declares the Lark grammar of its source for models that support grammar-constrained sampling. A failed call rejects in the script with its text, except an error result of a schema tool with its own value, which resolves: tools.bash gives { output, exitCode, ... } for a nonzero exit. Scripts keep store()/load() values per conversation, forked as of the fork's entry. The result's details.calls list the script's tool calls with their status; live progress is in pi.live.nestedTools (npm run bench:codemode).
  • read returns images as one image block instead of an unsupported_image error: PNG, JPEG, GIF, and WebP within the model's image limits (by default 2000x2000 pixels and 4.5 MB of base64) as they are, or, with createCodingTools({ images }), oriented, converted, and shrunk to fit. @earendil-works/pi-durable/images provides a Photon (WebAssembly) image processor, with /images/node and /images/cloudflare loaders; /images/node prepares images in a worker thread, so a large photo never blocks the event loop, and the thread exits after 30 s without images; nothing loads it unless imported. A model without image input gets a diagnostic saying it sees a placeholder.
  • pi.live.compactionFailure keeps the newest compaction failure (task, reason, error) until a compaction produces a summary; the agent events' snapshot carries it as compactionFailure, and compaction_end carries error for a compaction that failed. A failed background or manual compaction was invisible once its status was removed.

Fixed

  • A wait that closes a cycle through waits and held owners is rejected by runtime.commit(), naming the cycle, instead of leaving every task on it waiting forever; waiting on itself or on an owner chain were the only cycles caught. A background task may now wait on the owner of its conversation, which is no cycle (#10411; tests and approach from #10533 by @odysseus0)

  • Appending to an array in a document no longer costs a walk over the whole array per commit: Chord's delta tracker plans inserts and removals that keep the remaining elements in order from the changed ranges alone, and builds an appended array in one copy instead of two. 32,000 one-item appends, one commit each, take 1.4 s instead of 11.3 s; what remains is the copy each immutable value needs (npm run bench:document-append).

  • A generation whose blocking threshold compaction failed, faulted, was orphaned, or was aborted directly now fails with model_error (Compaction failed: <error>) instead of sending its request anyway. The context was still above the blocking threshold, so the request at best left no room for the answer: a session at 996K of a 1M window got an empty length answer on every turn, with no visible error.

  • Compaction no longer includes thinking in the summarization request. Replayed thinking is often not in the live context, so a request that included it could be larger than the context it summarized and fail with "prompt is too long" on every attempt.

  • A throwing onReport no longer replaces the error being reported or becomes an unhandled rejection, a throwing now() is reported once and Date.now used, and a watch listener's error is reported as well as ending the watch with listener_error.

  • A task whose fault write failed no longer runs again in the same process.

  • The scheduler no longer visits every live task on each pass: abort cascades start only from tasks with cancellation intent, owned live work and idle scopes are walks down an in-memory ownership index, and reservation, finalization, and failFast checks keep their own candidate sets. A chain of 500 owned tasks that took 12 s to settle takes 50 ms, 20,000 take 1.5 s; a tool making 8000 parallel nested calls finishes in 2.7 s instead of 18.8 s, with one document per nested call instead of one growing index (npm run bench:scheduler-fanout).

  • The scheduler's ownership indexes are bounded by live work: it keeps a conversation's owner and an ended task's ownership only while live work is below them, instead of every conversation and subagent chain it ever saw. Work that later appears in an old conversation loads its chain from storage again. After 10,000 ended subagent calls under a live parent it kept 10,000 ended tasks and 10,001 conversation edges; now none of either beyond the parent's conversation (npm run bench:scheduler-memory). A queued input no longer makes the scheduler scan every queued submission when nothing is being cancelled.

  • The Session's document cache is bounded by use: a loaded document that no watch or document state observes leaves memory once it was not read or written for documentRetentionMs (new in HarnessSettings and createSession() options; default ten minutes, 0 drops it right after use) and loads from Storage again on its next access. It held every conversation and session document ever touched, built-in and third-party, for the life of the process: 5,000 conversations kept 26,000 documents and about 3.8 KB each; with retention 0 they keep none (npm run bench:document-cache).

[1.1.0] - 2026-10-07

Breaking Changes

  • Storage implementations must honor the new order field of ConversationQuery, EntryQuery, TaskQuery, and SubmissionQuery, and continue a cursor in the order it was returned with. A storage that ignores it returns pages in the wrong direction; the conformance suite covers both orders (#10546).
  • TaskRuntime.context() takes the cutoff as an options object, matching Conversation.context(): runtime.context(conversationId, context, { at }) replaces runtime.context(conversationId, context, at).

Added

  • ToolExecutionApi.models and HookApi.models: the Harness's models, so tools and hooks can resolve models and make requests with the same catalog, credentials, and request transforms as generation (#10395).
  • Conversation.context(context, { at }) returns the model context as of a visible earlier entry, the same view fork(at) would start with, without creating a conversation (#10512).
  • ScanOrder (ascending or descending) as order on conversation, entry, task, and submission scans, including Tx.scanTasks() and Conversation.entries(), so hosts can page the newest tasks first. Defaults are unchanged: entries newest first, everything else oldest first. A cursor continues in its scan's order, so the query may omit order; asking for the other order with it throws (#10546).
  • Task records carry startedAt and endedAt, wall-clock times the Session stamps at the first change to running and at the change to terminal, with HarnessOptions.now or the new createSession(storage, { now }) option. startedAt survives waits and reopen. inspect() shows them on each live task's record. Records written by earlier versions have neither (#10549).
  • pi.tool-result messages carry durationMs: how long execute() took in that attempt, measured with a monotonic clock. Calls that did not execute, and interrupted or aborted calls, have none (#10549).
  • Assistant messages carry the durationMs pi-ai measures for each response (#10549).
  • openDurableObjectSqliteStorage(ctx.storage) in @earendil-works/pi-durable/storage/sqlite/cloudflare: SQLite storage on a SQLite-backed Cloudflare Durable Object.
  • settings.contextRetentionMs (default ten minutes): how long an idle conversation keeps its last context read in memory; 0 drops it once idle.

Changed

  • runtime.context() keeps each conversation's last read range and derived view in memory: a later read by any of its tasks with the same head marker scans and derives only the entries committed since. A generation no longer rereads and re-derives the whole transcript for each model request. Busy conversations keep it; idle ones for settings.contextRetentionMs.

Fixed

  • A conversation's first system message, and the baseline after a compaction or reset, now leads the model context instead of following the input that started the run. Providers with native mid-conversation tool changes, such as Anthropic, keep the prompt cache across later tool changes instead of rewriting it in full (#10542).

[1.0.4] - 2026-10-05

Breaking Changes

  • NodeExecutionEnv.watch() fails with permission_denied when a target, or a watched directory itself, cannot be read for lack of permission; before, it was watched as if missing. Later rescans that hit this report { error } with permission_denied instead of invalid.
  • The env conformance suite checks three more watch() behaviors: changes to the file a watched symbolic link points to, recursive coverage below a target that a non-recursive target overlaps, and a directory replaced at the same path. Custom environments that passed the 1.0.3 suite may need changes.

Added

  • createPowerShellTool() in @earendil-works/pi-durable/tools: a powershell tool that runs pwsh, else Windows PowerShell, directly through argv exec (no other shell parses the command), with UTF-8 output and the bash tool's output window, spill and errors.

Fixed

  • The read tool reads a file that grows while it is read (an active log) instead of failing with "changed while it was read"; it reads again only when the file shrank or was rewritten in place.
  • NodeExecutionEnv.watch(): a directory replaced at the same path gets a new native watcher; a target that is a symbolic link to a file reports changes to that file; a non-recursive target no longer stops an overlapping recursive target from covering subdirectories; closing during a rescan no longer leaks watchers.
  • Bounded tool output keeps a U+FEFF at the start of the retained tail, and drops a byte-order mark only at the very start of byte output.
  • settings.progress fields given as undefined keep their defaults.

[1.0.3] - 2026-10-05

Breaking Changes

  • FileSystem requires openBinaryReader() and openDirReader(); custom environments must implement them.
  • BinaryReader requires scanLines().
  • FileSystem requires watch().
  • Shell.exec() accepts an argv array besides a shell string, and ShellExecOptions.onOutput receives a third info argument naming the stream (stdout or stderr); custom environments must accept both forms and pass the stream.

Added

  • openBinaryReader() for bounded positional reads of one opened regular file, with noFollow to refuse a final-component symlink.
  • openDirReader() for paged directory listings that read metadata only for returned entries.
  • Argv form of exec(), which runs a program without a shell.
  • createEnvConformance() and registerEnvConformance() in @earendil-works/pi-durable/testing for checking custom ExecutionEnv implementations.
  • settings.progress with partialIntervalMs and outputIntervalMs configures how often generation partials and running tool output are committed; defaults stay 100 ms (#10357)
  • ShellExecOptions.window and ShellOutputInfo.skipped: an environment may omit shell output outside the caller's retained tail and report the omission, so remote environments need not transfer output the caller drops. ToolExecutionApi.outputWindow provides the window and output(chunk, skipped) counts omissions; the bash tool passes them through.
  • BinaryReader.scanLines() locates and measures a span of lines in one pass inside the environment; LineScanner, StreamDecoder, rangeDecoder() and startsWithBom() in @earendil-works/pi-durable/env let other environments decode and scan exactly like NodeExecutionEnv.
  • FileSystem.watch() reports changes to files and directories, recursive with excludes, including missing targets, with explicit overflow and error and a native or polling mode. NodeExecutionEnv polls on Windows (native watchers there keep directories open, which blocks renaming their parents) and on network and FUSE file systems, and on macOS rescans shortly after installing native watchers because FSEvents misses changes made right after fs.watch returns; its watch option sets the mode, poll interval, and directory limit.

Changed

  • The read tool reads only the file's header, one scan, and the lines it shows, instead of loading the whole file; its results are unchanged.

Fixed

  • NodeExecutionEnv.flushFile() on a directory fails with is_directory on Windows, as on POSIX.
  • Tail-retained tool output no longer depends on when progress commits happened: a progress snapshot compacted the stored output to the kept window, which could move where a later window's first line started.
  • NodeExecutionEnv shell output and text line readers no longer drop a U+FEFF that follows a chunk boundary; Node's streaming TextDecoder with BOM handling dropped it, unlike decoding all of the bytes at once.

[1.0.2] - 2026-10-04

Fixed

  • Persisted a distinct provider session UUID per conversation and forwarded it for prompt-cache and session affinity (#10424)

[1.0.1] - 2026-10-03

[1.0.0] - 2026-10-01

Added

  • Initial release of @earendil-works/pi-durable, a durable agent harness. See the README and the design document.