pi-harness-runtime 0.9.5 → 0.9.6
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 +14 -0
- package/index.ts +45 -6
- package/package.json +1 -1
- package/packages/a2a-adapter/package.json +1 -1
- package/packages/auth/package.json +1 -1
- package/packages/autonomous-refactor/package.json +1 -1
- package/packages/cache-strategy/package.json +1 -1
- package/packages/capability-registry/package.json +1 -1
- package/packages/checkpoint/package.json +1 -1
- package/packages/cli-plugin-sdk/package.json +1 -1
- package/packages/code-generation/package.json +1 -1
- package/packages/code-review/package.json +1 -1
- package/packages/codex-adapter/package.json +1 -1
- package/packages/context-compiler/package.json +1 -1
- package/packages/context-manager/package.json +1 -1
- package/packages/cost-optimizer/package.json +1 -1
- package/packages/django-plugin/package.json +1 -1
- package/packages/doc-generator/package.json +1 -1
- package/packages/evaluation-engine/package.json +1 -1
- package/packages/evaluation-runner/package.json +1 -1
- package/packages/experience-replay/package.json +1 -1
- package/packages/feedback-collector/package.json +1 -1
- package/packages/framework-detector/package.json +1 -1
- package/packages/framework-plugin-sdk/package.json +1 -1
- package/packages/frappe-plugin/package.json +1 -1
- package/packages/generic-web-plugin/package.json +1 -1
- package/packages/health-monitor/package.json +1 -1
- package/packages/laravel-plugin/package.json +1 -1
- package/packages/learning-engine/package.json +1 -1
- package/packages/mcp-adapter/package.json +1 -1
- package/packages/memory-engine/package.json +1 -1
- package/packages/model-registry/package.json +1 -1
- package/packages/nextjs-plugin/package.json +1 -1
- package/packages/notification/package.json +1 -1
- package/packages/observability/package.json +1 -1
- package/packages/performance-optimizer/package.json +1 -1
- package/packages/project-analyzer/package.json +1 -1
- package/packages/prompt-compiler/package.json +1 -1
- package/packages/prompt-versioning/package.json +1 -1
- package/packages/provider-adapter-sdk/package.json +1 -1
- package/packages/provider-router/package.json +1 -1
- package/packages/provider-selector/package.json +1 -1
- package/packages/providers/package.json +1 -1
- package/packages/quota-manager/package.json +1 -1
- package/packages/rate-limiter/package.json +1 -1
- package/packages/react-vite-plugin/package.json +1 -1
- package/packages/release-manager/package.json +1 -1
- package/packages/requirement-compiler/package.json +1 -1
- package/packages/runtime/package.json +1 -1
- package/packages/scheduler/package.json +1 -1
- package/packages/session/package.json +1 -1
- package/packages/shared-context/package.json +1 -1
- package/packages/skill-registry/package.json +1 -1
- package/packages/sprint-planner/package.json +1 -1
- package/packages/task-compiler/package.json +1 -1
- package/packages/test-data-generator/package.json +1 -1
- package/packages/test-generator/package.json +1 -1
- package/packages/token-estimation/package.json +1 -1
- package/packages/token-optimizer/package.json +1 -1
- package/packages/tui/package.json +1 -1
- package/packages/types/package.json +1 -1
- package/packages/worktree/package.json +1 -1
- package/proactive-compact.ts +28 -6
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,20 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
### [0.9.6](https://github.com/ManotLuijiu/pi-harness-runtime/compare/v0.9.5...v0.9.6) (2026-07-16)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* harden auto-resume after compaction ([13378e8](https://github.com/ManotLuijiu/pi-harness-runtime/commit/13378e852c984ead0e66f0adeffc073ff58af50c))
|
|
11
|
+
|
|
12
|
+
### [0.9.3](https://github.com/ManotLuijiu/pi-harness-runtime/compare/v0.5.0-beta.1...v0.9.3) (2026-07-14)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### Bug Fixes
|
|
16
|
+
|
|
17
|
+
* auto-resume pi dev with literal resume ([#51](https://github.com/ManotLuijiu/pi-harness-runtime/issues/51)) ([fd98762](https://github.com/ManotLuijiu/pi-harness-runtime/commit/fd987629f6062a4a7ff7a28d9dfb607962f5a4a9))
|
|
18
|
+
|
|
5
19
|
### [0.9.5](https://github.com/ManotLuijiu/pi-harness-runtime/compare/v0.9.4...v0.9.5) (2026-07-15)
|
|
6
20
|
|
|
7
21
|
|
package/index.ts
CHANGED
|
@@ -25,6 +25,7 @@ import { MiniMaxQuotaScraper } from "./harness/e2e/minimax-quota-scraper.js";
|
|
|
25
25
|
import { parseMiniMaxQuotaText } from "./harness/e2e/minimax-quota-parser.js";
|
|
26
26
|
import { buildFooterStatusValue } from "./footer-status.ts";
|
|
27
27
|
import {
|
|
28
|
+
MAX_PROACTIVE_COMPACT_FAILURES,
|
|
28
29
|
OUTPUT_LIMIT_RESUME_PROMPT,
|
|
29
30
|
PROACTIVE_COMPACT_COOLDOWN_MS,
|
|
30
31
|
shouldQueueOutputLimitResume,
|
|
@@ -109,7 +110,8 @@ export default function (pi: ExtensionAPI) {
|
|
|
109
110
|
)
|
|
110
111
|
) {
|
|
111
112
|
outputLimitResumeAttempts += 1;
|
|
112
|
-
|
|
113
|
+
pendingOutputLimitResumeAfterCompact = true;
|
|
114
|
+
queueAutoResume("output-limit", OUTPUT_LIMIT_RESUME_PROMPT, "steer");
|
|
113
115
|
} else if (m.stopReason === "stop") {
|
|
114
116
|
outputLimitResumeAttempts = 0;
|
|
115
117
|
}
|
|
@@ -141,7 +143,10 @@ export default function (pi: ExtensionAPI) {
|
|
|
141
143
|
let quotaAutoFetchInFlight = false;
|
|
142
144
|
let proactiveCompactInFlight = false;
|
|
143
145
|
let lastProactiveCompactAt = 0;
|
|
146
|
+
let consecutiveCompactFailures = 0;
|
|
147
|
+
let proactiveCompactCircuitReported = false;
|
|
144
148
|
let outputLimitResumeAttempts = 0;
|
|
149
|
+
let pendingOutputLimitResumeAfterCompact = false;
|
|
145
150
|
|
|
146
151
|
function writeMirrorRecord(record: MirrorRecord): void {
|
|
147
152
|
mirrorStore.write(record);
|
|
@@ -682,20 +687,42 @@ export default function (pi: ExtensionAPI) {
|
|
|
682
687
|
footerStatusCtx = ctx;
|
|
683
688
|
proactiveCompactInFlight = false;
|
|
684
689
|
lastProactiveCompactAt = Date.now();
|
|
685
|
-
|
|
690
|
+
consecutiveCompactFailures = 0;
|
|
691
|
+
proactiveCompactCircuitReported = false;
|
|
686
692
|
refreshFooterStatus(ctx, tracker, mirrorStore);
|
|
687
693
|
|
|
688
|
-
|
|
694
|
+
const forceOutputLimitResume = pendingOutputLimitResumeAfterCompact;
|
|
695
|
+
pendingOutputLimitResumeAfterCompact = false;
|
|
696
|
+
|
|
697
|
+
if (
|
|
698
|
+
!shouldQueuePostCompactionResume(event, ctx.hasPendingMessages(), {
|
|
699
|
+
force: forceOutputLimitResume,
|
|
700
|
+
})
|
|
701
|
+
) {
|
|
702
|
+
return;
|
|
703
|
+
}
|
|
704
|
+
|
|
705
|
+
if (forceOutputLimitResume) {
|
|
706
|
+
queueAutoResume(
|
|
707
|
+
"post-compact-output-limit",
|
|
708
|
+
OUTPUT_LIMIT_RESUME_PROMPT,
|
|
709
|
+
event.willRetry ? "steer" : "followUp",
|
|
710
|
+
);
|
|
689
711
|
return;
|
|
690
712
|
}
|
|
691
713
|
|
|
714
|
+
outputLimitResumeAttempts = 0;
|
|
692
715
|
// pi.dev expects the literal "resume" command to continue after compaction.
|
|
693
|
-
queueAutoResume("post-compact", "resume");
|
|
716
|
+
queueAutoResume("post-compact", "resume", "followUp");
|
|
694
717
|
});
|
|
695
718
|
|
|
696
|
-
function queueAutoResume(
|
|
719
|
+
function queueAutoResume(
|
|
720
|
+
reason: string,
|
|
721
|
+
content: string,
|
|
722
|
+
deliverAs: "steer" | "followUp",
|
|
723
|
+
): void {
|
|
697
724
|
try {
|
|
698
|
-
pi.sendUserMessage(content, { deliverAs
|
|
725
|
+
pi.sendUserMessage(content, { deliverAs });
|
|
699
726
|
} catch (error) {
|
|
700
727
|
console.error(
|
|
701
728
|
`[pi-harness] Failed to queue ${reason} auto-resume:`,
|
|
@@ -708,6 +735,15 @@ export default function (pi: ExtensionAPI) {
|
|
|
708
735
|
if (proactiveCompactInFlight) {
|
|
709
736
|
return;
|
|
710
737
|
}
|
|
738
|
+
if (consecutiveCompactFailures >= MAX_PROACTIVE_COMPACT_FAILURES) {
|
|
739
|
+
if (!proactiveCompactCircuitReported) {
|
|
740
|
+
proactiveCompactCircuitReported = true;
|
|
741
|
+
console.error(
|
|
742
|
+
`[pi-harness] Proactive compact disabled after ${consecutiveCompactFailures} consecutive failures`,
|
|
743
|
+
);
|
|
744
|
+
}
|
|
745
|
+
return;
|
|
746
|
+
}
|
|
711
747
|
if (!ctx.isIdle() || ctx.hasPendingMessages()) {
|
|
712
748
|
return;
|
|
713
749
|
}
|
|
@@ -728,9 +764,12 @@ export default function (pi: ExtensionAPI) {
|
|
|
728
764
|
onComplete: () => {
|
|
729
765
|
proactiveCompactInFlight = false;
|
|
730
766
|
lastProactiveCompactAt = Date.now();
|
|
767
|
+
consecutiveCompactFailures = 0;
|
|
768
|
+
proactiveCompactCircuitReported = false;
|
|
731
769
|
},
|
|
732
770
|
onError: (error) => {
|
|
733
771
|
proactiveCompactInFlight = false;
|
|
772
|
+
consecutiveCompactFailures += 1;
|
|
734
773
|
console.error("[pi-harness] Proactive compact failed:", error.message);
|
|
735
774
|
},
|
|
736
775
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pi-harness/provider-router",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.6",
|
|
4
4
|
"description": "Enhanced Provider Router for pi-harness-runtime — intelligent routing with capabilities, costs, and quotas",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/provider-router.js",
|
package/proactive-compact.ts
CHANGED
|
@@ -1,20 +1,32 @@
|
|
|
1
1
|
import type { ContextUsage } from "@earendil-works/pi-coding-agent";
|
|
2
2
|
|
|
3
3
|
export const PROACTIVE_COMPACT_THRESHOLD = 0.9;
|
|
4
|
+
export const PROACTIVE_COMPACT_HEADROOM_TOKENS = 15_000;
|
|
4
5
|
export const PROACTIVE_COMPACT_COOLDOWN_MS = 10 * 60 * 1000;
|
|
6
|
+
export const MAX_PROACTIVE_COMPACT_FAILURES = 3;
|
|
5
7
|
export const OUTPUT_LIMIT_AUTO_RESUME_LIMIT = 3;
|
|
6
8
|
export const OUTPUT_LIMIT_RESUME_PROMPT =
|
|
7
9
|
"Output token limit hit. Resume directly — no apology, no recap. Pick up mid-thought if the cut happened there. Break remaining work into smaller pieces.";
|
|
8
10
|
|
|
9
11
|
export function shouldTriggerProactiveCompact(
|
|
10
12
|
usage: ContextUsage | undefined,
|
|
11
|
-
options?: { threshold?: number },
|
|
13
|
+
options?: { threshold?: number; headroomTokens?: number },
|
|
12
14
|
): boolean {
|
|
13
|
-
|
|
14
|
-
if (!usage || usage.percent === null) {
|
|
15
|
+
if (!usage) {
|
|
15
16
|
return false;
|
|
16
17
|
}
|
|
17
|
-
|
|
18
|
+
|
|
19
|
+
const headroomTokens =
|
|
20
|
+
options?.headroomTokens ?? PROACTIVE_COMPACT_HEADROOM_TOKENS;
|
|
21
|
+
if (
|
|
22
|
+
usage.tokens !== null &&
|
|
23
|
+
usage.contextWindow - usage.tokens <= headroomTokens
|
|
24
|
+
) {
|
|
25
|
+
return true;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const threshold = options?.threshold ?? PROACTIVE_COMPACT_THRESHOLD;
|
|
29
|
+
return usage.percent !== null && usage.percent >= threshold;
|
|
18
30
|
}
|
|
19
31
|
|
|
20
32
|
export type AssistantStopLike = {
|
|
@@ -61,8 +73,18 @@ export function shouldQueueOutputLimitResume(
|
|
|
61
73
|
}
|
|
62
74
|
|
|
63
75
|
export function shouldQueuePostCompactionResume(
|
|
64
|
-
event: {
|
|
76
|
+
event: {
|
|
77
|
+
willRetry?: boolean;
|
|
78
|
+
reason?: "manual" | "threshold" | "overflow" | string;
|
|
79
|
+
},
|
|
65
80
|
hasPendingMessages: boolean,
|
|
81
|
+
options?: { force?: boolean },
|
|
66
82
|
): boolean {
|
|
67
|
-
|
|
83
|
+
if (event.reason === "manual" && options?.force !== true) {
|
|
84
|
+
return false;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
return (
|
|
88
|
+
(options?.force === true || event.willRetry !== true) && !hasPendingMessages
|
|
89
|
+
);
|
|
68
90
|
}
|