@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.mjs CHANGED
@@ -3615,6 +3615,21 @@ function createAgent(opts) {
3615
3615
  }
3616
3616
  if (toolCalls.length === 0) {
3617
3617
  if (soManager && !state.ctx?.__finalizedDueToStructuredOutput && !state.ctx?.__structuredOutputForceFinalize) {
3618
+ if (soManager.strategy.kind === "native") {
3619
+ const assistantText = extractMessageText2(lastMsg);
3620
+ if (assistantText) {
3621
+ const parsed = soManager.parseFromContent(assistantText);
3622
+ if (parsed.success) {
3623
+ const ctx2 = {
3624
+ ...state.ctx || {},
3625
+ __finalizedDueToStructuredOutput: true,
3626
+ __structuredOutputParsed: parsed.data
3627
+ };
3628
+ state = { ...state, ctx: ctx2 };
3629
+ }
3630
+ }
3631
+ break;
3632
+ }
3618
3633
  const nudge = soManager.buildNudgeMessage(false);
3619
3634
  const ctx = { ...state.ctx || {}, __structuredOutputForceFinalize: true };
3620
3635
  state = { ...state, messages: [...state.messages, nudge], ctx };
@@ -3631,6 +3646,23 @@ function createAgent(opts) {
3631
3646
  if (state.ctx?.__finalizedDueToStructuredOutput) break;
3632
3647
  }
3633
3648
  if (soManager && !state.ctx?.__finalizedDueToStructuredOutput) {
3649
+ const lastForParse = state.messages[state.messages.length - 1];
3650
+ if (lastForParse?.role === "assistant") {
3651
+ const assistantText = extractMessageText2(lastForParse);
3652
+ if (assistantText) {
3653
+ const parsed = soManager.parseFromContent(assistantText);
3654
+ if (parsed.success) {
3655
+ const ctx = {
3656
+ ...state.ctx || {},
3657
+ __finalizedDueToStructuredOutput: true,
3658
+ __structuredOutputParsed: parsed.data
3659
+ };
3660
+ state = { ...state, ctx };
3661
+ }
3662
+ }
3663
+ }
3664
+ }
3665
+ if (soManager && soManager.strategy.kind === "tool_based" && !state.ctx?.__finalizedDueToStructuredOutput) {
3634
3666
  const maxPostLoopRetries = soManager.maxRetries;
3635
3667
  for (let postRetry = 0; postRetry < maxPostLoopRetries; postRetry++) {
3636
3668
  if (state.ctx?.__finalizedDueToStructuredOutput) break;
@@ -7103,6 +7135,9 @@ function convertToJsonSchema(schema, strict = false) {
7103
7135
  function normalizeStrictSchema(schema) {
7104
7136
  if (!schema || typeof schema !== "object") return schema;
7105
7137
  const clone2 = { ...schema };
7138
+ if (typeof clone2.format === "string") {
7139
+ delete clone2.format;
7140
+ }
7106
7141
  if (clone2.type === "object" || clone2.properties) {
7107
7142
  if (!clone2.type) clone2.type = "object";
7108
7143
  if (clone2.properties && typeof clone2.properties === "object") {