@oh-my-pi/pi-agent-core 18.18.8 → 18.19.0
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/speculative-execution.d.ts +1 -1
- package/dist/types/types.d.ts +9 -0
- package/package.json +8 -8
- package/src/agent-loop.ts +32 -3
- package/src/speculative-execution.ts +7 -0
- package/src/types.ts +9 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
## [Unreleased]
|
|
4
4
|
|
|
5
|
+
## [18.18.9] - 2026-11-11
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
|
|
9
|
+
- Tool calls get `ctx.toolCall.earlierEffectsSettled`, which settles once the earlier calls of their message that run beside them and may write files (their approval, asked with their arguments, is not `read`) have finished; speculative results wait for those effects before validation, and cancellation while waiting prevents their commit ([#16274](https://github.com/can1357/oh-my-pi/pull/16274) by [@will-bogusz](https://github.com/will-bogusz))
|
|
10
|
+
|
|
5
11
|
## [18.18.8] - 2026-11-11
|
|
6
12
|
|
|
7
13
|
- Fixed a cursor tool result transform failure being swallowed silently — it is now logged as a warning ([#18654](https://github.com/can1357/oh-my-pi/pull/18654) by [@yuzu-octopus](https://github.com/yuzu-octopus))
|
|
@@ -60,7 +60,7 @@ export declare class SpeculativeOperationCoordinator {
|
|
|
60
60
|
reconcileFinalCalls(calls: ReadonlyMap<string, AgentToolCall>): Promise<void>;
|
|
61
61
|
authorizeLaunch(context: SpeculativeLaunchContext): Promise<SpeculativeAuthorization>;
|
|
62
62
|
discardChildren(parentToolCallId: string, reason: string): Promise<void>;
|
|
63
|
-
claim(tool: AgentTool | undefined, toolCall: AgentToolCall, args: Record<string, unknown
|
|
63
|
+
claim(tool: AgentTool | undefined, toolCall: AgentToolCall, args: Record<string, unknown>, earlierEffectsSettled?: Promise<void>, signal?: AbortSignal): Promise<SpeculativeRawOutcome | undefined>;
|
|
64
64
|
admitFinalized(context: AgentContext, toolCall: AgentToolCall, loopConfig: AgentLoopConfig, signal: AbortSignal | undefined): void;
|
|
65
65
|
admit(definition: SpeculativeChildDefinition): Promise<SpeculativeChildHandle | undefined>;
|
|
66
66
|
}
|
package/dist/types/types.d.ts
CHANGED
|
@@ -605,6 +605,15 @@ export interface ToolCallContext {
|
|
|
605
605
|
}>;
|
|
606
606
|
/** Provider-native metadata for the current call, when present. */
|
|
607
607
|
providerMetadata?: ToolCallProviderMetadata;
|
|
608
|
+
/**
|
|
609
|
+
* Settles once every earlier call of this batch that runs alongside this one
|
|
610
|
+
* and may change files (its approval, asked with its arguments and no context,
|
|
611
|
+
* is not "read", e.g. `bash`) has
|
|
612
|
+
* finished; absent when there is none. The model sees the batch's results only
|
|
613
|
+
* after the whole batch, so a read-only tool can check its target again here
|
|
614
|
+
* and redo a read those calls changed instead of returning stale content.
|
|
615
|
+
*/
|
|
616
|
+
earlierEffectsSettled?: Promise<void>;
|
|
608
617
|
/**
|
|
609
618
|
* Cooperative steering signal: aborted when a queued user/steering message
|
|
610
619
|
* (or an interrupting peer IRC) is detected while this tool batch runs. Its
|
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.
|
|
4
|
+
"version": "18.19.0",
|
|
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.
|
|
42
|
-
"@oh-my-pi/pi-catalog": "18.
|
|
43
|
-
"@oh-my-pi/pi-natives": "18.
|
|
44
|
-
"@oh-my-pi/pi-utils": "18.
|
|
45
|
-
"@oh-my-pi/pi-wire": "18.
|
|
46
|
-
"@oh-my-pi/snapcompact": "18.
|
|
41
|
+
"@oh-my-pi/pi-ai": "18.19.0",
|
|
42
|
+
"@oh-my-pi/pi-catalog": "18.19.0",
|
|
43
|
+
"@oh-my-pi/pi-natives": "18.19.0",
|
|
44
|
+
"@oh-my-pi/pi-utils": "18.19.0",
|
|
45
|
+
"@oh-my-pi/pi-wire": "18.19.0",
|
|
46
|
+
"@oh-my-pi/snapcompact": "18.19.0",
|
|
47
47
|
"@opentelemetry/api": "^1.9.1"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
|
-
"@oh-my-pi/omptype": "18.
|
|
50
|
+
"@oh-my-pi/omptype": "18.19.0",
|
|
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
|
@@ -102,6 +102,7 @@ import type {
|
|
|
102
102
|
SteeringInterruptSource,
|
|
103
103
|
SteeringQueueState,
|
|
104
104
|
StreamFn,
|
|
105
|
+
ToolApprovalDecision,
|
|
105
106
|
} from "./types";
|
|
106
107
|
import {
|
|
107
108
|
ASIDE_MESSAGE_COMMIT,
|
|
@@ -3568,7 +3569,11 @@ async function executeToolCalls(
|
|
|
3568
3569
|
flushResultMessages();
|
|
3569
3570
|
};
|
|
3570
3571
|
|
|
3571
|
-
const runTool = async (
|
|
3572
|
+
const runTool = async (
|
|
3573
|
+
record: (typeof records)[number],
|
|
3574
|
+
index: number,
|
|
3575
|
+
earlierEffectsSettled: Promise<void> | undefined,
|
|
3576
|
+
): Promise<void> => {
|
|
3572
3577
|
// A pending interrupt preempts not-yet-started interruptible tools,
|
|
3573
3578
|
// except receivers that drain the wake with an already-aborted signal.
|
|
3574
3579
|
// Non-interruptible work is never skipped, whatever the source: the
|
|
@@ -3677,7 +3682,7 @@ async function executeToolCalls(
|
|
|
3677
3682
|
if (abortBeforeToolExecution()) return;
|
|
3678
3683
|
|
|
3679
3684
|
const speculativeOutcome = speculationCoordinator
|
|
3680
|
-
? await speculationCoordinator.claim(tool, toolCall, executionArgs)
|
|
3685
|
+
? await speculationCoordinator.claim(tool, toolCall, executionArgs, earlierEffectsSettled, record.signal)
|
|
3681
3686
|
: undefined;
|
|
3682
3687
|
if (speculativeOutcome) {
|
|
3683
3688
|
// Normalize exactly like the ordinary execute path below: third-party
|
|
@@ -3706,6 +3711,7 @@ async function executeToolCalls(
|
|
|
3706
3711
|
toolCalls: toolCallInfos,
|
|
3707
3712
|
steeringSignal: steeringSoftController.signal,
|
|
3708
3713
|
providerMetadata: toolCall.providerMetadata,
|
|
3714
|
+
...(earlierEffectsSettled ? { earlierEffectsSettled } : {}),
|
|
3709
3715
|
addAdditionalContext: context => {
|
|
3710
3716
|
if (isNonBlankContext(context)) record.reportedContext.push(context);
|
|
3711
3717
|
},
|
|
@@ -3846,6 +3852,10 @@ async function executeToolCalls(
|
|
|
3846
3852
|
|
|
3847
3853
|
let lastExclusive: Promise<void> = Promise.resolve();
|
|
3848
3854
|
let sharedTasks: Promise<void>[] = [];
|
|
3855
|
+
// The shared calls among `sharedTasks` whose approval, asked with the call's
|
|
3856
|
+
// arguments, is not "read": they may change files that a later call running
|
|
3857
|
+
// beside them reads.
|
|
3858
|
+
let sharedEffects: Promise<void>[] = [];
|
|
3849
3859
|
const tasks: Promise<void>[] = [];
|
|
3850
3860
|
|
|
3851
3861
|
// While tool calls are in flight, queued steering or interrupting IRC would
|
|
@@ -3927,9 +3937,13 @@ async function executeToolCalls(
|
|
|
3927
3937
|
// only when validation failed, and those records error out before executing.
|
|
3928
3938
|
const concurrency = resolveToolConcurrency(record.tool, record.args);
|
|
3929
3939
|
const start = concurrency === "exclusive" ? Promise.all([lastExclusive, ...sharedTasks]) : lastExclusive;
|
|
3940
|
+
const earlierEffectsSettled =
|
|
3941
|
+
concurrency === "shared" && sharedEffects.length > 0
|
|
3942
|
+
? Promise.allSettled(sharedEffects).then(() => undefined)
|
|
3943
|
+
: undefined;
|
|
3930
3944
|
const task = start.then(async () => {
|
|
3931
3945
|
try {
|
|
3932
|
-
await runTool(record, index);
|
|
3946
|
+
await runTool(record, index, earlierEffectsSettled);
|
|
3933
3947
|
} finally {
|
|
3934
3948
|
refreshPauseState();
|
|
3935
3949
|
}
|
|
@@ -3938,8 +3952,23 @@ async function executeToolCalls(
|
|
|
3938
3952
|
if (concurrency === "exclusive") {
|
|
3939
3953
|
lastExclusive = task;
|
|
3940
3954
|
sharedTasks = [];
|
|
3955
|
+
sharedEffects = [];
|
|
3941
3956
|
} else {
|
|
3942
3957
|
sharedTasks.push(task);
|
|
3958
|
+
// A dynamic approval is asked with the prepared arguments, as concurrency
|
|
3959
|
+
// is above, and no context; one that throws, or that says anything but
|
|
3960
|
+
// "read", counts as a call that may write. A resolver that says "write"
|
|
3961
|
+
// only with a context or only for transformed arguments is not counted, so
|
|
3962
|
+
// a read after it returns what it read first.
|
|
3963
|
+
const approval = record.tool?.approval;
|
|
3964
|
+
let decision: ToolApprovalDecision | undefined;
|
|
3965
|
+
try {
|
|
3966
|
+
decision = typeof approval === "function" ? approval(record.args) : approval;
|
|
3967
|
+
} catch {
|
|
3968
|
+
decision = undefined;
|
|
3969
|
+
}
|
|
3970
|
+
const tier = typeof decision === "string" ? decision : (decision?.tier ?? "exec");
|
|
3971
|
+
if (tier !== "read") sharedEffects.push(task);
|
|
3943
3972
|
}
|
|
3944
3973
|
}
|
|
3945
3974
|
try {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as path from "node:path";
|
|
2
2
|
import type { AssistantMessage } from "@oh-my-pi/pi-ai";
|
|
3
|
+
import { untilAborted } from "@oh-my-pi/pi-utils";
|
|
3
4
|
import { validateAgentToolArguments } from "./tool-arguments";
|
|
4
5
|
import type {
|
|
5
6
|
AgentContext,
|
|
@@ -617,9 +618,15 @@ export class SpeculativeOperationCoordinator {
|
|
|
617
618
|
tool: AgentTool | undefined,
|
|
618
619
|
toolCall: AgentToolCall,
|
|
619
620
|
args: Record<string, unknown>,
|
|
621
|
+
earlierEffectsSettled?: Promise<void>,
|
|
622
|
+
signal?: AbortSignal,
|
|
620
623
|
): Promise<SpeculativeRawOutcome | undefined> {
|
|
621
624
|
const candidate = this.#candidates.get(toolCall.id);
|
|
622
625
|
if (candidate?.source !== "direct") return undefined;
|
|
626
|
+
// Final assistant order can differ from admission order. Validate only
|
|
627
|
+
// after the earlier shared writers have exposed their final effects.
|
|
628
|
+
if (earlierEffectsSettled) await untilAborted(signal, earlierEffectsSettled);
|
|
629
|
+
signal?.throwIfAborted();
|
|
623
630
|
return this.#commitCandidate(candidate, tool, toolCall, args);
|
|
624
631
|
}
|
|
625
632
|
|
package/src/types.ts
CHANGED
|
@@ -691,6 +691,15 @@ export interface ToolCallContext {
|
|
|
691
691
|
toolCalls: Array<{ id: string; name: string }>;
|
|
692
692
|
/** Provider-native metadata for the current call, when present. */
|
|
693
693
|
providerMetadata?: ToolCallProviderMetadata;
|
|
694
|
+
/**
|
|
695
|
+
* Settles once every earlier call of this batch that runs alongside this one
|
|
696
|
+
* and may change files (its approval, asked with its arguments and no context,
|
|
697
|
+
* is not "read", e.g. `bash`) has
|
|
698
|
+
* finished; absent when there is none. The model sees the batch's results only
|
|
699
|
+
* after the whole batch, so a read-only tool can check its target again here
|
|
700
|
+
* and redo a read those calls changed instead of returning stale content.
|
|
701
|
+
*/
|
|
702
|
+
earlierEffectsSettled?: Promise<void>;
|
|
694
703
|
/**
|
|
695
704
|
* Cooperative steering signal: aborted when a queued user/steering message
|
|
696
705
|
* (or an interrupting peer IRC) is detected while this tool batch runs. Its
|