Make connection, protocol, storage, and lock failures fail fast. Align the remote TUI's spacing, activity indicator, and exit behavior with legacy mode.
New section 14: streamAssistant and the three-phase tool execution
blocks (prepare/execute/finalize) with durability callbacks, batch rules
(parallel vs sequential, length truncation, terminate), and the
unbreakable agent-loop.ts compatibility requirement with acceptance
criterion. Harness internals rewritten on top of the blocks: runToolBatch
with provisioned-id callbacks, reconciliation via phases 2+3, hook-to-
block wiring table. Auth surface removed from the stream block: Models
resolves auth per request; before_payload/after_response mount on
onPayload/onResponse. Sections 16-22 renumbered.
Prefer function payloads when malformed OpenAI-compatible tool-call deltas also include an empty custom object, preserving parsed arguments.
Fixes#7160
Co-authored-by: Sunny Young <isunnyyoung@gmail.com>
Adds AssistantMessage.rawStopReason and preserves provider original stop reasons.
Improves certain cases of error messages.
For mistral, change unmapped finish reasons to be "error" instead of "stop".
fixes#7255
Restructured rewrite: concepts (session = tree + lanes + per-lane
operation logs + global facts), records and crash-site traces, recovery
as reduction, then API and implementation top-down. Renames refs to
lanes, generations to tasks; retires leaf entries, de-trees labels and
name, adds deferred provider requests (stopReason deferred, optional
fetchDeferred/cancelDeferred on ProviderStreams, deliberate lane
suspension), SQLite branch cache with tips and reverse lookup, Unix ms
timestamps. Supersedes harness.md.
Running from a linked worktree nested under its main repo loaded the
project's AGENTS.md/CLAUDE.md twice. The ancestor walk climbs from cwd to
the filesystem root, so it picked up the worktree's copy and then the main
repo's copy above it, even though both are the same tracked file.
The walk now drops that one duplicate: the main repo root's copy is skipped
when the worktree root has a context file of the same name. Nothing else
changes. The worktree still inherits the main repo's copy when it has none,
directories above the main repo keep loading, and ordinary repos, sibling
worktrees, submodules and bare layouts are untouched.
Bump TypeBox to 1.3.7 so compiled validators guard array-specific keywords when null is accepted, and cover tool-argument validation with a regression test.
Breaking for extensions: TypeBox 1.3 removes deprecated APIs including Type.Base, Type.Awaited, Type.Promise, Type.AsyncIterator, Type.Iterator, Type.Options, and Value.Mutate. Extensions using these through Pi's bundled TypeBox aliases must migrate to supported TypeBox APIs.
Fixes#7003
Image.render() previously emitted the imageFallback line without
truncateToWidth. Long absolute paths (common when callers pass a
filename) exceeded the terminal width and crashed the TUI.
- imageFallback: home-shorten paths to ~/...; OSC 8 file:// link when
hyperlinks are available and the path is absolute
- Image.render: truncate fallback lines to the render width
- tests for shorten, hyperlink, basename, and width clamp
Co-authored-by: Moritz Hofmann <Moritz.Hofmann@aimentum.de>
llama-server supports OpenAI-spec stream_options.include_usage since
b2b6b55a59 (Sep 2025); any server new enough for router mode sends the
final usage chunk when requested. With the flag hardcoded to false the
provider never requests it, so streamed responses record zero tokens
and session/context accounting stays empty.
Verified against llama-server b10094: with include_usage sent, the
final chunk carries usage (incl. prompt_tokens_details.cached_tokens);
without it, nothing.
Refs: named movable leaf pointers, one active operation per ref, parallel
under one writer. AgentRef surface implemented by AgentHarness for main;
per-ref queues, persisted config, session views, scoped watch() plus
watchSession(). Per-ref recovery and operational-log partitioning (no
parenting; log order is causal order within a ref; session entries carry
no ref, membership derives from parent linkage). Labels and session name
de-treed to global latest-wins records with setter APIs. Named
append-only context invariant (KV cache rationale for deferred writes).
New traces, API examples, and open questions for review.