Skip to content

PiSharp 1.2.0.1

Choose a tag to compare

@github-actions github-actions released this 17 Oct 02:19
· 995 commits to main since this release
b2a558a

PiSharp 1.2.0.1

A C#-only release on the Pi v1.2.0 baseline (commit
06a466935536f8c9bcacb2d5efc0fc021be1bdff). It adds PiSharp's experimental port of Pi's
durable agent harness: the pisharp durable command and three NuGet libraries. Nothing
else changes; pisharp without durable behaves as in 1.2.0.

The Parity page lists what still differs from Pi.
Decision 0005 records the scope of the port,
its differences from Pi and the owner's decision to release it.

Experimental: Pi Durable

Pi includes pi-durable, an experimental harness that commits every model turn, streamed
partial answer, tool call and queued message to storage before it shows it. PiSharp ports it
from Pi v1.2.0:

  • If the process dies mid-turn, reopening the session finishes that turn, with exactly one
    answer and no duplicated user or queued messages.
  • A tool interrupted after it started is not run again unless it is declared replay-safe;
    the model gets an "interrupted" result instead. A replay-safe tool runs again exactly once.
  • Subagents run as child conversations owned by the task that called them.

PiSharp's tests check these guarantees by killing a real process at checkpoints in every
phase of a turn and reopening its storage.

Everything in this section is experimental. The command, its session format and the
library API may change or be removed in any release, including a patch release, without a
deprecation period.

pisharp durable

pisharp durable              # start a new durable session in this folder
pisharp durable --continue   # reopen the newest durable session for this folder (or -c)

It prints a one-line experimental notice to stderr when it starts, and is listed in
pisharp --help as experimental. It uses the same settings, credentials and models as
pisharp. The model gets read (with images), write, edit, bash and a subagent
tool. In the session, /model, /tasks, /agents and /compact work, Escape aborts the
turn and Ctrl+D exits. Each session is one SQLite database under
~/.pi/agent/experimental/durable-sessions/, locked while it is open. If that lock is lost
while the session is open (its lock directory removed, or taken over by another process),
the session fails at once: nothing more is saved, the TUI says the lock was lost, and
pisharp durable exits with 1 (Pi's agent ends its process in that case). These sessions
are separate from ordinary sessions: pisharp --resume does not list them.

pisharp durable is PiSharp-only. Pi v1.1.0 ran its experimental durable agent from source,
not from the pi command, and Pi v1.2.0 removed it; PiSharp keeps it, ported from Pi
v1.1.0's agent and running on the v1.2.0 library.

Libraries

Package Contents
PiSharp.Durable The harness, sessions, conversations, tasks, documents, and memory and JSONL storage
PiSharp.Durable.Tools The local execution environment, the coding tools, tool_search and durable code mode
PiSharp.Durable.Sqlite SQLite storage on Microsoft.Data.Sqlite

The local execution environment resolves real paths (CanonicalPathAsync, and the root of
ListFilesAsync) as Node's realpath does, comparing each name literally: * and ? in a
Unix name are not wildcards, and on Windows a name in another case or an 8.3 short name
resolves to the name stored on disk.

Every public type is marked [Experimental("PISHARP_DURABLE001")], so the compiler reports
an error until you opt in by suppressing that diagnostic:

<PropertyGroup>
  <NoWarn>$(NoWarn);PISHARP_DURABLE001</NoWarn>
</PropertyGroup>
<ItemGroup>
  <PackageReference Include="PiSharp.Durable" Version="1.2.0.1" />
  <PackageReference Include="PiSharp.Durable.Sqlite" Version="1.2.0.1" />
  <PackageReference Include="PiSharp.Durable.Tools" Version="1.2.0.1" />
</ItemGroup>

The package descriptions say EXPERIMENTAL. They have the same version as every other
PiSharp package; there is no prerelease suffix.

SQLite storage

PiSharp.Durable.Sqlite uses Microsoft.Data.Sqlite 10.0.12 with SQLitePCLRaw 2.1.12's
e_sqlite3 (SQLite 3.53.3), pinned exactly. The native library comes from
SQLitePCLRaw.lib.e_sqlite3, which has a build for every common runtime identifier
(runtimes/<rid>/native/); .NET loads the one for the platform it runs on. The
PiSharp.Cli tool carries all of them, so the tool package is about 19 MB (11%) larger
than in 1.2.0.
The licenses ship in the packages and in the tool under licenses/:
Microsoft.Data.Sqlite.LICENSE.txt (MIT), SQLitePCLRaw.LICENSE.txt and
SQLitePCLRaw.NOTICE.txt (Apache-2.0) and SQLite.NOTICE.txt (public domain). The ported
jsdiff (BSD-3-Clause) and ignore/globset (MIT) code carries its licenses too. See
THIRD-PARTY-NOTICES.md.

Session compatibility

  • The SQLite schema, the JSONL layout and the record JSON are upstream pi-durable v1.2.0's.
    Tests open, read, resume and rewrite sessions upstream wrote, and upstream reads
    PiSharp's.
  • pisharp durable shares the session directory layout and the lock with Pi v1.1.0's
    experimental agent, so each finds the other's newest session with --continue and
    waits for or refuses the other's lock. Pi v1.1.0 cannot resume the version 2 tool
    records the v1.2.0 library writes, so do not expect it to continue a PiSharp session.
  • Pi v1.2.0 has no durable agent to share sessions with.

Known issues

  • JSONL storage keeps what it wrote in memory. In the nested-images benchmark PiSharp's
    JSONL storage holds about 400 MiB where Node holds 1 MiB, and 803 MiB against 202 MiB after
    reopening. SQLite storage, which pisharp durable uses, keeps nothing. See
    durable-benchmarks.md.
  • Code mode scripts do not move between Pi and PiSharp. A durable code mode script
    records its engine's fingerprint, and PiSharp's names Jint where Pi's names QuickJS, so
    neither resumes a script the other interrupted: the resume is refused instead of
    diverging. Everything else in such a session stays compatible. pisharp durable does not
    install code mode.
  • No Cloudflare adapters (Durable Object storage, images): they are out of scope.

Other changes

  • PiSharp.Codemode gains CodemodeSandbox.Start(), a port of Pi v1.2.0's deterministic
    sandbox.start() (virtual clock, seeded Math.random, host-numbered results), with
    CodemodeRun, CodemodeRunOptions and related types. Durable code mode runs on it, so it
    can replay a script after a restart. The addition is additive: ExecuteAsync() and the
    coding agent's codemode tool are unchanged.

How to opt in

  • The command: update the tool and run pisharp durable. Nothing changes for pisharp
    itself, and ordinary sessions are not touched.
  • The libraries: reference the packages above and suppress PISHARP_DURABLE001.
    samples/Durable.Chat is a small chat app on a real model, and samples/Durable.Examples
    ports upstream's examples.

Feedback is welcome in GitHub issues.

Packages

All 19 library packages and the PiSharp.Cli dotnet tool are published as 1.2.0.1:

dotnet tool update -g PiSharp.Cli