@monotykamary/pi-tps 1.1.0 → 1.1.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.
|
@@ -128,15 +128,15 @@ describe('pi-tps extension — dynamic TPS cap', () => {
|
|
|
128
128
|
messageEnd: 900,
|
|
129
129
|
});
|
|
130
130
|
|
|
131
|
-
// Turn 2: tool call with fallback TPS (2 updates,
|
|
132
|
-
// Without cap: 20 tokens / 0.
|
|
133
|
-
// With cap: min(
|
|
131
|
+
// Turn 2: tool call with fallback TPS (2 updates, 250ms generationMs)
|
|
132
|
+
// Without cap: 20 tokens / 0.25s ≈ 80 TPS (feasible but from short window)
|
|
133
|
+
// With cap: min(80, 50) = 50 TPS
|
|
134
134
|
const { appendEntrySpy, notifySpy } = driveTurn({
|
|
135
135
|
turnStart: 0,
|
|
136
136
|
messageStart: 100,
|
|
137
137
|
firstUpdate: 100.1,
|
|
138
138
|
streamUpdates: [100.15, 100.3],
|
|
139
|
-
messageEnd:
|
|
139
|
+
messageEnd: 350,
|
|
140
140
|
isToolCall: true,
|
|
141
141
|
});
|
|
142
142
|
|
|
@@ -147,20 +147,20 @@ describe('pi-tps extension — dynamic TPS cap', () => {
|
|
|
147
147
|
expect(data.tps).toBeGreaterThan(0);
|
|
148
148
|
});
|
|
149
149
|
|
|
150
|
-
// ── Tool calls do not set the cap
|
|
150
|
+
// ── Tool calls do not set the cap from fallback ─────────────────────────────
|
|
151
151
|
|
|
152
|
-
it('should not let tool-call turns set the cap', () => {
|
|
153
|
-
// Turn 1: tool call
|
|
152
|
+
it('should not let fallback-branch tool-call turns set the cap', () => {
|
|
153
|
+
// Turn 1: tool call with fallback TPS — should NOT set the cap
|
|
154
154
|
const { appendEntrySpy: spy1 } = driveTurn({
|
|
155
155
|
turnStart: 0,
|
|
156
156
|
messageStart: 100,
|
|
157
157
|
firstUpdate: 100.1,
|
|
158
158
|
streamUpdates: [100.15, 100.3],
|
|
159
|
-
messageEnd:
|
|
159
|
+
messageEnd: 350,
|
|
160
160
|
isToolCall: true,
|
|
161
161
|
});
|
|
162
162
|
const [, data1] = spy1.mock.calls[0];
|
|
163
|
-
// No cap → tool call TPS is null
|
|
163
|
+
// No cap → fallback tool call TPS is null
|
|
164
164
|
expect(data1.tps).toBeNull();
|
|
165
165
|
|
|
166
166
|
// Turn 2: reliable streaming response at ~50 TPS → sets the cap
|
|
@@ -175,13 +175,13 @@ describe('pi-tps extension — dynamic TPS cap', () => {
|
|
|
175
175
|
expect(data2.tps).toBeGreaterThanOrEqual(40);
|
|
176
176
|
expect(data2.tps).toBeLessThanOrEqual(60);
|
|
177
177
|
|
|
178
|
-
// Turn 3: another tool call — should now be clamped to 50
|
|
178
|
+
// Turn 3: another fallback tool call — should now be clamped to 50
|
|
179
179
|
const { appendEntrySpy: spy3 } = driveTurn({
|
|
180
180
|
turnStart: 0,
|
|
181
181
|
messageStart: 100,
|
|
182
182
|
firstUpdate: 100.1,
|
|
183
183
|
streamUpdates: [100.15, 100.3],
|
|
184
|
-
messageEnd:
|
|
184
|
+
messageEnd: 350,
|
|
185
185
|
isToolCall: true,
|
|
186
186
|
});
|
|
187
187
|
const [, data3] = spy3.mock.calls[2];
|
|
@@ -189,6 +189,40 @@ describe('pi-tps extension — dynamic TPS cap', () => {
|
|
|
189
189
|
expect(data3.tps).toBeLessThanOrEqual(55);
|
|
190
190
|
});
|
|
191
191
|
|
|
192
|
+
// ── Primary-branch tool calls (reasoning) set the cap ──────────────────────
|
|
193
|
+
|
|
194
|
+
it('should let primary-branch tool-call turns set the cap (e.g. reasoning before tool call)', () => {
|
|
195
|
+
// Turn 1: tool call with PRIMARY-branch TPS (reasoning + tool call, enough updates/time)
|
|
196
|
+
// 20 tokens / 0.4s = 50 TPS from primary branch, isToolCall = true
|
|
197
|
+
const { appendEntrySpy: spy1 } = driveTurn({
|
|
198
|
+
turnStart: 0,
|
|
199
|
+
messageStart: 200,
|
|
200
|
+
firstUpdate: 200.123,
|
|
201
|
+
streamUpdates: [400, 500, 600, 700, 800],
|
|
202
|
+
messageEnd: 900,
|
|
203
|
+
isToolCall: true,
|
|
204
|
+
});
|
|
205
|
+
const [, data1] = spy1.mock.calls[0];
|
|
206
|
+
// Primary branch + isToolCall → TPS is still computed (not null/capped)
|
|
207
|
+
expect(data1.tps).toBeGreaterThanOrEqual(40);
|
|
208
|
+
expect(data1.tps).toBeLessThanOrEqual(60);
|
|
209
|
+
expect(data1.isPrimaryBranch).toBe(true);
|
|
210
|
+
|
|
211
|
+
// Turn 2: fallback tool call — should be clamped to the cap from turn 1
|
|
212
|
+
const { appendEntrySpy: spy2 } = driveTurn({
|
|
213
|
+
turnStart: 0,
|
|
214
|
+
messageStart: 100,
|
|
215
|
+
firstUpdate: 100.1,
|
|
216
|
+
streamUpdates: [100.15, 100.3],
|
|
217
|
+
messageEnd: 350,
|
|
218
|
+
isToolCall: true,
|
|
219
|
+
});
|
|
220
|
+
const [, data2] = spy2.mock.calls[1];
|
|
221
|
+
expect(data2.tps).not.toBeNull();
|
|
222
|
+
// Clamped to ~50 cap set by the primary-branch tool call in turn 1
|
|
223
|
+
expect(data2.tps).toBeLessThanOrEqual(55);
|
|
224
|
+
});
|
|
225
|
+
|
|
192
226
|
// ── Cold start: no cap yet ────────────────────────────────────────────────
|
|
193
227
|
|
|
194
228
|
it('should show null TPS for tool calls when no cap exists yet', () => {
|
|
@@ -197,7 +231,7 @@ describe('pi-tps extension — dynamic TPS cap', () => {
|
|
|
197
231
|
messageStart: 100,
|
|
198
232
|
firstUpdate: 100.1,
|
|
199
233
|
streamUpdates: [100.15, 100.3],
|
|
200
|
-
messageEnd:
|
|
234
|
+
messageEnd: 350,
|
|
201
235
|
isToolCall: true,
|
|
202
236
|
});
|
|
203
237
|
|
|
@@ -228,7 +262,7 @@ describe('pi-tps extension — dynamic TPS cap', () => {
|
|
|
228
262
|
messageStart: 100,
|
|
229
263
|
firstUpdate: 100.1,
|
|
230
264
|
streamUpdates: [100.15, 100.3],
|
|
231
|
-
messageEnd:
|
|
265
|
+
messageEnd: 350,
|
|
232
266
|
isToolCall: false,
|
|
233
267
|
});
|
|
234
268
|
|
|
@@ -344,7 +378,7 @@ describe('pi-tps extension — dynamic TPS cap', () => {
|
|
|
344
378
|
messageStart: 100,
|
|
345
379
|
firstUpdate: 100.1,
|
|
346
380
|
streamUpdates: [100.15, 100.3],
|
|
347
|
-
messageEnd:
|
|
381
|
+
messageEnd: 350,
|
|
348
382
|
isToolCall: true,
|
|
349
383
|
});
|
|
350
384
|
|
|
@@ -303,7 +303,7 @@ function buildTelemetry(timing: TurnTiming, turnEndMs: number): TurnTelemetry |
|
|
|
303
303
|
const MIN_STREAM_MS = 1;
|
|
304
304
|
const MIN_STREAM_UPDATES = 5;
|
|
305
305
|
const MIN_INTER_CHUNK_MS = 1;
|
|
306
|
-
const MIN_GENERATION_MS =
|
|
306
|
+
const MIN_GENERATION_MS = 200;
|
|
307
307
|
const ACTIVE_TIME_THRESHOLD_MS = 200;
|
|
308
308
|
const STALL_REDUCTION_DENOM = 2;
|
|
309
309
|
const STALL_DOMINANCE_RATIO = 0.85;
|
|
@@ -601,7 +601,7 @@ export default function tpsExtension(pi: ExtensionAPI) {
|
|
|
601
601
|
// short outputs over tiny time windows.
|
|
602
602
|
const modelKey = `${telemetry.model.provider}:${telemetry.model.modelId}`;
|
|
603
603
|
|
|
604
|
-
if (telemetry.isPrimaryBranch &&
|
|
604
|
+
if (telemetry.isPrimaryBranch && telemetry.tps !== null) {
|
|
605
605
|
const currentCap = tpsCaps.get(modelKey);
|
|
606
606
|
if (currentCap === undefined || telemetry.tps > currentCap) {
|
|
607
607
|
tpsCaps.set(modelKey, telemetry.tps);
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-tps",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.1",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "pi-tps",
|
|
9
|
-
"version": "1.1.
|
|
9
|
+
"version": "1.1.1",
|
|
10
10
|
"hasInstallScript": true,
|
|
11
11
|
"license": "MIT",
|
|
12
12
|
"devDependencies": {
|