Imported as a linear vendor commit so forge rebases do not replay the upstream root tree. git-subtree-dir: third_party/pi git-subtree-split: 71023aec1546d6d677a65669c5665c0927ce0dd0
22 KiB
Changelog
[1.3.0] - 2026-10-15
Added
SqliteStorage.open(database, { prefix })can namespace every table and index;openNodeSqliteStorage()andopenDurableObjectSqliteStorage()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 byreadand 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 withbtoa(#10923).
[1.2.0] - 2026-10-12
Breaking Changes
ToolTaskInputandToolTaskResultare tagged unions: a model-issued call is{ kind: "model", ... }with its previous fields, a nested call{ kind: "nested", ... }.pi.toolis version 2 and migrates live version 1 tasks.ToolExecutionResult.contentis nowoutput, next to the newstructuredOutput.bashandpowershellanswer a nonzero exit with an error result carrying anexit_codediagnostic, instead of throwing (tool_error).- Any error a
Storagemethod throws, a read included, now fails the Session, which closes itself: every later call and every pending wait rejects withSessionFailed, whosecauseis that error, and nothing is retried.StorageRejectedis removed; a storage retries its own transient failures and throws the newStorageRequestErrorfor 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()andsubscribeClose()listeners that throw, or return a rejected promise, are reported throughonReportinstead of failing the operation that ran them.- A display-only write submission, one of only
kindanddata(nomodel,head, oredits), is appended and settleddoneat once, even while the conversation is busy or has queued items, instead of waiting inpi.inboxfor 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);registerEnvConformancetakes alistFilesoption 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 ofpi.user, and behaves as any other input; the kind must not start withpi.. Queued inputs carry it in theirpi.inboxitem (#10407). Session.closedsettles once the Session has closed, Storage included:{ reason: "closed" }afterclose(), or{ reason: "failed", error }after a storage error.WatchEndgains{ 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 ownpi.tooltask owned by the caller, runs validation, theToolTaskhooks (whoseToolHookCallcarriesparent), output limits, and its replay policy, and returns aNestedToolExecutionResult(itstaskId,structuredOutput,details,diagnostics,usage,isError,durationMs, but not the model'soutput) to the caller instead of the transcript. Each nested call is a member ofNestedCallDoc, a task-scoped document family of the caller keyed by the call's key, holding itstaskIdand, once it ends, itsresultas 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 inpi.live.nestedTools, with the arguments they run with and asummary(error, duration, usage) once done (progress: falsekeeps their running output out), and as tool events withparentToolCallIdandparentTaskId; every tool event also carries its call'staskId. A caller aborts the nested calls it left running before it settles.- Structured tool output: a tool declares
structuredOutputSchemaand returnsstructuredOutput, 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.structuredOutputis always the tool's own value: a schema tool's error result keeps the value it returned, and the text of one without becomes atool_errordiagnostic 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.bashandpowershellreturn{ output, truncated, fullOutputPath?, exitCode }. ToolRegistration.callers(model,tools, or both, the default) andpi.agentmodelTools: who may call a tool, and which of its tools a conversation offers the model;Agent.callablelists the tools nested calls resolve among.addToolsalso extendsmodelTools.- Deferred tools:
ToolRegistration.deferredkeeps a tool from the model untilmodelToolsnames it, in its array or its newadd({ remove?, add? });control.addToolswrites names toadd, and loaded tools follow the others in load order, so a load only appends declarations.Agent.deferredlists the deferred tools not loaded yet.@earendil-works/pi-durable/tool-searchprovides the coding agent'stool_searchtool, which searches them with BM25 and loads the matches. Thecodemodesection 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 carriesabortReason: "restart", which cascades; such a task waits for a missing definition instead of becomingorphaned. Nested calls andapi.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: acodemodetool (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, acodemodeprompt section lists the tools scripts can call (namespaces, an inline token budget), scripts find tools withsearchTools(),describeTool(), anddescribeNamespace(), and the result is laid out with a header, text item markers, a console block, truncation tomax_output_tokenswith a spill file, and saved images. Scripts getmodels.*(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.bashgives{ output, exitCode, ... }for a nonzero exit. Scripts keepstore()/load()values per conversation, forked as of the fork's entry. The result'sdetails.callslist the script's tool calls with their status; live progress is inpi.live.nestedTools(npm run bench:codemode).readreturns images as one image block instead of anunsupported_imageerror: 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, withcreateCodingTools({ images }), oriented, converted, and shrunk to fit.@earendil-works/pi-durable/imagesprovides a Photon (WebAssembly) image processor, with/images/nodeand/images/cloudflareloaders;/images/nodeprepares 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.compactionFailurekeeps the newest compaction failure (task, reason, error) until a compaction produces a summary; the agent events' snapshot carries it ascompactionFailure, andcompaction_endcarrieserrorfor 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 emptylengthanswer 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
onReportno longer replaces the error being reported or becomes an unhandled rejection, a throwingnow()is reported once andDate.nowused, and a watch listener's error is reported as well as ending the watch withlistener_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 inHarnessSettingsandcreateSession()options; default ten minutes,0drops 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
Storageimplementations must honor the neworderfield ofConversationQuery,EntryQuery,TaskQuery, andSubmissionQuery, 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, matchingConversation.context():runtime.context(conversationId, context, { at })replacesruntime.context(conversationId, context, at).
Added
ToolExecutionApi.modelsandHookApi.models: the Harness'smodels, 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 viewfork(at)would start with, without creating a conversation (#10512).ScanOrder(ascendingordescending) asorderon conversation, entry, task, and submission scans, includingTx.scanTasks()andConversation.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 omitorder; asking for the other order with it throws (#10546).- Task records carry
startedAtandendedAt, wall-clock times the Session stamps at the first change torunningand at the change toterminal, withHarnessOptions.nowor the newcreateSession(storage, { now })option.startedAtsurvives waits and reopen.inspect()shows them on each live task's record. Records written by earlier versions have neither (#10549). pi.tool-resultmessages carrydurationMs: how longexecute()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
durationMspi-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;0drops 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 forsettings.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 withpermission_deniedwhen 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 }withpermission_deniedinstead ofinvalid.- 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: apowershelltool that runspwsh, else Windows PowerShell, directly through argvexec(no other shell parses the command), with UTF-8 output and thebashtool's output window, spill and errors.
Fixed
- The
readtool 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.progressfields given asundefinedkeep their defaults.
[1.0.3] - 2026-10-05
Breaking Changes
FileSystemrequiresopenBinaryReader()andopenDirReader(); custom environments must implement them.BinaryReaderrequiresscanLines().FileSystemrequireswatch().Shell.exec()accepts an argv array besides a shell string, andShellExecOptions.onOutputreceives a thirdinfoargument naming the stream (stdoutorstderr); custom environments must accept both forms and pass the stream.
Added
openBinaryReader()for bounded positional reads of one opened regular file, withnoFollowto 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()andregisterEnvConformance()in@earendil-works/pi-durable/testingfor checking customExecutionEnvimplementations.settings.progresswithpartialIntervalMsandoutputIntervalMsconfigures how often generation partials and running tool output are committed; defaults stay 100 ms (#10357)ShellExecOptions.windowandShellOutputInfo.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.outputWindowprovides the window andoutput(chunk, skipped)counts omissions; thebashtool passes them through.BinaryReader.scanLines()locates and measures a span of lines in one pass inside the environment;LineScanner,StreamDecoder,rangeDecoder()andstartsWithBom()in@earendil-works/pi-durable/envlet other environments decode and scan exactly likeNodeExecutionEnv.FileSystem.watch()reports changes to files and directories, recursive with excludes, including missing targets, with explicitoverflowanderrorand anativeorpollingmode.NodeExecutionEnvpolls 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 afterfs.watchreturns; itswatchoption sets the mode, poll interval, and directory limit.
Changed
- The
readtool 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 withis_directoryon 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.
NodeExecutionEnvshell output and text line readers no longer drop a U+FEFF that follows a chunk boundary; Node's streamingTextDecoderwith 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.