@oh-my-pi/pi-agent-core 16.3.6 → 16.3.8
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/dist/types/agent-loop.d.ts +2 -2
- package/dist/types/agent.d.ts +2 -2
- package/dist/types/append-only-context.d.ts +1 -1
- package/dist/types/compaction/branch-summarization.d.ts +6 -6
- package/dist/types/compaction/compaction.d.ts +9 -6
- package/dist/types/compaction/entries.d.ts +1 -1
- package/dist/types/compaction/index.d.ts +9 -9
- package/dist/types/compaction/messages.d.ts +2 -2
- package/dist/types/compaction/openai.d.ts +1 -1
- package/dist/types/compaction/pruning.d.ts +2 -2
- package/dist/types/compaction/shake.d.ts +2 -2
- package/dist/types/compaction/tool-protection.d.ts +2 -2
- package/dist/types/compaction/utils.d.ts +1 -1
- package/dist/types/compaction.d.ts +1 -1
- package/dist/types/index.d.ts +12 -12
- package/dist/types/telemetry.d.ts +2 -2
- package/dist/types/types.d.ts +3 -3
- package/package.json +7 -7
- package/src/compaction/compaction.ts +9 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
## [Unreleased]
|
|
4
4
|
|
|
5
|
+
## [16.3.7] - 2026-07-05
|
|
6
|
+
|
|
7
|
+
### Fixed
|
|
8
|
+
|
|
9
|
+
- Fixed an issue where provider orchestration tokens were incorrectly included in context token calculations, which could trigger premature context auto-compaction and promotion.
|
|
10
|
+
|
|
5
11
|
## [16.3.3] - 2026-07-02
|
|
6
12
|
|
|
7
13
|
### Changed
|
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { type Context, EventStream } from "@oh-my-pi/pi-ai";
|
|
6
6
|
import { type Dialect } from "@oh-my-pi/pi-ai/dialect";
|
|
7
|
-
import { type AgentRunCoverage, type AgentRunSummary } from "./run-collector";
|
|
8
|
-
import type { AgentContext, AgentEvent, AgentLoopConfig, AgentMessage, StreamFn } from "./types";
|
|
7
|
+
import { type AgentRunCoverage, type AgentRunSummary } from "./run-collector.js";
|
|
8
|
+
import type { AgentContext, AgentEvent, AgentLoopConfig, AgentMessage, StreamFn } from "./types.js";
|
|
9
9
|
/** Stop-details marker for a provider error after assistant content/tool args already streamed. */
|
|
10
10
|
export declare const STREAM_INTERRUPTED_AFTER_CONTENT_STOP_DETAIL = "stream_interrupted_after_content";
|
|
11
11
|
export declare function resolveOwnedDialectFromEnv(value: string | undefined): Dialect | undefined;
|
package/dist/types/agent.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { type ApiKey, type AssistantMessage, type AssistantMessageEvent, type Context, type CursorExecHandlers, type CursorToolResultHandler, type Effort, type ImageContent, type Message, type Model, type ProviderSessionState, type ServiceTier, type SimpleStreamOptions, type ThinkingBudgets, type ToolChoice } from "@oh-my-pi/pi-ai";
|
|
2
2
|
import type { Dialect } from "@oh-my-pi/pi-ai/dialect";
|
|
3
3
|
import type { HarmonyAuditEvent } from "@oh-my-pi/pi-ai/utils/harmony-leak";
|
|
4
|
-
import type { AppendOnlyContextManager } from "./append-only-context";
|
|
5
|
-
import type { AgentEvent, AgentLoopConfig, AgentMessage, AgentState, AgentTool, AgentToolContext, AgentTurnEndContext, AsideMessage, StreamFn, ToolCallContext, ToolChoiceDirective } from "./types";
|
|
4
|
+
import type { AppendOnlyContextManager } from "./append-only-context.js";
|
|
5
|
+
import type { AgentEvent, AgentLoopConfig, AgentMessage, AgentState, AgentTool, AgentToolContext, AgentTurnEndContext, AsideMessage, StreamFn, ToolCallContext, ToolChoiceDirective } from "./types.js";
|
|
6
6
|
export declare class AgentBusyError extends Error {
|
|
7
7
|
constructor(message?: string);
|
|
8
8
|
}
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
*/
|
|
16
16
|
import type { Context, Message, Tool } from "@oh-my-pi/pi-ai";
|
|
17
17
|
import type { Dialect } from "@oh-my-pi/pi-ai/dialect";
|
|
18
|
-
import type { AgentContext } from "./types";
|
|
18
|
+
import type { AgentContext } from "./types.js";
|
|
19
19
|
/** Frozen system prompt + tool spec snapshot. */
|
|
20
20
|
export interface StablePrefixSnapshot {
|
|
21
21
|
systemPrompt: string[];
|
|
@@ -5,11 +5,11 @@
|
|
|
5
5
|
* a summary of the branch being left so context isn't lost.
|
|
6
6
|
*/
|
|
7
7
|
import type { Api, ApiKey, AssistantMessage, Context, Model, SimpleStreamOptions } from "@oh-my-pi/pi-ai";
|
|
8
|
-
import { type AgentTelemetry } from "../telemetry";
|
|
9
|
-
import type { AgentMessage } from "../types";
|
|
10
|
-
import type { ReadonlySessionManager, SessionEntry } from "./entries";
|
|
11
|
-
import { type ConvertToLlm } from "./messages";
|
|
12
|
-
import { type FileOperations } from "./utils";
|
|
8
|
+
import { type AgentTelemetry } from "../telemetry.js";
|
|
9
|
+
import type { AgentMessage } from "../types.js";
|
|
10
|
+
import type { ReadonlySessionManager, SessionEntry } from "./entries.js";
|
|
11
|
+
import { type ConvertToLlm } from "./messages.js";
|
|
12
|
+
import { type FileOperations } from "./utils.js";
|
|
13
13
|
export interface BranchSummaryResult {
|
|
14
14
|
summary?: string;
|
|
15
15
|
readFiles?: string[];
|
|
@@ -22,7 +22,7 @@ export interface BranchSummaryDetails {
|
|
|
22
22
|
readFiles: string[];
|
|
23
23
|
modifiedFiles: string[];
|
|
24
24
|
}
|
|
25
|
-
export type { FileOperations } from "./utils";
|
|
25
|
+
export type { FileOperations } from "./utils.js";
|
|
26
26
|
export interface BranchPreparation {
|
|
27
27
|
/** Messages extracted for summarization, in chronological order */
|
|
28
28
|
messages: AgentMessage[];
|
|
@@ -5,12 +5,12 @@
|
|
|
5
5
|
* and after compaction the session is reloaded.
|
|
6
6
|
*/
|
|
7
7
|
import { type Api, type ApiKey, type AssistantMessage, type Context, type FetchImpl, type MessageAttribution, type Model, type SimpleStreamOptions, type Tool, type Usage } from "@oh-my-pi/pi-ai";
|
|
8
|
-
import { type AgentTelemetry } from "../telemetry";
|
|
9
|
-
import { ThinkingLevel } from "../thinking";
|
|
10
|
-
import type { AgentMessage } from "../types";
|
|
11
|
-
import type { SessionEntry } from "./entries";
|
|
12
|
-
import { type ConvertToLlm } from "./messages";
|
|
13
|
-
import { type FileOperations } from "./utils";
|
|
8
|
+
import { type AgentTelemetry } from "../telemetry.js";
|
|
9
|
+
import { ThinkingLevel } from "../thinking.js";
|
|
10
|
+
import type { AgentMessage } from "../types.js";
|
|
11
|
+
import type { SessionEntry } from "./entries.js";
|
|
12
|
+
import { type ConvertToLlm } from "./messages.js";
|
|
13
|
+
import { type FileOperations } from "./utils.js";
|
|
14
14
|
/** Details stored in CompactionEntry.details for file tracking */
|
|
15
15
|
export interface CompactionDetails {
|
|
16
16
|
readFiles: string[];
|
|
@@ -56,6 +56,9 @@ export declare const DEFAULT_COMPACTION_SETTINGS: CompactionSettings;
|
|
|
56
56
|
/**
|
|
57
57
|
* Calculate total context tokens from usage.
|
|
58
58
|
* Uses the native totalTokens field when available, falls back to computing from components.
|
|
59
|
+
* Provider-side orchestration tokens are billable but never replay into the
|
|
60
|
+
* conversation prefix, so they are excluded from context sizing to keep
|
|
61
|
+
* auto-compaction and context-promotion thresholds honest.
|
|
59
62
|
*/
|
|
60
63
|
export declare function calculateContextTokens(usage: Usage): number;
|
|
61
64
|
export declare function calculatePromptTokens(usage: Usage): number;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ImageContent, MessageAttribution, ServiceTierByFamily, TextContent } from "@oh-my-pi/pi-ai";
|
|
2
|
-
import type { AgentMessage } from "../types";
|
|
2
|
+
import type { AgentMessage } from "../types.js";
|
|
3
3
|
export interface SessionEntryBase {
|
|
4
4
|
type: string;
|
|
5
5
|
id: string;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Compaction and summarization utilities.
|
|
3
3
|
*/
|
|
4
|
-
export * from "./branch-summarization";
|
|
5
|
-
export * from "./compaction";
|
|
6
|
-
export * from "./entries";
|
|
7
|
-
export * from "./errors";
|
|
8
|
-
export * from "./messages";
|
|
9
|
-
export * from "./openai";
|
|
10
|
-
export * from "./pruning";
|
|
11
|
-
export * from "./shake";
|
|
12
|
-
export * from "./utils";
|
|
4
|
+
export * from "./branch-summarization.js";
|
|
5
|
+
export * from "./compaction.js";
|
|
6
|
+
export * from "./entries.js";
|
|
7
|
+
export * from "./errors.js";
|
|
8
|
+
export * from "./messages.js";
|
|
9
|
+
export * from "./openai.js";
|
|
10
|
+
export * from "./pruning.js";
|
|
11
|
+
export * from "./shake.js";
|
|
12
|
+
export * from "./utils.js";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ImageContent, Message, MessageAttribution, ProviderPayload, TextContent } from "@oh-my-pi/pi-ai";
|
|
2
|
-
import type { AgentMessage } from "../types";
|
|
2
|
+
import type { AgentMessage } from "../types.js";
|
|
3
3
|
export interface CustomMessage<T = unknown> {
|
|
4
4
|
role: "custom";
|
|
5
5
|
customType: string;
|
|
@@ -42,7 +42,7 @@ export interface CompactionSummaryMessage {
|
|
|
42
42
|
timestamp: number;
|
|
43
43
|
}
|
|
44
44
|
export type CoreCompactionMessage = CustomMessage | HookMessage | BranchSummaryMessage | CompactionSummaryMessage;
|
|
45
|
-
declare module "../types" {
|
|
45
|
+
declare module "../types.js" {
|
|
46
46
|
interface CustomAgentMessages {
|
|
47
47
|
custom: CustomMessage;
|
|
48
48
|
hookMessage: HookMessage;
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
* with `{ summary, shortSummary? }`.
|
|
16
16
|
*/
|
|
17
17
|
import type { FetchImpl, Message, Model } from "@oh-my-pi/pi-ai/types";
|
|
18
|
-
export * from "./compaction-v2-streaming";
|
|
18
|
+
export * from "./compaction-v2-streaming.js";
|
|
19
19
|
export declare const OPENAI_REMOTE_COMPACTION_PRESERVE_KEY = "openaiRemoteCompaction";
|
|
20
20
|
/**
|
|
21
21
|
* Hard ceiling on remote compaction HTTP requests. Unlike every provider
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Tool output pruning utilities for compaction.
|
|
3
3
|
*/
|
|
4
|
-
import type { SessionEntry } from "./entries";
|
|
5
|
-
import { type ProtectedToolMatcher } from "./tool-protection";
|
|
4
|
+
import type { SessionEntry } from "./entries.js";
|
|
5
|
+
import { type ProtectedToolMatcher } from "./tool-protection.js";
|
|
6
6
|
export interface PruneConfig {
|
|
7
7
|
/** Keep the most recent tool output tokens intact. */
|
|
8
8
|
protectTokens: number;
|
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
*
|
|
10
10
|
* Layering mirrors `pruning.ts`: no I/O here.
|
|
11
11
|
*/
|
|
12
|
-
import type { CustomMessageEntry, SessionEntry, SessionMessageEntry } from "./entries";
|
|
13
|
-
import { type ProtectedToolMatcher } from "./tool-protection";
|
|
12
|
+
import type { CustomMessageEntry, SessionEntry, SessionMessageEntry } from "./entries.js";
|
|
13
|
+
import { type ProtectedToolMatcher } from "./tool-protection.js";
|
|
14
14
|
export interface ShakeConfig {
|
|
15
15
|
/** Keep the most recent context tokens (across all entries) intact. */
|
|
16
16
|
protectTokens: number;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ToolResultMessage } from "@oh-my-pi/pi-ai";
|
|
2
|
-
import type { AgentToolCall } from "../types";
|
|
3
|
-
import type { SessionEntry } from "./entries";
|
|
2
|
+
import type { AgentToolCall } from "../types.js";
|
|
3
|
+
import type { SessionEntry } from "./entries.js";
|
|
4
4
|
export interface ProtectedToolContext {
|
|
5
5
|
readonly toolResult: ToolResultMessage;
|
|
6
6
|
readonly toolCall: AgentToolCall | undefined;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import type { Message } from "@oh-my-pi/pi-ai";
|
|
5
5
|
import { type Dialect } from "@oh-my-pi/pi-ai/dialect";
|
|
6
|
-
import type { AgentMessage } from "../types";
|
|
6
|
+
import type { AgentMessage } from "../types.js";
|
|
7
7
|
export interface FileOperations {
|
|
8
8
|
read: Set<string>;
|
|
9
9
|
written: Set<string>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from "./compaction/index";
|
|
1
|
+
export * from "./compaction/index.js";
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
export * from "./agent";
|
|
2
|
-
export * from "./agent-loop";
|
|
3
|
-
export * from "./append-only-context";
|
|
4
|
-
export * from "./compaction";
|
|
5
|
-
export * from "./proxy";
|
|
6
|
-
export * from "./replay-policy";
|
|
7
|
-
export * from "./run-collector";
|
|
8
|
-
export * from "./telemetry";
|
|
9
|
-
export * from "./thinking";
|
|
10
|
-
export * from "./tokenizer";
|
|
11
|
-
export * from "./types";
|
|
12
|
-
export * from "./utils/yield";
|
|
1
|
+
export * from "./agent.js";
|
|
2
|
+
export * from "./agent-loop.js";
|
|
3
|
+
export * from "./append-only-context.js";
|
|
4
|
+
export * from "./compaction.js";
|
|
5
|
+
export * from "./proxy.js";
|
|
6
|
+
export * from "./replay-policy.js";
|
|
7
|
+
export * from "./run-collector.js";
|
|
8
|
+
export * from "./telemetry.js";
|
|
9
|
+
export * from "./thinking.js";
|
|
10
|
+
export * from "./tokenizer.js";
|
|
11
|
+
export * from "./types.js";
|
|
12
|
+
export * from "./utils/yield.js";
|
|
@@ -24,8 +24,8 @@
|
|
|
24
24
|
*/
|
|
25
25
|
import { type Api, type AssistantMessage, type Context, type Message, type Model, type ServiceTier, type SimpleStreamOptions, type StopReason, type ToolChoice, type Usage } from "@oh-my-pi/pi-ai";
|
|
26
26
|
import { type Attributes, type AttributeValue, type Span, SpanKind, SpanStatusCode, type Tracer, trace } from "@opentelemetry/api";
|
|
27
|
-
import { AgentRunCollector, type AgentRunCoverage, type AgentRunSummary, type ToolStatus } from "./run-collector";
|
|
28
|
-
import type { AgentTool } from "./types";
|
|
27
|
+
import { AgentRunCollector, type AgentRunCoverage, type AgentRunSummary, type ToolStatus } from "./run-collector.js";
|
|
28
|
+
import type { AgentTool } from "./types.js";
|
|
29
29
|
/** Default tracer name. Override via {@link AgentTelemetryConfig.tracerName}. */
|
|
30
30
|
export declare const DEFAULT_TRACER_NAME = "@oh-my-pi/pi-agent-core";
|
|
31
31
|
/**
|
package/dist/types/types.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { ApiKey, AssistantMessage, AssistantMessageEvent, AssistantMessageEventStream, Context, Effort, ImageContent, Message, Model, ServiceTier, SimpleStreamOptions, Static, streamSimple, TextContent, Tool, ToolChoice, ToolResultMessage, TSchema } from "@oh-my-pi/pi-ai";
|
|
2
2
|
import type { Dialect } from "@oh-my-pi/pi-ai/dialect";
|
|
3
3
|
import type { HarmonyAuditEvent } from "@oh-my-pi/pi-ai/utils/harmony-leak";
|
|
4
|
-
import type { AppendOnlyContextManager } from "./append-only-context";
|
|
5
|
-
import type { AgentRunCoverage, AgentRunSummary } from "./run-collector";
|
|
6
|
-
import type { AgentTelemetryConfig } from "./telemetry";
|
|
4
|
+
import type { AppendOnlyContextManager } from "./append-only-context.js";
|
|
5
|
+
import type { AgentRunCoverage, AgentRunSummary } from "./run-collector.js";
|
|
6
|
+
import type { AgentTelemetryConfig } from "./telemetry.js";
|
|
7
7
|
/** Stream function - can return sync or Promise for async config lookup */
|
|
8
8
|
export type StreamFn = (...args: Parameters<typeof streamSimple>) => AssistantMessageEventStream | Promise<AssistantMessageEventStream>;
|
|
9
9
|
/**
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"type": "module",
|
|
3
3
|
"name": "@oh-my-pi/pi-agent-core",
|
|
4
|
-
"version": "16.3.
|
|
4
|
+
"version": "16.3.8",
|
|
5
5
|
"description": "General-purpose agent with transport abstraction, state management, and attachment support",
|
|
6
6
|
"homepage": "https://omp.sh",
|
|
7
7
|
"author": "Can Boluk",
|
|
@@ -35,12 +35,12 @@
|
|
|
35
35
|
"fmt": "biome format --write ."
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@oh-my-pi/pi-ai": "16.3.
|
|
39
|
-
"@oh-my-pi/pi-catalog": "16.3.
|
|
40
|
-
"@oh-my-pi/pi-natives": "16.3.
|
|
41
|
-
"@oh-my-pi/pi-utils": "16.3.
|
|
42
|
-
"@oh-my-pi/pi-wire": "16.3.
|
|
43
|
-
"@oh-my-pi/snapcompact": "16.3.
|
|
38
|
+
"@oh-my-pi/pi-ai": "16.3.8",
|
|
39
|
+
"@oh-my-pi/pi-catalog": "16.3.8",
|
|
40
|
+
"@oh-my-pi/pi-natives": "16.3.8",
|
|
41
|
+
"@oh-my-pi/pi-utils": "16.3.8",
|
|
42
|
+
"@oh-my-pi/pi-wire": "16.3.8",
|
|
43
|
+
"@oh-my-pi/snapcompact": "16.3.8",
|
|
44
44
|
"@opentelemetry/api": "^1.9.1"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
@@ -204,9 +204,17 @@ export const DEFAULT_COMPACTION_SETTINGS: CompactionSettings = {
|
|
|
204
204
|
/**
|
|
205
205
|
* Calculate total context tokens from usage.
|
|
206
206
|
* Uses the native totalTokens field when available, falls back to computing from components.
|
|
207
|
+
* Provider-side orchestration tokens are billable but never replay into the
|
|
208
|
+
* conversation prefix, so they are excluded from context sizing to keep
|
|
209
|
+
* auto-compaction and context-promotion thresholds honest.
|
|
207
210
|
*/
|
|
208
211
|
export function calculateContextTokens(usage: Usage): number {
|
|
209
|
-
|
|
212
|
+
const orchestration = usage.orchestration;
|
|
213
|
+
const orchestrationTotal = orchestration
|
|
214
|
+
? (orchestration.input ?? 0) + (orchestration.output ?? 0) + (orchestration.cacheRead ?? 0)
|
|
215
|
+
: 0;
|
|
216
|
+
const raw = usage.totalTokens || usage.input + usage.output + usage.cacheRead + usage.cacheWrite;
|
|
217
|
+
return Math.max(0, raw - orchestrationTotal);
|
|
210
218
|
}
|
|
211
219
|
|
|
212
220
|
export function calculatePromptTokens(usage: Usage): number {
|