Skip to content

v0.3.0

Choose a tag to compare

@jagdeepsinghdev jagdeepsinghdev released this 20 Sep 22:09
· 16 commits to master since this release

0.3.0 — 2026-09-20

  • Fix: compaction 401 on authenticated endpoints (#2). before_provider_headers runs before Pi hands the API key to the SDK, so the captured header map never contained a credential unless authHeader: true was set. The summary request now resolves auth at request time via ctx.modelRegistry.getApiKeyAndHeaders and attaches the key the way the SDK does (x-api-key for Anthropic Messages, Authorization: Bearer for OpenAI and OAuth-style tokens), layered over the captured routing headers; a resolved baseUrl is preferred over model.baseUrl. A missing credential is reported as auth: … instead of an HTTP 401.
  • Fix: warm-up never worked against authenticated endpoints. It guessed a Bearer token from the captured headers and fell back to the literal "local". It now runs through ctx.modelRegistry.streamSimple on Pi >= 0.86, so Pi supplies the credential; on Pi 0.85, whose registry facade cannot stream, it resolves auth via getApiKeyAndHeaders and calls pi-ai's completeSimple with the real key. The "local" default is gone, the last warm-up error is shown by /prefix-compaction, and PI_PREFIX_CACHE_DEBUG=1 prints it to stderr.
  • Feature: OpenAI Chat Completions support (#1). Models with "api": "openai-completions" are now handled: the summarize instruction is appended as a string-content user message, the output cap is set in whichever field the captured request used (max_tokens or max_completion_tokens), the request goes to <baseUrl>/chat/completions, and a chat.completion.chunk stream parser handles text, reasoning_content/reasoning, tool_calls, finish_reason (length and tool_calls fall back) and usage (prompt_tokens_details.cached_tokens, prompt_cache_hit_tokens, cached_tokens). enable_thinking, chat_template_args and response_format joined the prompt-affecting fields. Pi's own summarizer is still filtered out when its system prompt arrives as a system/developer message.
  • The "Compaction done" notice now reports how many prompt tokens the server served from its prefix cache, so a cache miss is visible.
  • Tests: fake-server end-to-end tests reproduce the 401 with a keyless capture and verify both wire formats; 28 tests total. Verified live on Pi 0.85.1 and 0.86.0 against: a llama.cpp server with --api-key (401 without the key), both /v1/messages and /v1/chat/completions, ~26,220 of ~26,225 prompt tokens from cache; a self-hosted vLLM Qwen3.8 endpoint over Anthropic Messages (Bearer-only auth) and OpenAI Chat Completions with thinking on; and DeepSeek's official API on both wire formats with thinking on and off, ~56,190 of ~56,350 prompt tokens from cache.
  • Smoke script: new --cycles N runs N compact-then-continue rounds in one session and verifies two planted facts survive after each. Four cycles on DeepSeek, both wire formats, thinking high: every compaction went through the extension with a full prefix-cache hit and the facts stayed intact.