@oh-my-pi/pi-agent-core 18.18.3 → 18.18.4
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/dist/types/agent-loop.d.ts +7 -1
- package/package.json +8 -8
- package/src/agent-loop.ts +21 -15
- package/src/compaction/compaction.ts +3 -1
|
@@ -5,7 +5,13 @@
|
|
|
5
5
|
import { type AssistantMessage, type Context, EventStream, type ToolResultMessage } from "@oh-my-pi/pi-ai";
|
|
6
6
|
import { type Dialect } from "@oh-my-pi/pi-ai/dialect";
|
|
7
7
|
import { type AgentRunCoverage, type AgentRunSummary } from "./run-collector.js";
|
|
8
|
-
import type { AgentContext, AgentEvent, AgentLoopConfig, AgentMessage, SteeringQueueState, StreamFn } from "./types.js";
|
|
8
|
+
import type { AgentContext, AgentEvent, AgentLoopConfig, AgentMessage, AgentTool, SteeringQueueState, StreamFn } from "./types.js";
|
|
9
|
+
/**
|
|
10
|
+
* A tool's batch concurrency for one call: an unset mode is shared, and a
|
|
11
|
+
* throwing per-call resolver is exclusive — the ordering that cannot race —
|
|
12
|
+
* rather than taking down the whole batch.
|
|
13
|
+
*/
|
|
14
|
+
export declare function resolveToolConcurrency(tool: AgentTool<any, any, any> | undefined, args: Record<string, unknown>): "shared" | "exclusive";
|
|
9
15
|
/** Stop-details marker for a provider error after assistant content/tool args already streamed. */
|
|
10
16
|
export declare const STREAM_INTERRUPTED_AFTER_CONTENT_STOP_DETAIL = "stream_interrupted_after_content";
|
|
11
17
|
/**
|
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": "18.18.
|
|
4
|
+
"version": "18.18.4",
|
|
5
5
|
"description": "General-purpose agent with transport abstraction, state management, and attachment support",
|
|
6
6
|
"homepage": "https://omp.sh",
|
|
7
7
|
"author": {
|
|
@@ -38,16 +38,16 @@
|
|
|
38
38
|
"fmt": "oxfmt --no-error-on-unmatched-pattern 'src/**/*.{ts,tsx}' '{test,bench,examples,scripts}/**/*.ts' '*.ts'"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@oh-my-pi/pi-ai": "18.18.
|
|
42
|
-
"@oh-my-pi/pi-catalog": "18.18.
|
|
43
|
-
"@oh-my-pi/pi-natives": "18.18.
|
|
44
|
-
"@oh-my-pi/pi-utils": "18.18.
|
|
45
|
-
"@oh-my-pi/pi-wire": "18.18.
|
|
46
|
-
"@oh-my-pi/snapcompact": "18.18.
|
|
41
|
+
"@oh-my-pi/pi-ai": "18.18.4",
|
|
42
|
+
"@oh-my-pi/pi-catalog": "18.18.4",
|
|
43
|
+
"@oh-my-pi/pi-natives": "18.18.4",
|
|
44
|
+
"@oh-my-pi/pi-utils": "18.18.4",
|
|
45
|
+
"@oh-my-pi/pi-wire": "18.18.4",
|
|
46
|
+
"@oh-my-pi/snapcompact": "18.18.4",
|
|
47
47
|
"@opentelemetry/api": "^1.9.1"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
|
-
"@oh-my-pi/omptype": "18.18.
|
|
50
|
+
"@oh-my-pi/omptype": "18.18.4",
|
|
51
51
|
"@opentelemetry/context-async-hooks": "2.9.0",
|
|
52
52
|
"@opentelemetry/sdk-trace-base": "2.9.0",
|
|
53
53
|
"@types/bun": "^1.3.14"
|
package/src/agent-loop.ts
CHANGED
|
@@ -110,6 +110,24 @@ import {
|
|
|
110
110
|
SPECULATIVE_STREAM_SESSION,
|
|
111
111
|
} from "./types";
|
|
112
112
|
|
|
113
|
+
/**
|
|
114
|
+
* A tool's batch concurrency for one call: an unset mode is shared, and a
|
|
115
|
+
* throwing per-call resolver is exclusive — the ordering that cannot race —
|
|
116
|
+
* rather than taking down the whole batch.
|
|
117
|
+
*/
|
|
118
|
+
export function resolveToolConcurrency(
|
|
119
|
+
tool: AgentTool<any, any, any> | undefined,
|
|
120
|
+
args: Record<string, unknown>,
|
|
121
|
+
): "shared" | "exclusive" {
|
|
122
|
+
const mode = tool?.concurrency;
|
|
123
|
+
if (typeof mode !== "function") return mode ?? "shared";
|
|
124
|
+
try {
|
|
125
|
+
return mode(args);
|
|
126
|
+
} catch {
|
|
127
|
+
return "exclusive";
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
113
131
|
async function waitForProcessPause(config: AgentLoopConfig, signal?: AbortSignal): Promise<void> {
|
|
114
132
|
try {
|
|
115
133
|
while (agentPauseGate.paused && !signal?.aborted) {
|
|
@@ -3905,21 +3923,9 @@ async function executeToolCalls(
|
|
|
3905
3923
|
: undefined;
|
|
3906
3924
|
for (let index = 0; index < records.length; index++) {
|
|
3907
3925
|
const record = records[index];
|
|
3908
|
-
|
|
3909
|
-
|
|
3910
|
-
|
|
3911
|
-
// Resolved from the prepared (possibly hook-revised) args — raw args
|
|
3912
|
-
// only when validation failed, and those records error out before
|
|
3913
|
-
// executing. A throwing resolver must not take down the whole batch,
|
|
3914
|
-
// so fall back to the safe (serial) mode.
|
|
3915
|
-
try {
|
|
3916
|
-
concurrency = concurrencyMode(record.args);
|
|
3917
|
-
} catch {
|
|
3918
|
-
concurrency = "exclusive";
|
|
3919
|
-
}
|
|
3920
|
-
} else {
|
|
3921
|
-
concurrency = concurrencyMode ?? "shared";
|
|
3922
|
-
}
|
|
3926
|
+
// Resolved from the prepared (possibly hook-revised) args — raw args
|
|
3927
|
+
// only when validation failed, and those records error out before executing.
|
|
3928
|
+
const concurrency = resolveToolConcurrency(record.tool, record.args);
|
|
3923
3929
|
const start = concurrency === "exclusive" ? Promise.all([lastExclusive, ...sharedTasks]) : lastExclusive;
|
|
3924
3930
|
const task = start.then(async () => {
|
|
3925
3931
|
try {
|
|
@@ -1289,7 +1289,9 @@ async function generateShortSummary(
|
|
|
1289
1289
|
maxTokens,
|
|
1290
1290
|
signal,
|
|
1291
1291
|
apiKey,
|
|
1292
|
-
|
|
1292
|
+
// Display-only summary under a 512-token cap: reasoning would consume the
|
|
1293
|
+
// whole budget. The full summary keeps the session's effort.
|
|
1294
|
+
disableReasoning: true,
|
|
1293
1295
|
initiatorOverride: options?.initiatorOverride,
|
|
1294
1296
|
metadata: options?.metadata,
|
|
1295
1297
|
fetch: options?.fetch,
|