pi-bedrouter 0.2.0 → 0.2.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/footer.ts +9 -2
package/README.md
CHANGED
|
@@ -65,7 +65,7 @@ Example for a developer with a checkout:
|
|
|
65
65
|
|
|
66
66
|
## How the footer works
|
|
67
67
|
|
|
68
|
-
Bedrouter echoes every routing decision in response headers (`x-bedrouter-model`, `-requested`, `-class`, `-reason`, `-conversation`, `-classifier`). Pi hands extensions those headers in the `after_provider_response` event, so the status line updates the moment a response starts, before any tokens stream. When the turn ends, the extension asks bedrouter for the conversation's running totals (`GET /v1/conversations/:key`) and appends cost: spend so far
|
|
68
|
+
Bedrouter echoes every routing decision in response headers (`x-bedrouter-model`, `-requested`, `-class`, `-reason`, `-conversation`, `-classifier`). Pi hands extensions those headers in the `after_provider_response` event, so the status line updates the moment a response starts, before any tokens stream. When the turn ends, the extension asks bedrouter for the conversation's running totals (`GET /v1/conversations/:key`) and appends cost: spend so far, then the routing effect against what the same tokens would have cost on the model the client asked for: `saved $x (n%)`, `same as asked-for`, or `+$x over asked-for (routed up)` when the router chose a stronger rung. The classifier's one-off call is shown separately (`classifier $0.0004`) rather than counted against routing. `↑n` counts escalations in this conversation. The line clears when you switch to a non-bedrouter model. A background health check (every `healthPollS` seconds) keeps it honest between turns: if the server dies the line reads `bedrouter: DOWN` and, with `autoStart` on, the extension restarts it and says so.
|
|
69
69
|
|
|
70
70
|
Under a coding agent every request carries tools and a large system prompt, so you will see `execute` and `explore` decided by keywords or the classifier, then `sticky` for the rest of the session, `up:kw:explore` when an explicit design question moves the conversation up, and escalations after failures. `trivial` shows up for bare chat clients, not for Pi.
|
|
71
71
|
|
package/package.json
CHANGED
package/src/footer.ts
CHANGED
|
@@ -19,9 +19,16 @@ export function statusLine(d: LastDecision | null, c: ConversationStats | null):
|
|
|
19
19
|
let s = `⇄ ${d.model} ${arrow} ${d.requested} ${d.cls}·${short(d.reason)}`;
|
|
20
20
|
if (c && c.requests > 0) {
|
|
21
21
|
const spend = c.costUsd + c.classifierCostUsd;
|
|
22
|
-
|
|
22
|
+
// Routing effect = model cost vs the same tokens on the asked-for model. The classifier's one-off call is overhead
|
|
23
|
+
// and shown as such, never folded into "over asked-for" (which would flag every break-even session as a loss).
|
|
24
|
+
const diff = c.requestedCostUsd - c.costUsd;
|
|
23
25
|
const pct = c.requestedCostUsd > 0 ? Math.round((diff / c.requestedCostUsd) * 100) : 0;
|
|
24
|
-
|
|
26
|
+
const clf = c.classifierCostUsd > 0 ? `, classifier ${usd(c.classifierCostUsd)}` : "";
|
|
27
|
+
let verdict: string;
|
|
28
|
+
if (Math.abs(diff) < 1e-6) verdict = `same as asked-for${clf}`;
|
|
29
|
+
else if (diff > 0) verdict = `saved ${usd(diff)} (${pct}%)${clf}`;
|
|
30
|
+
else verdict = `+${usd(-diff)} over asked-for (routed up)${clf}`;
|
|
31
|
+
s += ` ${usd(spend)} · ${verdict}${c.escalations ? ` ↑${c.escalations}` : ""}`;
|
|
25
32
|
}
|
|
26
33
|
return s;
|
|
27
34
|
}
|