pi-model-fallback 0.5.1 → 0.5.2

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/CHANGELOG.md CHANGED
@@ -2,6 +2,16 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## [0.5.2] - 2026-10-07
6
+
7
+ ### Changed
8
+
9
+ - Update `@earendil-works/pi-*` development dependencies to `1.0.4`.
10
+
11
+ ### Fixed
12
+
13
+ - Recognize a status in parentheses when a provider error wrapper precedes it, for example `omni API error (503): ...`. Previously such messages yielded no status, so rules listing `503` were never evaluated even when configured.
14
+
5
15
  ## [0.5.1] - 2026-09-30
6
16
 
7
17
  ### Changed
package/README.md CHANGED
@@ -123,7 +123,7 @@ If the package is installed project-locally and the current project references i
123
123
 
124
124
  - Successful responses do nothing.
125
125
  - Matching failures from `after_provider_response` can trigger fallback immediately.
126
- - Assistant error messages parsed at `turn_end` can also persist fallback state for SDK/provider failures that do not emit the normal response hook. Status extraction looks for HTTP-style tokens (for example `status 429`, `HTTP 503`, or `rate limit`) rather than any bare 3-digit number in the message.
126
+ - Assistant error messages parsed at `turn_end` can also persist fallback state for SDK/provider failures that do not emit the normal response hook. Status extraction looks for HTTP-style tokens (for example `status 429`, `HTTP 503`, or `rate limit`) rather than any bare 3-digit number in the message. A status in parentheses is only recognized when an error wrapper keyword precedes it, as in `omni API error (503): ...`; a parenthesized number with no such wrapper, such as `(503) items processed`, stays unmatched.
127
127
  - With the default `autoRetry: true`, the failed prompt is automatically queued once per fallback transition on the fallback model. A fallback chain may therefore replay the prompt more than once. Set `autoRetry: false` to switch models without replaying it.
128
128
 
129
129
  Rules never fall back to the failing model itself; a rule whose fallback target equals the failing model is skipped so the next matching rule (or no rule) applies.
@@ -51,6 +51,13 @@ export function parseStatusFromErrorMessage(message: string): number | undefined
51
51
  // "429 tokens remaining in context window", which must stay unmatched.
52
52
  /^\s*error\s*:?\s*([1-5][0-9]{2})\b/i,
53
53
  /\b(?:status|code|http)\s*[:\s]?\s*([1-5][0-9]{2})\b/i,
54
+ // Parenthesized status inside a provider error wrapper, e.g.
55
+ // "omni API error (503): overloaded" or "chat_completion_error (429): ...".
56
+ // Without this the wrapper text sits between "error" and the number, so the
57
+ // anchored "error <status>" pattern cannot see it and the rule set never
58
+ // sees a status at all. The wrapper keyword and the parentheses are both
59
+ // required so prose such as "(503) items processed" stays unmatched.
60
+ /\b\w*(?:error|failure|failed)\s*\(\s*([1-5][0-9]{2})\s*\)/i,
54
61
  /\bHTTP\/\d(?:\.\d)?\s+([1-5][0-9]{2})\b/,
55
62
  /\b(?:rate[\s-]?limit(?:ed)?|too many requests)[^0-9]{0,40}([45][0-9]{2})\b/i,
56
63
  /\b([45][0-9]{2})\s+(?:error|quota|too many requests|service unavailable|bad gateway|gateway timeout|internal server error)\b/i,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-model-fallback",
3
- "version": "0.5.1",
3
+ "version": "0.5.2",
4
4
  "description": "Pi extension that switches to a fallback model after provider failures such as 429 rate limits.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -50,10 +50,10 @@
50
50
  "typebox": "*"
51
51
  },
52
52
  "devDependencies": {
53
- "@earendil-works/pi-agent-core": "^0.99.1",
54
- "@earendil-works/pi-ai": "^0.99.1",
55
- "@earendil-works/pi-coding-agent": "^0.99.1",
56
- "@earendil-works/pi-tui": "^0.99.1",
53
+ "@earendil-works/pi-agent-core": "^1.0.4",
54
+ "@earendil-works/pi-ai": "^1.0.4",
55
+ "@earendil-works/pi-coding-agent": "^1.0.4",
56
+ "@earendil-works/pi-tui": "^1.0.4",
57
57
  "@types/node": "^26.6.3",
58
58
  "jiti": "^2.7.0",
59
59
  "typebox": "latest",