@stablekernel/pi-bifrost 0.13.0 → 0.13.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/package.json +1 -1
- package/src/index.ts +15 -5
- package/src/plugin.test.ts +25 -0
package/README.md
CHANGED
|
@@ -8,7 +8,7 @@ Pi extension that registers a [Bifrost](https://docs.getbifrost.ai) LLM gateway
|
|
|
8
8
|
- `bifrost-openai` — the OpenAI-compatible surface, every chat model the gateway serves. First-party OpenAI GPT models (not `gpt-oss`) are sent over the Responses API (`api: "openai-responses"` per model): gpt-6-class models reject chat completions through the gateway.
|
|
9
9
|
- `bifrost-anthropic` — the Anthropic Messages surface, Claude models only. The Anthropic wire carries prompt-cache control blocks that only Claude accepts, so non-Claude models are registered on the OpenAI surface instead of being listed twice with one copy broken.
|
|
10
10
|
- Fetches each surface's model list, limits and pricing through `gateway-cli models --wire=…` at startup — no catalog is checked in.
|
|
11
|
-
- Seeds reasoning capability per model: catalog-flagged models register `reasoning: true`. On the OpenAI surface they also get a `thinkingLevelMap` translating pi's thinking levels to the model's effort values (unapplicable levels are hidden, never passed through by name) plus `supportsReasoningEffort`, so pi's per-request effort picker sends the provider's own values. On the Anthropic surface the capability is flagged and pi's Claude thinking handling applies. Models with effort levels also set `supportsPerMessageEffort` (omp only) so thinking-level changes keep the prompt cache. Cache-keeping has been verified live only on `claude-opus-5-5` through Bifrost; other models remain unverified ([G-012](../../KNOWN-GAPS.md)). Toggle-only reasoning models get no effort map. The default effort itself is pi's own thinking-level default.
|
|
11
|
+
- Seeds reasoning capability per model: catalog-flagged models register `reasoning: true`. On the OpenAI surface they also get a `thinkingLevelMap` translating pi's thinking levels to the model's effort values (unapplicable levels are hidden, never passed through by name) plus `supportsReasoningEffort`, so pi's per-request effort picker sends the provider's own values. On the Anthropic surface the capability is flagged and pi's Claude thinking handling applies; `claude-sonnet-5-5` also sets `forceAdaptiveThinking`, because pi 1.4.0 otherwise sends `thinking.type=enabled` and Bifrost returns a 400 (verified live 2026-11-25; Opus 5.5, Haiku 5.5 and Fable 5.2 work without it). Models with effort levels also set `supportsPerMessageEffort` (omp only) so thinking-level changes keep the prompt cache. Cache-keeping has been verified live only on `claude-opus-5-5` through Bifrost; other models remain unverified ([G-012](../../KNOWN-GAPS.md)). Toggle-only reasoning models get no effort map. The default effort itself is pi's own thinking-level default.
|
|
12
12
|
- Adds rolling prompt-cache breakpoints for GPT-6.2 on Bedrock (`bedrock/openai.gpt-6.2-*`). Those models reuse a cached prefix only up to a content block marked `prompt_cache_breakpoint: {mode: "explicit"}`, so without markers every agent turn was a full cache write. A `before_provider_request` hook marks the last input item of each request and the item that ended the previous request; string content on a marked item is sent as a one-block `input_text` list. Other models, 6.0/6.1 included, cache implicitly and are left untouched. Verified live 2026-11-24 on `gpt-6.2-sol` through omp: cache reads per turn went from 0, 0, 0, 0 to 44.5K, 46.0K, 47.6K, 49.0K (about 97% of the prompt).
|
|
13
13
|
- Sets `user` on chat-completions requests to Fireworks models (`fireworks/*`) to a hash of the conversation's first messages, Fireworks' documented session-affinity key (Bifrost forwards it), so a session's turns tend to reach the replica that holds its cached prefix. It is a hint, not a pin: measured live 2026-11-24 on `kimi-k3.1`, follow-up turns that missed the previous prefix fell from 26% to 18% (200 turns each). The rest is Fireworks routing ([G-020](../../KNOWN-GAPS.md)). A `user` the harness already set is kept.
|
|
14
14
|
- Never holds the key: pi resolves it per request via the `!gateway-cli key print` command form, so the per-project key cascade (environment override → project → user default) applies on every turn.
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -360,9 +360,12 @@ export function toPiModels(
|
|
|
360
360
|
}
|
|
361
361
|
}
|
|
362
362
|
// Anthropic-messages surface: reasoning:true tells pi the model can
|
|
363
|
-
// think; pi's built-in Claude handling applies.
|
|
364
|
-
//
|
|
365
|
-
//
|
|
363
|
+
// think; pi's built-in Claude handling applies. pi 1.4.0 does not
|
|
364
|
+
// recognize claude-sonnet-5-5 as adaptive-only and sends
|
|
365
|
+
// thinking.type=enabled, which Bifrost relays as a 400 ("thinking.type.
|
|
366
|
+
// enabled is not supported ... Use thinking.type.adaptive"); verified
|
|
367
|
+
// live 2026-11-25. forceAdaptiveThinking fixes it. Opus 5.5, Haiku 5.5
|
|
368
|
+
// and Fable 5.2 work without it (same check), so only Sonnet 5.5 sets it.
|
|
366
369
|
//
|
|
367
370
|
// supportsPerMessageEffort: omp defaults it off for non-first-party
|
|
368
371
|
// endpoints, so a thinking-level change rewrote the top-level effort
|
|
@@ -370,8 +373,11 @@ export function toPiModels(
|
|
|
370
373
|
// block onward (full-context cache miss per change). Per-message effort
|
|
371
374
|
// keeps the prefix intact; Bifrost forwards the beta (verified live
|
|
372
375
|
// 2026-11-16 on claude-opus-5-5). Only for models with effort levels.
|
|
373
|
-
if (api === "anthropic-messages"
|
|
374
|
-
|
|
376
|
+
if (api === "anthropic-messages") {
|
|
377
|
+
const compat: NonNullable<ProviderModelConfig["compat"]> = {};
|
|
378
|
+
if (map) compat.supportsPerMessageEffort = true;
|
|
379
|
+
if (ADAPTIVE_ONLY.test(m.id)) compat.forceAdaptiveThinking = true;
|
|
380
|
+
if (Object.keys(compat).length > 0) model.compat = compat;
|
|
375
381
|
}
|
|
376
382
|
}
|
|
377
383
|
out.push(model);
|
|
@@ -394,6 +400,10 @@ const PI_LEVELS = [
|
|
|
394
400
|
* not the open-weight gpt-oss line, which chat completions serves fine. */
|
|
395
401
|
const OPENAI_GPT = /(?:^|\/)openai[./]gpt-(?!oss)/;
|
|
396
402
|
|
|
403
|
+
/** Claude ids that reject thinking.type=enabled but that pi does not know are
|
|
404
|
+
* adaptive-only; verified live 2026-11-25 (Opus/Haiku 5.5, Fable 5.2 are fine). */
|
|
405
|
+
const ADAPTIVE_ONLY = /^claude-sonnet-5-5$/;
|
|
406
|
+
|
|
397
407
|
/**
|
|
398
408
|
* Build a thinkingLevelMap from a model's advertised effort values. Each pi
|
|
399
409
|
* level maps to the same-named provider value when the model accepts it, and
|
package/src/plugin.test.ts
CHANGED
|
@@ -494,6 +494,31 @@ describe("reasoning", () => {
|
|
|
494
494
|
expect(model.reasoning).toBe(true);
|
|
495
495
|
expect(model.compat).toBeUndefined();
|
|
496
496
|
});
|
|
497
|
+
|
|
498
|
+
test("forces adaptive thinking for Sonnet 5.5 only", async () => {
|
|
499
|
+
// pi 1.4.0 sends thinking.type=enabled for Sonnet 5.5, which Bifrost
|
|
500
|
+
// 400s (G-084); Opus, Haiku and Fable 5.x work without the flag.
|
|
501
|
+
const { toPiModels } = await import("./index.js");
|
|
502
|
+
const models = toPiModels(
|
|
503
|
+
{
|
|
504
|
+
models: [
|
|
505
|
+
"claude-sonnet-5-5",
|
|
506
|
+
"claude-opus-5-5",
|
|
507
|
+
"claude-haiku-5-5",
|
|
508
|
+
"claude-fable-5-2",
|
|
509
|
+
].map((id): CliModel => ({ ...KIMI, id })),
|
|
510
|
+
},
|
|
511
|
+
"anthropic-messages",
|
|
512
|
+
);
|
|
513
|
+
const byId = Object.fromEntries(models.map((m) => [m.id, m.compat]));
|
|
514
|
+
expect(byId["claude-sonnet-5-5"]).toEqual({
|
|
515
|
+
supportsPerMessageEffort: true,
|
|
516
|
+
forceAdaptiveThinking: true,
|
|
517
|
+
});
|
|
518
|
+
for (const id of ["claude-opus-5-5", "claude-haiku-5-5", "claude-fable-5-2"]) {
|
|
519
|
+
expect(byId[id]).toEqual({ supportsPerMessageEffort: true });
|
|
520
|
+
}
|
|
521
|
+
});
|
|
497
522
|
});
|
|
498
523
|
|
|
499
524
|
describe("responses routing", () => {
|