@oh-my-pi/pi-agent-core 18.4.9 → 18.4.11

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 CHANGED
@@ -2,6 +2,19 @@
2
2
 
3
3
  ## [Unreleased]
4
4
 
5
+ ## [18.4.11] - 2026-10-02
6
+
7
+ ### Fixed
8
+
9
+ - Fixed lenient argument validation for tools such as `yield`: malformed tool-call JSON is now reported to the model instead of causing the tool to run with empty arguments.
10
+
11
+ ## [18.4.10] - 2026-10-02
12
+
13
+ ### Fixed
14
+
15
+ - `streamProxy` no longer finalizes a cut-off tool-call argument buffer into an executable auto-closed preview; such a call gets the parse-error arguments, so the tool is not run and the model receives the parse error ([#13868](https://github.com/can1357/oh-my-pi/pull/13868) by [@alphastorm](https://github.com/alphastorm))
16
+ - OpenAI remote compaction no longer sends stored native tool calls whose names are blank, longer than 128 characters, or contain whitespace or control characters. The outputs that answer those calls are dropped as well ([#13985](https://github.com/can1357/oh-my-pi/pull/13985) by [@Xytronix](https://github.com/Xytronix)).
17
+
5
18
  ## [18.4.6] - 2026-10-01
6
19
 
7
20
  ### Added
@@ -1007,7 +1007,7 @@ export interface AgentTool<TParameters extends TSchema = TSchema, TDetails = any
1007
1007
  * before ordinary dispatch commits its result.
1008
1008
  */
1009
1009
  speculation?: ToolSpeculationPolicy;
1010
- /** If true, argument validation errors are non-fatal: raw args are passed to execute() instead of returning an error to the LLM. */
1010
+ /** If true, schema validation errors are non-fatal: raw args are passed to execute() instead of returning an error to the LLM. Malformed argument JSON still returns the parse error. */
1011
1011
  lenientArgValidation?: boolean;
1012
1012
  /**
1013
1013
  * Whether the agent loop may abort this tool mid-execution — or skip it
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.9",
4
+ "version": "18.4.11",
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.4.9",
42
- "@oh-my-pi/pi-catalog": "18.4.9",
43
- "@oh-my-pi/pi-natives": "18.4.9",
44
- "@oh-my-pi/pi-utils": "18.4.9",
45
- "@oh-my-pi/pi-wire": "18.4.9",
46
- "@oh-my-pi/snapcompact": "18.4.9",
41
+ "@oh-my-pi/pi-ai": "18.4.11",
42
+ "@oh-my-pi/pi-catalog": "18.4.11",
43
+ "@oh-my-pi/pi-natives": "18.4.11",
44
+ "@oh-my-pi/pi-utils": "18.4.11",
45
+ "@oh-my-pi/pi-wire": "18.4.11",
46
+ "@oh-my-pi/snapcompact": "18.4.11",
47
47
  "@opentelemetry/api": "^1.9.1"
48
48
  },
49
49
  "devDependencies": {
50
- "@oh-my-pi/omptype": "18.4.9",
50
+ "@oh-my-pi/omptype": "18.4.11",
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
@@ -2907,13 +2907,14 @@ async function prepareToolCallDispatch(
2907
2907
  }
2908
2908
  return validateToolArguments(tool, { ...toolCall, arguments: args });
2909
2909
  } catch (validationError) {
2910
- if (tool?.lenientArgValidation) {
2910
+ // Lenience covers schema mismatches; a parse failure has no args to hand over.
2911
+ const parseFailed = "__parseError" in args;
2912
+ if (tool?.lenientArgValidation && !parseFailed) {
2911
2913
  const fallback = { ...args };
2912
- delete fallback.__parseError;
2913
2914
  delete fallback.__rawJson;
2914
2915
  return fallback;
2915
2916
  }
2916
- entry.args = "__parseError" in args ? { __parseError: args.__parseError } : args;
2917
+ entry.args = parseFailed ? { __parseError: args.__parseError } : args;
2917
2918
  entry.validationErrorMessage =
2918
2919
  validationError instanceof Error ? validationError.message : String(validationError);
2919
2920
  return undefined;
@@ -36,6 +36,7 @@ import type {
36
36
  ProviderSessionState,
37
37
  } from "@oh-my-pi/pi-ai/types";
38
38
  import {
39
+ dropMalformedOpenAIResponsesToolCalls,
39
40
  getOpenAIResponsesHistoryItems,
40
41
  getOpenAIResponsesHistoryPayload,
41
42
  normalizeResponsesToolCallId,
@@ -537,7 +538,10 @@ export function buildOpenAiNativeHistory(
537
538
  }
538
539
  }
539
540
  }
540
- const historyItems = adaptComputerHistoryForCompaction(rawHistoryItems, model.supportsComputerUse === true);
541
+ const historyItems = adaptComputerHistoryForCompaction(
542
+ dropMalformedOpenAIResponsesToolCalls(rawHistoryItems),
543
+ model.supportsComputerUse === true,
544
+ );
541
545
  input.push(...historyItems);
542
546
  addOpenAiCallIds(historyItems, knownCallIds, customCallIds, computerCallIds);
543
547
  msgIndex++;
@@ -589,7 +593,7 @@ export function buildOpenAiNativeHistory(
589
593
  }
590
594
  }
591
595
  const historyItems = adaptComputerHistoryForCompaction(
592
- providerPayload.items,
596
+ dropMalformedOpenAIResponsesToolCalls(providerPayload.items),
593
597
  model.supportsComputerUse === true,
594
598
  );
595
599
  if (providerPayload.dt) {
package/src/proxy.ts CHANGED
@@ -20,7 +20,8 @@ import {
20
20
  type StreamingPartialJsonCarrier,
21
21
  setStreamingPartialJson,
22
22
  } from "@oh-my-pi/pi-ai/utils/block-symbols";
23
- import { parseStreamingJson, parseStreamingJsonThrottled, readSseJson } from "@oh-my-pi/pi-utils";
23
+ import { parseToolCallArguments } from "@oh-my-pi/pi-ai/utils/tool-call-arguments";
24
+ import { parseStreamingJsonThrottled, readSseJson } from "@oh-my-pi/pi-utils";
24
25
 
25
26
  // Event stream adapter for proxy SSE events
26
27
  export class ProxyMessageEventStream extends EventStream<AssistantMessageEvent, AssistantMessage> {
@@ -378,7 +379,7 @@ function processProxyEvent(
378
379
  // throttle may have skipped trailing deltas, so the last
379
380
  // parsed arguments can lag the accumulated buffer.
380
381
  const acc = partialJsonByIndex.get(proxyEvent.contentIndex);
381
- if (acc !== undefined && acc.length > 0) content.arguments = parseStreamingJson(acc) || {};
382
+ if (acc !== undefined && acc.length > 0) content.arguments = parseToolCallArguments(acc) || {};
382
383
  partialJsonByIndex.delete(proxyEvent.contentIndex);
383
384
  parsedLenByIndex.delete(proxyEvent.contentIndex);
384
385
  clearStreamingPartialJson(content);
@@ -427,6 +428,6 @@ function finalizeBufferedArguments(partial: AssistantMessage, partialJsonByIndex
427
428
  for (const [index, acc] of partialJsonByIndex) {
428
429
  if (acc.length === 0) continue;
429
430
  const content = partial.content[index];
430
- if (content?.type === "toolCall") content.arguments = parseStreamingJson(acc) || {};
431
+ if (content?.type === "toolCall") content.arguments = parseToolCallArguments(acc) || {};
431
432
  }
432
433
  }
@@ -714,12 +714,12 @@ export class SpeculativeOperationCoordinator {
714
714
  try {
715
715
  validatedArgs = validateToolArguments(tool, toolCall);
716
716
  } catch {
717
- if (!tool.lenientArgValidation) {
717
+ // Lenience covers schema mismatches; a parse failure has no args to hand over.
718
+ if (!tool.lenientArgValidation || "__parseError" in toolCall.arguments) {
718
719
  this.ineligible(toolCall, "tool arguments are not valid", source, parentToolCallId);
719
720
  return undefined;
720
721
  }
721
- validatedArgs = { ...(toolCall.arguments as Record<string, unknown>) };
722
- delete validatedArgs.__parseError;
722
+ validatedArgs = { ...toolCall.arguments };
723
723
  delete validatedArgs.__rawJson;
724
724
  }
725
725
  let executionArgs: Record<string, unknown>;
package/src/types.ts CHANGED
@@ -1143,7 +1143,7 @@ export interface AgentTool<
1143
1143
  * before ordinary dispatch commits its result.
1144
1144
  */
1145
1145
  speculation?: ToolSpeculationPolicy;
1146
- /** If true, argument validation errors are non-fatal: raw args are passed to execute() instead of returning an error to the LLM. */
1146
+ /** If true, schema validation errors are non-fatal: raw args are passed to execute() instead of returning an error to the LLM. Malformed argument JSON still returns the parse error. */
1147
1147
  lenientArgValidation?: boolean;
1148
1148
  /**
1149
1149
  * Whether the agent loop may abort this tool mid-execution — or skip it