Skip to content

PiSharp 1.2.0.2

Choose a tag to compare

@github-actions github-actions released this 02 Nov 03:38
· 683 commits to main since this release
92e2f8b

PiSharp 1.2.0.2

A C#-only release on the Pi v1.2.0 baseline (commit
06a466935536f8c9bcacb2d5efc0fc021be1bdff). The baseline does not change: everything new here
is PiSharp-only, and most of it is experimental. It also fixes bugs in pisharp itself.

  • Experimental, now released: the media library and tools, service tiers, custom agents
    (three new packages), questions and plan mode in pisharp durable, and the durable device
    server and its commands.
  • Fixed: write no longer stops at 64 KiB, codemode scripts no longer see model headers,
    and MCP, shutdown, input and RPC races are fixed.
  • Source only: the Web Agent, Durable Web, SQL Server storage and the libraries under them
    are in the repository but not packaged.

The Parity page lists what still differs from Pi.

Everything marked experimental may change or be removed in any release, including a patch
release, without a deprecation period.
Each experimental API carries an
[Experimental("...")] attribute: the compiler reports an error until you suppress that
diagnostic.

Diagnostic Covers
PISHARP_MEDIA001 The media library, PiSharp.AI.Media
PISHARP_TIERS001 Service tiers: ServiceTiers and the ServiceTier members
PISHARP_AGENTS001 The custom agents packages (with PISHARP_DURABLE001)
PISHARP_CATALOG001 MaintainedCatalogOverlay and MaintainedCatalogResult in PiSharp.AI
PISHARP_DURABLE001 The durable packages, as in 1.2.0.1, now including questions, plan mode and the media tools

Experimental: media

PiSharp can generate images, video, speech and music, transcribe audio, embed and rerank text,
and ask decision models. Pi has image generation and classifiers, but nothing for embeddings,
video, speech, transcription, music or reranking, so this is PiSharp-only
(decision 0007).

  • Library. PiSharp.AI.Media (PISHARP_MEDIA001). MediaRegistry resolves provider/id
    model specs and their credentials and dispatches by kind.

    • Embeddings: OpenAI-compatible and Gemini.
    • Images: OpenAI GPT image, OpenRouter's Image API, Gemini and Imagen.
    • Video: OpenRouter and Veo.
    • Speech and transcription: OpenAI-compatible.
    • Music: OpenRouter chat audio.
    • OpenRouter rerank and decisions.

    DiscoverAsync lists OpenRouter's models of each kind.

  • Tools in pisharp durable. generate_image, generate_video, embed,
    list_media_models and set_media_defaults, plus the deferred generate_speech,
    transcribe_audio, generate_music, rerank and decide. They are installed only when a
    configured provider has a media model and the media.enabled setting isn't false. Each kind
    has a default model and options in the media setting.

  • No double charges after a crash.

    • Paid results are saved before they are used, so a rerun reuses them.
    • A video's job id is saved as soon as the job is submitted.
    • A transcription whose request went out but whose transcript was not saved fails as
      interrupted instead of being sent again.
    • embed, rerank and decide are cheap and change nothing at the provider, so an unsaved
      call simply runs again.
  • set_media_defaults changes apply to the session even when settings.json can't be saved,
    and the tool says so.

See Media and the
media library.

Experimental: service tiers

Some providers sell cheaper or faster capacity. A service tier picks it per request: auto,
normal, economy, priority, fast or ultrafast.

  • pisharp:

    • --tier <tier> (alias --service-tier) or the serviceTier setting sets the tier.
    • /tier <tier> changes it for the next request, and /tier <tier> default also saves it.
    • The footer shows it.
  • pisharp durable: the same, per conversation, and the subagent tool takes a tier.

  • Wire mapping. Each API gets its own field:

    • OpenAI and OpenRouter: service_tier.
    • Anthropic: service_tier, plus speed: "fast" on the models that offer fast mode.
    • Codex and Google: their own tier values.

    Other providers and APIs get no tier field.

  • Off by default. With no tier set, requests and the footer are exactly as before.

  • Not in Pi. --tier, /tier, the footer tier and the serviceTier setting are recorded
    as intentional differences from Pi.

See Service tiers.

Experimental: custom agents (new packages)

Three new packages for building crash-safe agents in C# on the durable harness
(decision 0012):

Package Contents
PiSharp.CustomAgents Typed workflows, agent teams, subagents, messaging, typed and dynamic tools, plugin DLLs and web_search
PiSharp.CustomAgents.JavaScript JavaScript tools and workflow actions in Codemode's Jint sandbox
PiSharp.CustomAgents.Scripting C# script tools and workflow actions, compiled with Roslyn
  • Workflows. A typed series of actions over one shared data object.
    • An action can be:
      • C# code or a model call (Prompt, or Prompt<T> with structured output);
      • an agent run, or a JavaScript or C# script;
      • a sub-workflow, a Parallel or ForEach fan-out, or a wait for a signal.
    • Each step commits atomically, so a run resumes after a crash, and OnceAsync keeps a side
      effect to one run.
    • A fail-fast fan-out names the child that failed, not a sibling it aborted.
  • Teams. Agent definitions with their own tools and instructions, on any provider.
    • Subagents work through delegate, spawn, wait_agent and stop_agent.
    • Agents talk through send_message, ask_agent and reply.
    • A wait that would deadlock is refused.
  • Dynamic tools.
    • JavaScript: sandboxed. A model may write its own tools only if the host turns that on.
    • C# scripts: run with full trust and are never model-written. Each compiles into a
      collectible context and unloads when replaced.
    • Plugin DLLs: trusted only when listed.
  • web_search. Brave, Tavily, Firecrawl, and the hosted search of OpenAI, Anthropic, xAI
    (with X search) and OpenRouter. Errors name the key's environment variable, never the key.
<PropertyGroup>
  <NoWarn>$(NoWarn);PISHARP_AGENTS001;PISHARP_DURABLE001</NoWarn>
</PropertyGroup>
<ItemGroup>
  <PackageReference Include="PiSharp.CustomAgents" Version="1.2.0.2" />
</ItemGroup>

PiSharp.CustomAgents.Scripting depends on Microsoft.CodeAnalysis.CSharp 5.6.0 (MIT), pinned
exactly. See Custom agents, and
samples/CustomAgents.Examples and samples/CustomAgents.Research.

Experimental: pisharp durable additions

pi-durable has none of these; they are PiSharp's.

  • Questions from the agent.
    • The ask_user_question tool asks one to four multiple-choice questions, with an
      "Other" answer.
    • The question waits durably: after a restart the same questions come back, and your
      answer completes the same call.
  • Plan mode (/plan, /plan <message>).
    • The conversation keeps only read, bash, ask_user_question and exit_plan_mode, and
      write and edit confined to a plan directory (the planMode.directory setting).
    • exit_plan_mode submits the plan for your review: approve and start, approve without
      starting, or keep planning with or without feedback.
    • bash is not restricted in plan mode.
  • --tier, /tier and the media tools (above).
  • pisharp durable --help prints the options without opening a session.
  • The durable device server (decision 0008,
    0009 and
    0010). These commands are not in
    pisharp --help; pisharp durable help lists them.
    • pisharp durable serve runs this machine as a durable device: many durable sessions
      behind an authenticated HTTP and server-sent-events API.
      • It listens on 127.0.0.1:4780 by default and keeps its data in
        ~/.pi/agent/experimental/durable-device.
      • The device token is a shell: anyone who has it can run commands as you.
      • --host can listen on another address, with a warning. The API is plain HTTP, so use an
        SSH tunnel or a TLS proxy instead.
    • pisharp durable token prints or rotates the device token. It is stored in a file only
      you can read and never goes on a command line: remote commands read it from
      PISHARP_DEVICE_TOKEN or --token-file.
    • Device commands for sessions, executions, schedules, trigger credentials, budgets,
      retention, policies and judgments, artifacts, evidence, sources, research, feedback and
      preferences. Each takes --json, and --device <url> to work on another device.
    • Local commands: attach (a line-mode terminal on a session's agent), doctor,
      service (writes a per-user service definition and installs nothing) and
      backup create|verify|restore.

Fixes in pisharp

  • write is no longer capped at 64 KiB. Pi has no write limit; PiSharp now takes up to
    8 MiB of arguments in one call. edit arguments are still limited to 65,536 characters.
  • Codemode scripts no longer see model headers. models.list() and getModelOfType() used
    to give scripts each model's headers, which can hold API keys. Requests made through
    classify and generateImages still send them.
  • MCP:
    • Closing one server no longer fails another server that connects at the same moment.
    • While a server closes, prompts, /mcp actions and an extension's getAllTools wait or
      answer instead of failing with "Session replacement is in progress".
    • A session that ends while a stdio MCP server is still starting exits cleanly instead of
      reporting a cleanup failure.
  • Input and shutdown:
    • The first key after /new or another session switch reaches the editor.
    • Shutting down a session that faulted, or that still had queued input, no longer reports a
      cleanup failure on top of its real outcome.
    • A cancelled JSON-mode command reports Canceled instead of CommandFailed.
  • RPC and print mode. pisharp -p and RPC no longer hang at exit when an extension command
    starts a run while the command's response is being written.
  • Help:
    • --service-tier is listed as an alias of --tier.
    • powershell is no longer listed as a built-in tool, since the CLI doesn't register it.
    • pisharp session --help and pisharp session <verb> --help print help, and
      pisharp <command> --help names session and durable.
    • The mcp help and messages say pisharp.

Maintained model catalog (PiSharp-only)

The CLI can apply a separately maintained, reviewed catalog layer of model metadata and prices
on top of Pi's pinned catalogs:

  • Where it comes from. catalog-maintained/models.overlay.json next to the tool, or a file
    named by PISHARP_MAINTAINED_CATALOG.
  • When it applies. After remote catalog refreshes and before models.json and extensions.
  • It ships empty in 1.2.0.2, so the catalog is unchanged.
  • What it can change. It updates prices and limits, and can add complete chat models. It
    never selects a model.

MaintainedCatalogOverlay, its public reader in PiSharp.AI, is PISHARP_CATALOG001.
samples/agents/31-ModelCatalogMaintainer produces the format.

Source only (not packaged)

These are on main and run from source, but have no NuGet package and are not in the tool
unless noted:

  • The PiSharp Web Agent (src/PiSharp.WebAgent, decision 0011).
    • A local chat app and model playground on durable sessions, bound to 127.0.0.1:5180.
    • It has Spend Guard caps and a spend ledger, Compare, the Tool Bench and the Model Arena,
      test suites and Drift Watch.
  • Durable Web (src/PiSharp.Durable.Web): the hub and web UI for durable devices, on
    127.0.0.1:5181.
  • SQL Server storage for durable sessions (src/PiSharp.Durable.MSSQL, decision 0007). Its
    SNI runtime dependency is under Microsoft's proprietary license terms, which the owner must
    review before it is packaged or added to the CLI.
  • The libraries under them:
    • PiSharp.Durable.Hosting, PiSharp.Durable.Server and PiSharp.Durable.Client ship
      inside the PiSharp.Cli tool, for pisharp durable serve, but not as packages.
    • PiSharp.ModelRuntime (the model registry, moved out of the CLI) also ships inside the
      tool.
    • PiSharp.Web.Common is source only.
  • Samples. 62 runnable agent samples (samples/agents) with fixtures and self-tests, and
    samples/Durable.ReleaseWatcher.

Packages and tool

All 22 library packages and the PiSharp.Cli dotnet tool are published as 1.2.0.2: the 19 of
1.2.0.1 plus the three custom agents packages.

dotnet tool update -g PiSharp.Cli
  • The tool now needs the ASP.NET Core runtime. Microsoft.AspNetCore.App 10 is needed
    because pisharp durable serve hosts a web server. The .NET 10 SDK, which dotnet tool
    needs, includes it. On a machine with only the .NET runtime, install the ASP.NET Core
    runtime too.
  • New license in the tool. It carries licenses/durable-pi.LICENSE.txt (MIT): the device
    host adapts designs of durable-pi. See
    THIRD-PARTY-NOTICES.md.

Known issues

  • Media not run live. OpenRouter video and the Google media backends (Gemini, Imagen, Veo)
    have not been run against the live services. The Brave and Tavily search backends haven't
    either.
  • Plan mode doesn't restrict bash. Only write and edit are confined to the plan
    directory.
  • edit argument cap. edit arguments are still capped at 65,536 characters.
  • Extension state across /reload. A native extension's ExtensionSessionState written
    before /reload is not found after it, because the extension's id changes on reload.
  • MCP reads during a close. An extension's getActiveTools is still refused while an MCP
    server closes.
  • Known issues kept from 1.2.0.1:
    • JSONL durable storage keeps what it wrote in memory.
    • Durable code mode scripts don't resume between Pi and PiSharp.

Feedback is welcome in GitHub issues.