pi-goal-list-loop-audit 0.38.39 → 0.38.40

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
@@ -1,5 +1,16 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.38.40 — provider overflow errors count as starvation (2026-09-09)
4
+
5
+ ### Fixed
6
+
7
+ - **PR #48 (Bjynt, merged):** `isContextStarvedLengthStop` now detects explicit provider context-overflow errors (`exceed_context_size_error`, `exceeds the available context size`, `context window exceeded`, …) arriving as `stopReason="error"`, firing the starvation ladder + emergency compactor (≥90% usage gate kept). Case 1 refactor is behavior-identical. Wiring confirmed live via the raw session message's `errorMessage`.
8
+ - Follow-up noted on the PR: OpenAI-style `maximum context length` wording still falls through the matcher set.
9
+
10
+ ### Verification
11
+
12
+ - Contributor's Case 2 tests + full `release:check` 0 failures; `tsc --noEmit` clean.
13
+
3
14
  ## 0.38.39 — Codex-like terminal summary (2026-09-09)
4
15
 
5
16
  ### Fixed
package/docs/INDEX.md CHANGED
@@ -18,7 +18,7 @@ For shipped docs, the relevant entry points are:
18
18
  failback; v0.35.9 hardened cross-version npm tarball checks; v0.35.10
19
19
  handles multi-entry npm dry-run reports; v0.35.11 accepts both npm report
20
20
  shapes; v0.35.12 supports npm 12's keyed pack reports; v0.35.13 fixes stale-API recovery loops.
21
- v0.35.14–v0.38.39 continue through the supervisor freeze (`/glla pause`),
21
+ v0.35.14–v0.38.40 continue through the supervisor freeze (`/glla pause`),
22
22
  load hold, auditor picker parity, Windows launch fix, zombie-watchdog
23
23
  subagent carve-out, due-wait backstop, the `/glla agents` visibility panel,
24
24
  durable state-root selection, blank-until-resume auditor context, frozen
@@ -46,6 +46,10 @@ export interface AssistantLengthMessageLike {
46
46
  usage?: {
47
47
  output?: number;
48
48
  };
49
+ /** Provider error message, when stopReason is "error". */
50
+ errorMessage?: string;
51
+ /** Error type from provider (e.g., "exceed_context_size_error"). */
52
+ errorType?: string;
49
53
  }
50
54
 
51
55
  export const LENGTH_CONTINUE_CONTEXT_STARVED_PERCENT = 90;
@@ -60,21 +64,49 @@ export const LENGTH_CONTINUE_CONTEXT_STARVED_MAX_OUTPUT = 8;
60
64
  * here queues another 1-token request before pi's post-agent_end compaction
61
65
  * check and delays the actual cure (field: darklord 2026-08-02, 198,116 /
62
66
  * 198,179 total tokens of a 200,000 window, output=1 twice).
67
+ *
68
+ * v0.38.36: also detect explicit context-overflow provider errors
69
+ * (e.g., "exceed_context_size_error", "exceeds the available context size")
70
+ * which arrive as stopReason="error" with an errorMessage, not as
71
+ * stopReason="length". These are also context starvation — the request
72
+ * exceeded the model's context window before generation could start.
63
73
  */
64
74
  export function isContextStarvedLengthStop(
65
75
  message: AssistantLengthMessageLike | null | undefined,
66
76
  contextUsage: ContextUsageLike | null | undefined,
67
77
  ): boolean {
68
- if (message?.stopReason !== "length") return false;
69
- const output = message.usage?.output;
70
- if (typeof output !== "number" || !Number.isFinite(output)) return false;
71
- if (output > LENGTH_CONTINUE_CONTEXT_STARVED_MAX_OUTPUT) return false;
72
- const percent = typeof contextUsage?.percent === "number"
73
- ? contextUsage.percent
74
- : typeof contextUsage?.tokens === "number" && typeof contextUsage?.contextWindow === "number" && contextUsage.contextWindow > 0
75
- ? (contextUsage.tokens / contextUsage.contextWindow) * 100
76
- : null;
77
- return percent !== null && Number.isFinite(percent) && percent >= LENGTH_CONTINUE_CONTEXT_STARVED_PERCENT;
78
+ // Case 1: pi's context-safety clamp (stopReason="length" with tiny output)
79
+ if (message?.stopReason === "length") {
80
+ const output = message.usage?.output;
81
+ if (typeof output === "number" && Number.isFinite(output) && output <= LENGTH_CONTINUE_CONTEXT_STARVED_MAX_OUTPUT) {
82
+ const percent = typeof contextUsage?.percent === "number"
83
+ ? contextUsage.percent
84
+ : typeof contextUsage?.tokens === "number" && typeof contextUsage?.contextWindow === "number" && contextUsage.contextWindow > 0
85
+ ? (contextUsage.tokens / contextUsage.contextWindow) * 100
86
+ : null;
87
+ return percent !== null && Number.isFinite(percent) && percent >= LENGTH_CONTINUE_CONTEXT_STARVED_PERCENT;
88
+ }
89
+ return false; // Real overlong response, not context starvation
90
+ }
91
+ // Case 2: explicit provider context-overflow error (stopReason="error")
92
+ if (message?.stopReason === "error") {
93
+ const errMsg = (message.errorMessage ?? message.errorType ?? "").toLowerCase();
94
+ if (
95
+ errMsg.includes("exceed_context_size") ||
96
+ errMsg.includes("exceeds the available context") ||
97
+ errMsg.includes("exceeds the context window") ||
98
+ (errMsg.includes("exceeds the model") && errMsg.includes("context")) ||
99
+ (errMsg.includes("context window") && errMsg.includes("exceed"))
100
+ ) {
101
+ const percent = typeof contextUsage?.percent === "number"
102
+ ? contextUsage.percent
103
+ : typeof contextUsage?.tokens === "number" && typeof contextUsage?.contextWindow === "number" && contextUsage.contextWindow > 0
104
+ ? (contextUsage.tokens / contextUsage.contextWindow) * 100
105
+ : null;
106
+ return percent !== null && Number.isFinite(percent) && percent >= LENGTH_CONTINUE_CONTEXT_STARVED_PERCENT;
107
+ }
108
+ }
109
+ return false;
78
110
  }
79
111
 
80
112
  export function makeLengthContinueTracker(max: number = LENGTH_CONTINUE_MAX) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-goal-list-loop-audit",
3
- "version": "0.38.39",
3
+ "version": "0.38.40",
4
4
  "description": "Mission control for autonomous pi: interview-drafted goals, an audited task queue, and forever-loops (metric, spec, project-audit) that run for hours. A detached extension-less auditor process re-verifies every completion with raw evidence without holding the main pi turn; confirmed drafts, decision pauses and consent gates keep you in charge.",
5
5
  "license": "AGPL-3.0-only",
6
6
  "author": "dracon",