pi-tool-duration 0.2.2 → 0.2.3
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 +6 -0
- package/README.md +1 -1
- package/extensions/tool-duration/index.ts +11 -5
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.2.3] - 2026-09-18
|
|
4
|
+
|
|
5
|
+
### Fixed
|
|
6
|
+
|
|
7
|
+
- Preserve timing in native compaction input when long tool output is truncated, including split-turn summaries. Ordinary requests still append one duration marker, and recorded tool content and details remain unchanged.
|
|
8
|
+
|
|
3
9
|
## [0.2.2] - 2026-09-18
|
|
4
10
|
|
|
5
11
|
### Fixed
|
package/README.md
CHANGED
|
@@ -19,7 +19,7 @@ The extension measures from Pi's `tool_execution_start` through `tool_execution_
|
|
|
19
19
|
[duration: 5.0s]
|
|
20
20
|
```
|
|
21
21
|
|
|
22
|
-
Compaction
|
|
22
|
+
Compaction input copies put timing before the tool output so it survives Pi's truncation of long results. Recorded tool output stays unchanged, including after reload, resume, and branch navigation. Timings remain available to the model across those transitions without duplicating Pi's native TUI timing such as `Took 5.0s`.
|
|
23
23
|
|
|
24
24
|
Markers already saved as tool text by versions through 0.2.1 remain unchanged. They cannot be safely distinguished from genuine tool output with the same text.
|
|
25
25
|
|
|
@@ -27,7 +27,11 @@ function thresholdMs(pi: ExtensionAPI): number {
|
|
|
27
27
|
);
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
function withDurations(
|
|
30
|
+
function withDurations(
|
|
31
|
+
messages: ContextEvent["messages"],
|
|
32
|
+
ctx: ExtensionContext,
|
|
33
|
+
position: "append" | "prepend" = "append",
|
|
34
|
+
) {
|
|
31
35
|
const saved = new Map<string, string>();
|
|
32
36
|
for (const entry of ctx.sessionManager.getBranch()) {
|
|
33
37
|
if (entry.type !== "custom" || entry.customType !== TIMING_ENTRY) continue;
|
|
@@ -44,9 +48,10 @@ function withDurations(messages: ContextEvent["messages"], ctx: ExtensionContext
|
|
|
44
48
|
if (message.role !== "toolResult") return message;
|
|
45
49
|
const duration = saved.get(`${message.timestamp}:${message.toolCallId}`);
|
|
46
50
|
if (!duration) return message;
|
|
51
|
+
const marker = { type: "text" as const, text: duration };
|
|
47
52
|
return {
|
|
48
53
|
...message,
|
|
49
|
-
content:
|
|
54
|
+
content: position === "prepend" ? [marker, ...message.content] : [...message.content, marker],
|
|
50
55
|
};
|
|
51
56
|
});
|
|
52
57
|
}
|
|
@@ -92,9 +97,10 @@ export default function (pi: ExtensionAPI) {
|
|
|
92
97
|
pi.on("context", (event, ctx) => ({ messages: withDurations(event.messages, ctx) }));
|
|
93
98
|
|
|
94
99
|
pi.on("session_before_compact", ({ preparation }, ctx) => {
|
|
95
|
-
// Native summarization bypasses context hooks
|
|
96
|
-
|
|
97
|
-
preparation.
|
|
100
|
+
// Native summarization bypasses context hooks and truncates tool text from the end.
|
|
101
|
+
// Put timing first in its input copies, never in saved messages or ordinary requests.
|
|
102
|
+
preparation.messagesToSummarize = withDurations(preparation.messagesToSummarize, ctx, "prepend");
|
|
103
|
+
preparation.turnPrefixMessages = withDurations(preparation.turnPrefixMessages, ctx, "prepend");
|
|
98
104
|
});
|
|
99
105
|
|
|
100
106
|
const clearTimings = () => {
|