@voltagent/core 2.6.7 → 2.6.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/dist/index.d.mts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +55 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +53 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -352,7 +352,7 @@ __export(index_exports, {
|
|
|
352
352
|
hasFilePart: () => hasFilePart,
|
|
353
353
|
hasImagePart: () => hasImagePart,
|
|
354
354
|
hasTextPart: () => hasTextPart,
|
|
355
|
-
hasToolCall: () =>
|
|
355
|
+
hasToolCall: () => import_ai9.hasToolCall,
|
|
356
356
|
isAbortError: () => isAbortError,
|
|
357
357
|
isMiddlewareAbortError: () => isMiddlewareAbortError,
|
|
358
358
|
isNodeRuntime: () => isNodeRuntime,
|
|
@@ -375,7 +375,7 @@ __export(index_exports, {
|
|
|
375
375
|
serializeValueForDebug: () => serializeValueForDebug,
|
|
376
376
|
setWaitUntil: () => setWaitUntil,
|
|
377
377
|
shouldSample: () => shouldSample,
|
|
378
|
-
stepCountIs: () =>
|
|
378
|
+
stepCountIs: () => import_ai9.stepCountIs,
|
|
379
379
|
tool: () => tool,
|
|
380
380
|
trace: () => import_api9.trace,
|
|
381
381
|
transformTextContent: () => transformTextContent,
|
|
@@ -30604,6 +30604,12 @@ var Agent = class {
|
|
|
30604
30604
|
onStepFinish: this.createStepHandler(oc, options)
|
|
30605
30605
|
})
|
|
30606
30606
|
);
|
|
30607
|
+
this.ensureStructuredOutputGenerated({
|
|
30608
|
+
result: response,
|
|
30609
|
+
output,
|
|
30610
|
+
tools,
|
|
30611
|
+
maxSteps
|
|
30612
|
+
});
|
|
30607
30613
|
const resolvedProviderUsage = response.usage ? await Promise.resolve(response.usage) : void 0;
|
|
30608
30614
|
finalizeLLMSpan(import_api16.SpanStatusCode.OK, {
|
|
30609
30615
|
usage: resolvedProviderUsage,
|
|
@@ -32345,6 +32351,42 @@ Metadata: ${(0, import_utils33.safeStringify)(metadata)}`;
|
|
|
32345
32351
|
toolResults: stepToolResults.length > 0 ? stepToolResults : result.toolResults ?? []
|
|
32346
32352
|
};
|
|
32347
32353
|
}
|
|
32354
|
+
ensureStructuredOutputGenerated(params) {
|
|
32355
|
+
const { result, output, tools, maxSteps } = params;
|
|
32356
|
+
if (!output) {
|
|
32357
|
+
return;
|
|
32358
|
+
}
|
|
32359
|
+
try {
|
|
32360
|
+
void result.output;
|
|
32361
|
+
} catch (error) {
|
|
32362
|
+
const isNoOutputGeneratedError = error instanceof import_ai7.NoOutputGeneratedError || error instanceof Error && error.name === "AI_NoOutputGeneratedError";
|
|
32363
|
+
if (!isNoOutputGeneratedError) {
|
|
32364
|
+
throw error;
|
|
32365
|
+
}
|
|
32366
|
+
const { toolCalls } = this.collectToolDataFromResult(result);
|
|
32367
|
+
const configuredToolCount = Object.keys(tools ?? {}).length;
|
|
32368
|
+
const stepCount = result.steps?.length ?? 0;
|
|
32369
|
+
const finishReason = result.finishReason ?? "unknown";
|
|
32370
|
+
const reachedMaxSteps = stepCount >= maxSteps;
|
|
32371
|
+
const guidance = configuredToolCount > 0 || toolCalls.length > 0 ? "When tools are enabled, ensure the model emits a final non-tool response that matches the output schema, or split this into two calls (tools first, schema formatting second)." : "Ensure the model emits a final response that matches the requested output schema.";
|
|
32372
|
+
const maxStepHint = reachedMaxSteps ? ` Generation stopped after ${stepCount} steps (maxSteps=${maxSteps}).` : "";
|
|
32373
|
+
throw createVoltAgentError(
|
|
32374
|
+
`Structured output was requested but no final output was generated (finishReason: ${finishReason}). ${guidance}${maxStepHint}`,
|
|
32375
|
+
{
|
|
32376
|
+
stage: "response_parsing",
|
|
32377
|
+
code: "STRUCTURED_OUTPUT_NOT_GENERATED",
|
|
32378
|
+
originalError: error,
|
|
32379
|
+
metadata: {
|
|
32380
|
+
finishReason,
|
|
32381
|
+
stepCount,
|
|
32382
|
+
maxSteps,
|
|
32383
|
+
configuredToolCount,
|
|
32384
|
+
toolCallCount: toolCalls.length
|
|
32385
|
+
}
|
|
32386
|
+
}
|
|
32387
|
+
);
|
|
32388
|
+
}
|
|
32389
|
+
}
|
|
32348
32390
|
/**
|
|
32349
32391
|
* Create execution context
|
|
32350
32392
|
*/
|
|
@@ -33651,6 +33693,9 @@ ${retrieverContext}`;
|
|
|
33651
33693
|
return true;
|
|
33652
33694
|
}
|
|
33653
33695
|
isRetryableError(error) {
|
|
33696
|
+
if (isVoltAgentError(error) && error.code === "STRUCTURED_OUTPUT_NOT_GENERATED") {
|
|
33697
|
+
return true;
|
|
33698
|
+
}
|
|
33654
33699
|
const retryable = error?.isRetryable;
|
|
33655
33700
|
if (typeof retryable === "boolean") {
|
|
33656
33701
|
return retryable;
|
|
@@ -41315,6 +41360,9 @@ var TriggerRegistry = class _TriggerRegistry {
|
|
|
41315
41360
|
}
|
|
41316
41361
|
};
|
|
41317
41362
|
|
|
41363
|
+
// src/voltagent.ts
|
|
41364
|
+
var import_ai8 = require("ai");
|
|
41365
|
+
|
|
41318
41366
|
// src/utils/voltops-validation.ts
|
|
41319
41367
|
function isValidVoltOpsKeys(publicKey, secretKey) {
|
|
41320
41368
|
if (!publicKey || !secretKey) {
|
|
@@ -41635,9 +41683,12 @@ var VoltAgent = class {
|
|
|
41635
41683
|
process.once("SIGTERM", () => handleSignal("SIGTERM"));
|
|
41636
41684
|
process.once("SIGINT", () => handleSignal("SIGINT"));
|
|
41637
41685
|
process.on("unhandledRejection", (reason) => {
|
|
41686
|
+
const isStructuredOutputWrapperError = isVoltAgentError(reason) && reason.code === "STRUCTURED_OUTPUT_NOT_GENERATED";
|
|
41687
|
+
const isNoOutputGeneratedError = isStructuredOutputWrapperError || reason instanceof import_ai8.NoOutputGeneratedError || reason instanceof Error && reason.name === "AI_NoOutputGeneratedError";
|
|
41638
41688
|
this.logger.error("[VoltAgent] Unhandled Promise Rejection:", {
|
|
41639
41689
|
reason: reason instanceof Error ? reason.message : reason,
|
|
41640
|
-
stack: reason instanceof Error ? reason.stack : void 0
|
|
41690
|
+
stack: reason instanceof Error ? reason.stack : void 0,
|
|
41691
|
+
hint: isNoOutputGeneratedError ? "Structured output was requested but no final output was generated. If tools are enabled, ensure a final schema-matching response or split into two calls." : void 0
|
|
41641
41692
|
});
|
|
41642
41693
|
});
|
|
41643
41694
|
}
|
|
@@ -41943,7 +41994,7 @@ var VoltAgent = class {
|
|
|
41943
41994
|
|
|
41944
41995
|
// src/index.ts
|
|
41945
41996
|
var import_utils40 = require("@voltagent/internal/utils");
|
|
41946
|
-
var
|
|
41997
|
+
var import_ai9 = require("ai");
|
|
41947
41998
|
// Annotate the CommonJS export names for ESM import in node:
|
|
41948
41999
|
0 && (module.exports = {
|
|
41949
42000
|
A2AServerRegistry,
|