@botbotgo/agent-harness 0.0.167 → 0.0.168
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/package-version.d.ts +1 -1
- package/dist/package-version.js +1 -1
- package/dist/runtime/adapter/flow/stream-runtime.js +2 -2
- package/dist/runtime/adapter/runtime-shell.js +2 -2
- package/dist/runtime/parsing/output-parsing.d.ts +2 -0
- package/dist/runtime/parsing/output-parsing.js +23 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const AGENT_HARNESS_VERSION = "0.0.
|
|
1
|
+
export declare const AGENT_HARNESS_VERSION = "0.0.167";
|
package/dist/package-version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const AGENT_HARNESS_VERSION = "0.0.
|
|
1
|
+
export const AGENT_HARNESS_VERSION = "0.0.167";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { isToolCallRecoveryFailure, sanitizeVisibleText, } from "../../parsing/output-parsing.js";
|
|
2
2
|
import { buildInvocationRequest } from "../model/invocation-request.js";
|
|
3
3
|
import { buildRawModelMessages } from "../model/message-assembly.js";
|
|
4
4
|
import { projectRuntimeStreamEvent, createStreamEventProjectionState } from "../stream-event-projection.js";
|
|
@@ -82,7 +82,7 @@ export async function* streamRuntimeExecution(options) {
|
|
|
82
82
|
error.message.includes("does not support tool binding")) {
|
|
83
83
|
throw error;
|
|
84
84
|
}
|
|
85
|
-
if (!
|
|
85
|
+
if (!isToolCallRecoveryFailure(error)) {
|
|
86
86
|
throw error;
|
|
87
87
|
}
|
|
88
88
|
const retried = await options.invoke(options.applyStrictToolJsonInstruction(options.binding), options.input, options.threadId, options.runtimeOptions.runId ?? options.threadId, undefined, options.history, options.runtimeOptions);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { setTimeout as sleep } from "node:timers/promises";
|
|
2
|
-
import { extractVisibleOutput,
|
|
2
|
+
import { extractVisibleOutput, isToolCallRecoveryFailure, STRICT_TOOL_JSON_INSTRUCTION } from "../parsing/output-parsing.js";
|
|
3
3
|
import { readStreamDelta } from "../parsing/stream-event-parsing.js";
|
|
4
4
|
import { computeRemainingTimeoutMs, isRetryableProviderError, resolveProviderRetryPolicy } from "./resilience.js";
|
|
5
5
|
import { isDeepAgentBinding, isLangChainBinding, withUpdatedBindingExecutionParams, } from "../support/compiled-binding.js";
|
|
@@ -153,7 +153,7 @@ export async function callRuntimeWithToolParseRecovery(input) {
|
|
|
153
153
|
return await input.callRuntime(input.binding, input.request);
|
|
154
154
|
}
|
|
155
155
|
catch (error) {
|
|
156
|
-
if (input.resumePayload !== undefined || !
|
|
156
|
+
if (input.resumePayload !== undefined || !isToolCallRecoveryFailure(error)) {
|
|
157
157
|
throw error;
|
|
158
158
|
}
|
|
159
159
|
return input.callRuntime(applyStrictToolJsonInstruction(input.binding), input.request);
|
|
@@ -10,6 +10,8 @@ export declare function extractOutputContent(value: unknown): unknown;
|
|
|
10
10
|
export declare function extractContentBlocks(value: unknown): unknown[];
|
|
11
11
|
export declare function extractEmptyAssistantMessageFailure(value: unknown): string;
|
|
12
12
|
export declare function isToolCallParseFailure(error: unknown): boolean;
|
|
13
|
+
export declare function isToolCallValidationFailure(error: unknown): boolean;
|
|
14
|
+
export declare function isToolCallRecoveryFailure(error: unknown): boolean;
|
|
13
15
|
export declare const STRICT_TOOL_JSON_INSTRUCTION = "When calling tools, return only the tool call itself. The arguments must be a pure JSON object with no explanatory text before or after it.";
|
|
14
16
|
export declare function wrapResolvedModel<T>(value: T): T;
|
|
15
17
|
export declare function extractReasoningText(value: unknown): string;
|
|
@@ -492,6 +492,28 @@ export function isToolCallParseFailure(error) {
|
|
|
492
492
|
return false;
|
|
493
493
|
return /error parsing tool call:/i.test(error.message);
|
|
494
494
|
}
|
|
495
|
+
function isStructuredValidationIssue(value) {
|
|
496
|
+
if (typeof value !== "object" || !value || Array.isArray(value)) {
|
|
497
|
+
return false;
|
|
498
|
+
}
|
|
499
|
+
const typed = value;
|
|
500
|
+
return typeof typed.code === "string" && Array.isArray(typed.path) && (typed.message === undefined || typeof typed.message === "string");
|
|
501
|
+
}
|
|
502
|
+
export function isToolCallValidationFailure(error) {
|
|
503
|
+
if (!(error instanceof Error))
|
|
504
|
+
return false;
|
|
505
|
+
const message = error.message.trim();
|
|
506
|
+
if (!message)
|
|
507
|
+
return false;
|
|
508
|
+
const direct = tryParseJson(message);
|
|
509
|
+
if (Array.isArray(direct) && direct.length > 0 && direct.every((issue) => isStructuredValidationIssue(issue) && issue.path.length > 0)) {
|
|
510
|
+
return true;
|
|
511
|
+
}
|
|
512
|
+
return /Invalid input:\s*expected .* received undefined/i.test(message) && /"path"\s*:\s*\[/.test(message);
|
|
513
|
+
}
|
|
514
|
+
export function isToolCallRecoveryFailure(error) {
|
|
515
|
+
return isToolCallParseFailure(error) || isToolCallValidationFailure(error);
|
|
516
|
+
}
|
|
495
517
|
export const STRICT_TOOL_JSON_INSTRUCTION = "When calling tools, return only the tool call itself. The arguments must be a pure JSON object with no explanatory text before or after it.";
|
|
496
518
|
function appendStrictToolInstruction(input) {
|
|
497
519
|
if (Array.isArray(input)) {
|
|
@@ -518,7 +540,7 @@ export function wrapResolvedModel(value) {
|
|
|
518
540
|
return normalizeAgentMessage(await member.apply(currentTarget, args));
|
|
519
541
|
}
|
|
520
542
|
catch (error) {
|
|
521
|
-
if (!
|
|
543
|
+
if (!isToolCallRecoveryFailure(error)) {
|
|
522
544
|
throw error;
|
|
523
545
|
}
|
|
524
546
|
const retryArgs = [...args];
|