Conversation
- the managed model went through Anthropic's OpenAI-compatible endpoint, which does not support prompt caching; Pi's anthropic-messages adapter now targets a backend /chat/v1/messages route that keeps auth, quota and usage accounting - the route adds top-level automatic cache_control, prices 5m/1h cache writes and cache reads, rejects server tools, and classifies Anthropic errors - upgrade Pi to 0.82.1, the first release with claude-opus-5; bind provider auth explicitly since 0.82 rejects an unconfigured provider - raise the Opus 5 default context window to 300K (defaultModelsVersion 8)
- the Pi stream never emitted usage metadata, so the thread contextSize stayed null and the context-usage ring was hidden for every Pi-routed model - map Pi usage to the AI SDK shape at turn_end, including cached input tokens
- wire-level assertions for cache_control on the managed Messages route, cache-aware pricing, server-tool rejection and Anthropic error telemetry - Pi adapter and harness tests for the managed alias, context window and the turn usage emitted for the context indicator
Semgrep Security ScanNo security issues found. |
|
Preview environment deployed 🚀
Stack: Auto-destroys on PR close/merge. Login via the bundled Keycloak realm — |
- cli/ pins its own copies of the four @earendil-works/pi-* packages and CI requires them to match the root pi-ai version - AgentHarness no longer takes an execution environment in 0.82; the coding tools are bound to cwd directly, so the unused NodeExecutionEnv goes away
|
There is no small context price discount on Anthropic models anymore at <200K, so I raised the default context to 300K intentionally as part of this patch. 300K aligns well with the small context of other models(OAI) so if you're not doing 1M I think it's the sweet spot. |
PR Metrics
Updated Fri, 18 Sep 2026 20:41:02 GMT · run #3054 |
There was a problem hiding this comment.
🔭 thunder-deep-review (advisory)
Complements the other bots — surfaces only what they did not flag. Never approves, never requests changes, never gates merge.
head: eb893423245b · mode: deep · deferred 0 item(s) already reported by other bots (best-effort dedup)
There was a problem hiding this comment.
🔭 thunder-deep-review (advisory)
Complements the other bots — surfaces only what they did not flag. Never approves, never requests changes, never gates merge.
head: 16ce8409d3d6 · mode: deep · deferred 0 item(s) already reported by other bots (best-effort dedup)
There was a problem hiding this comment.
🔭 thunder-deep-review (advisory)
Complements the other bots — surfaces only what they did not flag. Never approves, never requests changes, never gates merge.
head: d2213da3f90c · mode: deep · deferred 0 item(s) already reported by other bots (best-effort dedup)
…ilures The native route's stream onError now spreads getApiErrorMetadata like /completions does, so requestId and errorType reach telemetry. Also share the latency recorder and admission gate between the two inference routes so timing headers and quota semantics cannot drift.
Linear
THU-899
Summary
opus-5model through Pi's nativeanthropic-messagesadapter and a new backendPOST /v1/chat/v1/messagesroute instead of Anthropic's OpenAI-compatible endpoint, which does not support prompt caching. Pi marks the system prompt, last tool and last user block withcache_control; the backend adds top-level automaticcache_controlon every request./chat/completionsauth, quota admission, usage recording and latency telemetry. It validates the body (400 on malformed input), rejects Anthropic server tools, and classifies Anthropic SDK and mid-stream errors into the existing telemetry kinds withrequestId/errorType.@earendil-works/pi-ai,pi-agent-core,pi-coding-agent(andpi-tuiincli/) 0.80.7 -> 0.82.1, the first release whose catalog includesclaude-opus-5. Provider auth is bound explicitly (boundApiKeyAuth) because 0.82 rejects an unconfigured provider;AgentHarnessno longer takes an execution environment, so the app and CLI harness builders drop it.contextWindow200K -> 300K;defaultModelsVersion7 -> 8 and the lineage migration carries the new value to unmodified rows.usagemetadata atturn_end, sochat_threads.contextSizeis persisted and the context-usage indicator renders for Pi-routed models (it previously only worked on the legacy AI SDK path).@anthropic-ai/sdkto the backend.Test Plan
bun run tsc --noEmit,bun run lint,bun run test,bun run test:agent-corebun run type-check,bun run lint,bun testcli/:bun run typecheck,bun run test,bun run build, artifact--version/--helpsmokemessage_startusage reportscache_read_input_tokens > 0; the context ring appears in the composer after the first reply.Changes
backend/src/inference/routes.ts-POST /v1/messageshandler; sharedcreateUsageCallbacks/streamingResponseHeadershelpers used by both routesbackend/src/inference/client.ts-getAnthropicMessagesClientbackend/src/utils/anthropic-streaming.ts- re-encodes SDK events as SSE, collects final usage, reports stream errorsbackend/src/inference/usage-ledger.ts,error-kind.ts- cache pricing; Anthropic error classificationshared/agent-core/anthropic-model.ts,build-app-harness.ts,bound-api-key-auth.ts,openai-compat-model.ts- managed alias / base URL / context window on the native descriptor; Pi 0.82 auth and harness changesshared/agent-core/pi-to-aisdk-stream.ts-usagemessage-metadata atturn_endsrc/acp/built-in-adapter.ts,src/ai/fetch.ts- routethunderbolt+vendor: anthropicmodels to the native path (Pi and legacy AI SDK);resolveManagedAnthropicConnectionderives from the shared thunderbolt auth policyshared/defaults/models.ts,src/lib/data-migrations/upgrade-model-defaults.ts- 300K defaultcli/package.json,cli/bun.lock,cli/src/agent/harness.ts- Pi 0.82.1 pins and harness construction