pi-better-harness 0.40.3 → 0.40.4

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.
@@ -108,7 +108,9 @@ DeepSeek also excludes Chinese public holidays. The bundled holiday list is curr
108
108
  - When every candidate is excluded but at least one failed transiently, retry the model the turn already uses instead of ending the turn. Only rejected requests can end it with no route left.
109
109
  - Preserve the failed model only after a context overflow, because Pi retries that request after compacting the conversation and a switch would pay a cold cache.
110
110
  - Report excluded and demoted providers as router state only when those lists change, so a long session does not append one state entry per request.
111
- - Declare the virtual model's 1M context window and 384k output limit. Pi reads them whenever a response names no physical model, which is what the router's own routing error looks like, and an undeclared limit counts as zero. A zero window makes every conversation look over the compaction threshold, so Pi would compact after each routing error at any context size.
111
+ - Declare the virtual model's context limits as a pair that fits the provider window. Pi reads them whenever a response names no physical model, which is what the router's own routing error looks like, and an undeclared limit counts as zero. A zero window makes every conversation look over the compaction threshold, so Pi would compact after each routing error at any context size.
112
+
113
+ Both candidates share one 1,048,576-token window between input and output, but Pi treats `contextWindow` as the input allowance and `maxTokens` as room beyond it. The router therefore declares an input budget of `1,048,576 - 64,000` beside a 64,000-token output budget, so the two add up to the provider window. Declaring the raw 1,048,576 window beside a large output budget promises capacity no endpoint has: a 746,917-token conversation plus a 384,000-token completion is 1,130,917 tokens, which the provider rejects. The same pair also keeps Pi's compaction trigger below the point where output stops fitting.
112
114
  - Stop with an error when every candidate is unavailable or rejected. A new user turn clears the exclusions.
113
115
  - Direct requests, such as compaction summaries, compare prices independently.
114
116
 
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-better-model-router",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "description": "Price-aware virtual model routing for Pi.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -22,12 +22,20 @@ export interface VirtualDefinition {
22
22
  contextWindow: number; maxTokens: number;
23
23
  route(request: RouteRequest, ctx: ExtensionContext): RouteResult;
24
24
  }
25
- // Both candidate families declare a 1M context window, so the router declares the shared
26
- // floor. Pi needs it whenever a response names no physical model, which is exactly the
27
- // router's own routing error: with no declared limit Pi falls back to a zero window, sees
25
+ // Pi needs a declared window whenever a response names no physical model, which is exactly
26
+ // the router's own routing error: with no declared limit Pi falls back to a zero window, sees
28
27
  // every conversation as over the threshold, and compacts after each routing error.
29
- const CONTEXT_WINDOW = 1_000_000;
30
- const MAX_TOKENS = 384_000;
28
+ //
29
+ // Both candidate families share one 1,048,576-token window between input and output, but Pi
30
+ // treats contextWindow as the input allowance and maxTokens as room beyond it. Declaring the
31
+ // raw window beside a large output budget therefore promises capacity the provider does not
32
+ // have: 746,917 tokens of history plus a 384,000-token completion is 1,130,917, and the
33
+ // request is rejected for exceeding 1,048,576. Declare the input budget the shared window
34
+ // leaves after the output budget instead, so both the compaction threshold and the
35
+ // request-time clamp stay inside the real window.
36
+ const PROVIDER_CONTEXT_WINDOW = 1_048_576;
37
+ const MAX_TOKENS = 64_000;
38
+ const CONTEXT_WINDOW = PROVIDER_CONTEXT_WINDOW - MAX_TOKENS;
31
39
  function sameList(left: readonly string[] = [], right: readonly string[] = []): boolean {
32
40
  return left.length === right.length && left.every((value, index) => value === right[index]);
33
41
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-better-harness",
3
- "version": "0.40.3",
3
+ "version": "0.40.4",
4
4
  "description": "Pi extension bundle for a write sandbox, subagents, background tasks, SSH, goals, model routing, and Outcome & Todo.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -57,7 +57,7 @@
57
57
  "dependencies": {
58
58
  "pi-better-background-tasks": "0.14.2",
59
59
  "pi-better-goal": "0.12.1",
60
- "pi-better-model-router": "0.1.3",
60
+ "pi-better-model-router": "0.1.4",
61
61
  "pi-ollama-cloud": "0.13.1",
62
62
  "pi-better-sandbox": "0.14.1",
63
63
  "pi-better-ssh": "0.1.4",