@cognipeer/agent-sdk 0.5.1 → 0.5.2

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.cjs CHANGED
@@ -3625,6 +3625,21 @@ function createAgent(opts) {
3625
3625
  }
3626
3626
  if (toolCalls.length === 0) {
3627
3627
  if (soManager && !state.ctx?.__finalizedDueToStructuredOutput && !state.ctx?.__structuredOutputForceFinalize) {
3628
+ if (soManager.strategy.kind === "native") {
3629
+ const assistantText = extractMessageText2(lastMsg);
3630
+ if (assistantText) {
3631
+ const parsed = soManager.parseFromContent(assistantText);
3632
+ if (parsed.success) {
3633
+ const ctx2 = {
3634
+ ...state.ctx || {},
3635
+ __finalizedDueToStructuredOutput: true,
3636
+ __structuredOutputParsed: parsed.data
3637
+ };
3638
+ state = { ...state, ctx: ctx2 };
3639
+ }
3640
+ }
3641
+ break;
3642
+ }
3628
3643
  const nudge = soManager.buildNudgeMessage(false);
3629
3644
  const ctx = { ...state.ctx || {}, __structuredOutputForceFinalize: true };
3630
3645
  state = { ...state, messages: [...state.messages, nudge], ctx };
@@ -3641,6 +3656,23 @@ function createAgent(opts) {
3641
3656
  if (state.ctx?.__finalizedDueToStructuredOutput) break;
3642
3657
  }
3643
3658
  if (soManager && !state.ctx?.__finalizedDueToStructuredOutput) {
3659
+ const lastForParse = state.messages[state.messages.length - 1];
3660
+ if (lastForParse?.role === "assistant") {
3661
+ const assistantText = extractMessageText2(lastForParse);
3662
+ if (assistantText) {
3663
+ const parsed = soManager.parseFromContent(assistantText);
3664
+ if (parsed.success) {
3665
+ const ctx = {
3666
+ ...state.ctx || {},
3667
+ __finalizedDueToStructuredOutput: true,
3668
+ __structuredOutputParsed: parsed.data
3669
+ };
3670
+ state = { ...state, ctx };
3671
+ }
3672
+ }
3673
+ }
3674
+ }
3675
+ if (soManager && soManager.strategy.kind === "tool_based" && !state.ctx?.__finalizedDueToStructuredOutput) {
3644
3676
  const maxPostLoopRetries = soManager.maxRetries;
3645
3677
  for (let postRetry = 0; postRetry < maxPostLoopRetries; postRetry++) {
3646
3678
  if (state.ctx?.__finalizedDueToStructuredOutput) break;
@@ -7113,6 +7145,9 @@ function convertToJsonSchema(schema, strict = false) {
7113
7145
  function normalizeStrictSchema(schema) {
7114
7146
  if (!schema || typeof schema !== "object") return schema;
7115
7147
  const clone2 = { ...schema };
7148
+ if (typeof clone2.format === "string") {
7149
+ delete clone2.format;
7150
+ }
7116
7151
  if (clone2.type === "object" || clone2.properties) {
7117
7152
  if (!clone2.type) clone2.type = "object";
7118
7153
  if (clone2.properties && typeof clone2.properties === "object") {