@probelabs/probe 0.6.0-rc133 → 0.6.0-rc135

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.
@@ -1613,8 +1613,7 @@ When troubleshooting:
1613
1613
  // Build appropriate reminder message based on whether schema is provided
1614
1614
  let reminderContent;
1615
1615
  if (options.schema) { // Apply for ANY schema, not just JSON schemas
1616
- // When schema is provided, AI should either use tools OR provide natural response
1617
- // Schema formatting will happen automatically afterward
1616
+ // When schema is provided, AI must use attempt_completion to trigger schema formatting
1618
1617
  reminderContent = `Please use one of the available tools to help answer the question, or use attempt_completion if you have enough information to provide a final answer.
1619
1618
 
1620
1619
  Remember: Use proper XML format with BOTH opening and closing tags:
@@ -1623,16 +1622,14 @@ Remember: Use proper XML format with BOTH opening and closing tags:
1623
1622
  <parameter>value</parameter>
1624
1623
  </tool_name>
1625
1624
 
1626
- IMPORTANT: A schema was provided for the final output format. You have two options:
1625
+ IMPORTANT: A schema was provided for the final output format.
1627
1626
 
1628
- Option 1 - Use attempt_completion with your complete answer:
1627
+ You MUST use attempt_completion to provide your answer:
1629
1628
  <attempt_completion>
1630
- [Your complete answer here - will be automatically formatted to match the schema]
1629
+ [Your complete answer here - provide in natural language, it will be automatically formatted to match the schema]
1631
1630
  </attempt_completion>
1632
1631
 
1633
- Option 2 - Provide a natural response without any tool, and it will be automatically formatted.
1634
-
1635
- Do NOT try to format your response as JSON yourself - this will be done automatically.`;
1632
+ Your response will be automatically formatted to JSON. You can provide your answer in natural language or as JSON - either will work.`;
1636
1633
  } else {
1637
1634
  // Standard reminder without schema
1638
1635
  reminderContent = `Please use one of the available tools to help answer the question, or use attempt_completion if you have enough information to provide a final answer.
@@ -1928,8 +1925,9 @@ Convert your previous response content into actual JSON data that follows this s
1928
1925
  }
1929
1926
  } else if (reachedMaxIterations && options.schema && this.debug) {
1930
1927
  console.log('[DEBUG] Skipping schema formatting due to max iterations reached without completion');
1931
- } else if (completionAttempted && options.schema) {
1928
+ } else if (completionAttempted && options.schema && !options._schemaFormatted && !options._skipValidation) {
1932
1929
  // For attempt_completion results with schema, still clean markdown if needed
1930
+ // Skip this validation if we're in a recursive correction call (_skipValidation flag)
1933
1931
  try {
1934
1932
  finalResult = cleanSchemaResponse(finalResult);
1935
1933
 
@@ -1995,9 +1993,10 @@ Convert your previous response content into actual JSON data that follows this s
1995
1993
  0
1996
1994
  );
1997
1995
 
1998
- finalResult = await this.answer(schemaDefinitionPrompt, [], {
1999
- ...options,
2000
- _schemaFormatted: true
1996
+ finalResult = await this.answer(schemaDefinitionPrompt, [], {
1997
+ ...options,
1998
+ _schemaFormatted: true,
1999
+ _skipValidation: true // Skip validation in recursive correction calls to prevent loops
2001
2000
  });
2002
2001
  finalResult = cleanSchemaResponse(finalResult);
2003
2002
  validation = validateJsonResponse(finalResult);
@@ -2040,9 +2039,10 @@ Convert your previous response content into actual JSON data that follows this s
2040
2039
  );
2041
2040
  }
2042
2041
 
2043
- finalResult = await this.answer(correctionPrompt, [], {
2044
- ...options,
2045
- _schemaFormatted: true
2042
+ finalResult = await this.answer(correctionPrompt, [], {
2043
+ ...options,
2044
+ _schemaFormatted: true,
2045
+ _skipValidation: true // Skip validation in recursive correction calls to prevent loops
2046
2046
  });
2047
2047
  finalResult = cleanSchemaResponse(finalResult);
2048
2048
 
@@ -2083,7 +2083,7 @@ Convert your previous response content into actual JSON data that follows this s
2083
2083
  }
2084
2084
 
2085
2085
  // Final mermaid validation for all responses (regardless of schema or attempt_completion)
2086
- if (!this.disableMermaidValidation) {
2086
+ if (!this.disableMermaidValidation && !options._schemaFormatted) {
2087
2087
  try {
2088
2088
  if (this.debug) {
2089
2089
  console.log(`[DEBUG] Mermaid validation: Performing final mermaid validation on result...`);
@@ -2119,9 +2119,11 @@ Convert your previous response content into actual JSON data that follows this s
2119
2119
  }
2120
2120
 
2121
2121
  // Remove thinking tags from final result before returning to user
2122
- finalResult = removeThinkingTags(finalResult);
2123
- if (this.debug) {
2124
- console.log(`[DEBUG] Removed thinking tags from final result`);
2122
+ if (!options._schemaFormatted) {
2123
+ finalResult = removeThinkingTags(finalResult);
2124
+ if (this.debug) {
2125
+ console.log(`[DEBUG] Removed thinking tags from final result`);
2126
+ }
2125
2127
  }
2126
2128
 
2127
2129
  return finalResult;
@@ -49649,16 +49649,14 @@ Remember: Use proper XML format with BOTH opening and closing tags:
49649
49649
  <parameter>value</parameter>
49650
49650
  </tool_name>
49651
49651
 
49652
- IMPORTANT: A schema was provided for the final output format. You have two options:
49652
+ IMPORTANT: A schema was provided for the final output format.
49653
49653
 
49654
- Option 1 - Use attempt_completion with your complete answer:
49654
+ You MUST use attempt_completion to provide your answer:
49655
49655
  <attempt_completion>
49656
- [Your complete answer here - will be automatically formatted to match the schema]
49656
+ [Your complete answer here - provide in natural language, it will be automatically formatted to match the schema]
49657
49657
  </attempt_completion>
49658
49658
 
49659
- Option 2 - Provide a natural response without any tool, and it will be automatically formatted.
49660
-
49661
- Do NOT try to format your response as JSON yourself - this will be done automatically.`;
49659
+ Your response will be automatically formatted to JSON. You can provide your answer in natural language or as JSON - either will work.`;
49662
49660
  } else {
49663
49661
  reminderContent = `Please use one of the available tools to help answer the question, or use attempt_completion if you have enough information to provide a final answer.
49664
49662
 
@@ -49895,7 +49893,7 @@ Convert your previous response content into actual JSON data that follows this s
49895
49893
  }
49896
49894
  } else if (reachedMaxIterations && options.schema && this.debug) {
49897
49895
  console.log("[DEBUG] Skipping schema formatting due to max iterations reached without completion");
49898
- } else if (completionAttempted && options.schema) {
49896
+ } else if (completionAttempted && options.schema && !options._schemaFormatted && !options._skipValidation) {
49899
49897
  try {
49900
49898
  finalResult = cleanSchemaResponse(finalResult);
49901
49899
  if (!this.disableMermaidValidation) {
@@ -49949,7 +49947,9 @@ Convert your previous response content into actual JSON data that follows this s
49949
49947
  );
49950
49948
  finalResult = await this.answer(schemaDefinitionPrompt, [], {
49951
49949
  ...options,
49952
- _schemaFormatted: true
49950
+ _schemaFormatted: true,
49951
+ _skipValidation: true
49952
+ // Skip validation in recursive correction calls to prevent loops
49953
49953
  });
49954
49954
  finalResult = cleanSchemaResponse(finalResult);
49955
49955
  validation = validateJsonResponse(finalResult);
@@ -49989,7 +49989,9 @@ Convert your previous response content into actual JSON data that follows this s
49989
49989
  }
49990
49990
  finalResult = await this.answer(correctionPrompt, [], {
49991
49991
  ...options,
49992
- _schemaFormatted: true
49992
+ _schemaFormatted: true,
49993
+ _skipValidation: true
49994
+ // Skip validation in recursive correction calls to prevent loops
49993
49995
  });
49994
49996
  finalResult = cleanSchemaResponse(finalResult);
49995
49997
  validation = validateJsonResponse(finalResult, { debug: this.debug });
@@ -50022,7 +50024,7 @@ Convert your previous response content into actual JSON data that follows this s
50022
50024
  }
50023
50025
  }
50024
50026
  }
50025
- if (!this.disableMermaidValidation) {
50027
+ if (!this.disableMermaidValidation && !options._schemaFormatted) {
50026
50028
  try {
50027
50029
  if (this.debug) {
50028
50030
  console.log(`[DEBUG] Mermaid validation: Performing final mermaid validation on result...`);
@@ -50053,9 +50055,11 @@ Convert your previous response content into actual JSON data that follows this s
50053
50055
  } else if (this.debug) {
50054
50056
  console.log(`[DEBUG] Mermaid validation: Skipped final validation due to disableMermaidValidation option`);
50055
50057
  }
50056
- finalResult = removeThinkingTags(finalResult);
50057
- if (this.debug) {
50058
- console.log(`[DEBUG] Removed thinking tags from final result`);
50058
+ if (!options._schemaFormatted) {
50059
+ finalResult = removeThinkingTags(finalResult);
50060
+ if (this.debug) {
50061
+ console.log(`[DEBUG] Removed thinking tags from final result`);
50062
+ }
50059
50063
  }
50060
50064
  return finalResult;
50061
50065
  } catch (error) {
@@ -51367,7 +51371,7 @@ Please reformat your previous response to match this schema exactly. Only return
51367
51371
  if (!validation.isValid) {
51368
51372
  const correctionPrompt = createJsonCorrectionPrompt(result, schema, validation.error);
51369
51373
  try {
51370
- result = await agent.answer(correctionPrompt, [], { schema });
51374
+ result = await agent.answer(correctionPrompt, [], { schema, _schemaFormatted: true });
51371
51375
  result = cleanSchemaResponse(result);
51372
51376
  const finalValidation = validateJsonResponse(result);
51373
51377
  if (!finalValidation.isValid && args.debug) {
@@ -51649,11 +51653,11 @@ Please reformat your previous response to match this schema exactly. Only return
51649
51653
  if (appTracer) {
51650
51654
  result = await appTracer.withSpan(
51651
51655
  "agent.json_correction",
51652
- () => agent.answer(correctionPrompt, [], { schema }),
51656
+ () => agent.answer(correctionPrompt, [], { schema, _schemaFormatted: true }),
51653
51657
  { "original_error": validation.error }
51654
51658
  );
51655
51659
  } else {
51656
- result = await agent.answer(correctionPrompt, [], { schema });
51660
+ result = await agent.answer(correctionPrompt, [], { schema, _schemaFormatted: true });
51657
51661
  }
51658
51662
  result = cleanSchemaResponse(result);
51659
51663
  const finalValidation = validateJsonResponse(result);
@@ -3305,83 +3305,16 @@ var init_deref = __esm({
3305
3305
  }
3306
3306
  });
3307
3307
 
3308
- // node_modules/@smithy/core/dist-es/submodules/schema/TypeRegistry.js
3309
- var TypeRegistry;
3310
- var init_TypeRegistry = __esm({
3311
- "node_modules/@smithy/core/dist-es/submodules/schema/TypeRegistry.js"() {
3312
- TypeRegistry = class _TypeRegistry {
3313
- namespace;
3314
- schemas;
3315
- exceptions;
3316
- static registries = /* @__PURE__ */ new Map();
3317
- constructor(namespace, schemas = /* @__PURE__ */ new Map(), exceptions = /* @__PURE__ */ new Map()) {
3318
- this.namespace = namespace;
3319
- this.schemas = schemas;
3320
- this.exceptions = exceptions;
3321
- }
3322
- static for(namespace) {
3323
- if (!_TypeRegistry.registries.has(namespace)) {
3324
- _TypeRegistry.registries.set(namespace, new _TypeRegistry(namespace));
3325
- }
3326
- return _TypeRegistry.registries.get(namespace);
3327
- }
3328
- register(shapeId, schema) {
3329
- const qualifiedName = this.normalizeShapeId(shapeId);
3330
- this.schemas.set(qualifiedName, schema);
3331
- }
3332
- getSchema(shapeId) {
3333
- const id = this.normalizeShapeId(shapeId);
3334
- if (!this.schemas.has(id)) {
3335
- throw new Error(`@smithy/core/schema - schema not found for ${id}`);
3336
- }
3337
- return this.schemas.get(id);
3338
- }
3339
- registerError(es, ctor) {
3340
- this.exceptions.set(es, ctor);
3341
- }
3342
- getErrorCtor(es) {
3343
- return this.exceptions.get(es);
3344
- }
3345
- getBaseException() {
3346
- for (const [id, schema] of this.schemas.entries()) {
3347
- if (id.startsWith("smithy.ts.sdk.synthetic.") && id.endsWith("ServiceException")) {
3348
- return schema;
3349
- }
3350
- }
3351
- return void 0;
3352
- }
3353
- find(predicate) {
3354
- return [...this.schemas.values()].find(predicate);
3355
- }
3356
- clear() {
3357
- this.schemas.clear();
3358
- this.exceptions.clear();
3359
- }
3360
- normalizeShapeId(shapeId) {
3361
- if (shapeId.includes("#")) {
3362
- return shapeId;
3363
- }
3364
- return this.namespace + "#" + shapeId;
3365
- }
3366
- getNamespace(shapeId) {
3367
- return this.normalizeShapeId(shapeId).split("#")[0];
3368
- }
3369
- };
3370
- }
3371
- });
3372
-
3373
3308
  // node_modules/@smithy/core/dist-es/submodules/schema/schemas/Schema.js
3374
3309
  var Schema;
3375
3310
  var init_Schema = __esm({
3376
3311
  "node_modules/@smithy/core/dist-es/submodules/schema/schemas/Schema.js"() {
3377
- init_TypeRegistry();
3378
3312
  Schema = class {
3379
3313
  name;
3380
3314
  namespace;
3381
3315
  traits;
3382
3316
  static assign(instance, values2) {
3383
3317
  const schema = Object.assign(instance, values2);
3384
- TypeRegistry.for(schema.namespace).register(schema.name, schema);
3385
3318
  return schema;
3386
3319
  }
3387
3320
  static [Symbol.hasInstance](lhs) {
@@ -3512,7 +3445,7 @@ var init_OperationSchema = __esm({
3512
3445
  });
3513
3446
 
3514
3447
  // node_modules/@smithy/core/dist-es/submodules/schema/schemas/SimpleSchema.js
3515
- var SimpleSchema, sim;
3448
+ var SimpleSchema, sim, simAdapter;
3516
3449
  var init_SimpleSchema = __esm({
3517
3450
  "node_modules/@smithy/core/dist-es/submodules/schema/schemas/SimpleSchema.js"() {
3518
3451
  init_Schema();
@@ -3529,6 +3462,12 @@ var init_SimpleSchema = __esm({
3529
3462
  traits,
3530
3463
  schemaRef
3531
3464
  });
3465
+ simAdapter = (namespace, name14, traits, schemaRef) => Schema.assign(new SimpleSchema(), {
3466
+ name: name14,
3467
+ namespace,
3468
+ traits,
3469
+ schemaRef
3470
+ });
3532
3471
  }
3533
3472
  });
3534
3473
 
@@ -3574,7 +3513,7 @@ function member(memberSchema, memberName) {
3574
3513
  function hydrate(ss) {
3575
3514
  const [id, ...rest] = ss;
3576
3515
  return {
3577
- [0]: sim,
3516
+ [0]: simAdapter,
3578
3517
  [1]: list,
3579
3518
  [2]: map,
3580
3519
  [3]: struct,
@@ -3955,6 +3894,78 @@ var init_sentinels = __esm({
3955
3894
  }
3956
3895
  });
3957
3896
 
3897
+ // node_modules/@smithy/core/dist-es/submodules/schema/TypeRegistry.js
3898
+ var TypeRegistry;
3899
+ var init_TypeRegistry = __esm({
3900
+ "node_modules/@smithy/core/dist-es/submodules/schema/TypeRegistry.js"() {
3901
+ TypeRegistry = class _TypeRegistry {
3902
+ namespace;
3903
+ schemas;
3904
+ exceptions;
3905
+ static registries = /* @__PURE__ */ new Map();
3906
+ constructor(namespace, schemas = /* @__PURE__ */ new Map(), exceptions = /* @__PURE__ */ new Map()) {
3907
+ this.namespace = namespace;
3908
+ this.schemas = schemas;
3909
+ this.exceptions = exceptions;
3910
+ }
3911
+ static for(namespace) {
3912
+ if (!_TypeRegistry.registries.has(namespace)) {
3913
+ _TypeRegistry.registries.set(namespace, new _TypeRegistry(namespace));
3914
+ }
3915
+ return _TypeRegistry.registries.get(namespace);
3916
+ }
3917
+ register(shapeId, schema) {
3918
+ const qualifiedName = this.normalizeShapeId(shapeId);
3919
+ const registry = _TypeRegistry.for(qualifiedName.split("#")[0]);
3920
+ registry.schemas.set(qualifiedName, schema);
3921
+ }
3922
+ getSchema(shapeId) {
3923
+ const id = this.normalizeShapeId(shapeId);
3924
+ if (!this.schemas.has(id)) {
3925
+ throw new Error(`@smithy/core/schema - schema not found for ${id}`);
3926
+ }
3927
+ return this.schemas.get(id);
3928
+ }
3929
+ registerError(es, ctor) {
3930
+ const $error = es;
3931
+ const registry = _TypeRegistry.for($error[1]);
3932
+ registry.schemas.set($error[1] + "#" + $error[2], $error);
3933
+ registry.exceptions.set($error, ctor);
3934
+ }
3935
+ getErrorCtor(es) {
3936
+ const $error = es;
3937
+ const registry = _TypeRegistry.for($error[1]);
3938
+ return registry.exceptions.get(es);
3939
+ }
3940
+ getBaseException() {
3941
+ for (const exceptionKey of this.exceptions.keys()) {
3942
+ if (Array.isArray(exceptionKey)) {
3943
+ const [, ns, name14] = exceptionKey;
3944
+ const id = ns + "#" + name14;
3945
+ if (id.startsWith("smithy.ts.sdk.synthetic.") && id.endsWith("ServiceException")) {
3946
+ return exceptionKey;
3947
+ }
3948
+ }
3949
+ }
3950
+ return void 0;
3951
+ }
3952
+ find(predicate) {
3953
+ return [...this.schemas.values()].find(predicate);
3954
+ }
3955
+ clear() {
3956
+ this.schemas.clear();
3957
+ this.exceptions.clear();
3958
+ }
3959
+ normalizeShapeId(shapeId) {
3960
+ if (shapeId.includes("#")) {
3961
+ return shapeId;
3962
+ }
3963
+ return this.namespace + "#" + shapeId;
3964
+ }
3965
+ };
3966
+ }
3967
+ });
3968
+
3958
3969
  // node_modules/@smithy/core/dist-es/submodules/schema/index.js
3959
3970
  var schema_exports = {};
3960
3971
  __export(schema_exports, {
@@ -3979,6 +3990,7 @@ __export(schema_exports, {
3979
3990
  op: () => op,
3980
3991
  serializerMiddlewareOption: () => serializerMiddlewareOption2,
3981
3992
  sim: () => sim,
3993
+ simAdapter: () => simAdapter,
3982
3994
  struct: () => struct,
3983
3995
  translateTraits: () => translateTraits
3984
3996
  });
@@ -75044,16 +75056,14 @@ Remember: Use proper XML format with BOTH opening and closing tags:
75044
75056
  <parameter>value</parameter>
75045
75057
  </tool_name>
75046
75058
 
75047
- IMPORTANT: A schema was provided for the final output format. You have two options:
75059
+ IMPORTANT: A schema was provided for the final output format.
75048
75060
 
75049
- Option 1 - Use attempt_completion with your complete answer:
75061
+ You MUST use attempt_completion to provide your answer:
75050
75062
  <attempt_completion>
75051
- [Your complete answer here - will be automatically formatted to match the schema]
75063
+ [Your complete answer here - provide in natural language, it will be automatically formatted to match the schema]
75052
75064
  </attempt_completion>
75053
75065
 
75054
- Option 2 - Provide a natural response without any tool, and it will be automatically formatted.
75055
-
75056
- Do NOT try to format your response as JSON yourself - this will be done automatically.`;
75066
+ Your response will be automatically formatted to JSON. You can provide your answer in natural language or as JSON - either will work.`;
75057
75067
  } else {
75058
75068
  reminderContent = `Please use one of the available tools to help answer the question, or use attempt_completion if you have enough information to provide a final answer.
75059
75069
 
@@ -75290,7 +75300,7 @@ Convert your previous response content into actual JSON data that follows this s
75290
75300
  }
75291
75301
  } else if (reachedMaxIterations && options.schema && this.debug) {
75292
75302
  console.log("[DEBUG] Skipping schema formatting due to max iterations reached without completion");
75293
- } else if (completionAttempted && options.schema) {
75303
+ } else if (completionAttempted && options.schema && !options._schemaFormatted && !options._skipValidation) {
75294
75304
  try {
75295
75305
  finalResult = cleanSchemaResponse(finalResult);
75296
75306
  if (!this.disableMermaidValidation) {
@@ -75344,7 +75354,9 @@ Convert your previous response content into actual JSON data that follows this s
75344
75354
  );
75345
75355
  finalResult = await this.answer(schemaDefinitionPrompt, [], {
75346
75356
  ...options,
75347
- _schemaFormatted: true
75357
+ _schemaFormatted: true,
75358
+ _skipValidation: true
75359
+ // Skip validation in recursive correction calls to prevent loops
75348
75360
  });
75349
75361
  finalResult = cleanSchemaResponse(finalResult);
75350
75362
  validation = validateJsonResponse(finalResult);
@@ -75384,7 +75396,9 @@ Convert your previous response content into actual JSON data that follows this s
75384
75396
  }
75385
75397
  finalResult = await this.answer(correctionPrompt, [], {
75386
75398
  ...options,
75387
- _schemaFormatted: true
75399
+ _schemaFormatted: true,
75400
+ _skipValidation: true
75401
+ // Skip validation in recursive correction calls to prevent loops
75388
75402
  });
75389
75403
  finalResult = cleanSchemaResponse(finalResult);
75390
75404
  validation = validateJsonResponse(finalResult, { debug: this.debug });
@@ -75417,7 +75431,7 @@ Convert your previous response content into actual JSON data that follows this s
75417
75431
  }
75418
75432
  }
75419
75433
  }
75420
- if (!this.disableMermaidValidation) {
75434
+ if (!this.disableMermaidValidation && !options._schemaFormatted) {
75421
75435
  try {
75422
75436
  if (this.debug) {
75423
75437
  console.log(`[DEBUG] Mermaid validation: Performing final mermaid validation on result...`);
@@ -75448,9 +75462,11 @@ Convert your previous response content into actual JSON data that follows this s
75448
75462
  } else if (this.debug) {
75449
75463
  console.log(`[DEBUG] Mermaid validation: Skipped final validation due to disableMermaidValidation option`);
75450
75464
  }
75451
- finalResult = removeThinkingTags(finalResult);
75452
- if (this.debug) {
75453
- console.log(`[DEBUG] Removed thinking tags from final result`);
75465
+ if (!options._schemaFormatted) {
75466
+ finalResult = removeThinkingTags(finalResult);
75467
+ if (this.debug) {
75468
+ console.log(`[DEBUG] Removed thinking tags from final result`);
75469
+ }
75454
75470
  }
75455
75471
  return finalResult;
75456
75472
  } catch (error2) {
package/cjs/index.cjs CHANGED
@@ -11005,83 +11005,16 @@ var init_deref = __esm({
11005
11005
  }
11006
11006
  });
11007
11007
 
11008
- // node_modules/@smithy/core/dist-es/submodules/schema/TypeRegistry.js
11009
- var TypeRegistry;
11010
- var init_TypeRegistry = __esm({
11011
- "node_modules/@smithy/core/dist-es/submodules/schema/TypeRegistry.js"() {
11012
- TypeRegistry = class _TypeRegistry {
11013
- namespace;
11014
- schemas;
11015
- exceptions;
11016
- static registries = /* @__PURE__ */ new Map();
11017
- constructor(namespace, schemas = /* @__PURE__ */ new Map(), exceptions = /* @__PURE__ */ new Map()) {
11018
- this.namespace = namespace;
11019
- this.schemas = schemas;
11020
- this.exceptions = exceptions;
11021
- }
11022
- static for(namespace) {
11023
- if (!_TypeRegistry.registries.has(namespace)) {
11024
- _TypeRegistry.registries.set(namespace, new _TypeRegistry(namespace));
11025
- }
11026
- return _TypeRegistry.registries.get(namespace);
11027
- }
11028
- register(shapeId, schema) {
11029
- const qualifiedName = this.normalizeShapeId(shapeId);
11030
- this.schemas.set(qualifiedName, schema);
11031
- }
11032
- getSchema(shapeId) {
11033
- const id = this.normalizeShapeId(shapeId);
11034
- if (!this.schemas.has(id)) {
11035
- throw new Error(`@smithy/core/schema - schema not found for ${id}`);
11036
- }
11037
- return this.schemas.get(id);
11038
- }
11039
- registerError(es, ctor) {
11040
- this.exceptions.set(es, ctor);
11041
- }
11042
- getErrorCtor(es) {
11043
- return this.exceptions.get(es);
11044
- }
11045
- getBaseException() {
11046
- for (const [id, schema] of this.schemas.entries()) {
11047
- if (id.startsWith("smithy.ts.sdk.synthetic.") && id.endsWith("ServiceException")) {
11048
- return schema;
11049
- }
11050
- }
11051
- return void 0;
11052
- }
11053
- find(predicate) {
11054
- return [...this.schemas.values()].find(predicate);
11055
- }
11056
- clear() {
11057
- this.schemas.clear();
11058
- this.exceptions.clear();
11059
- }
11060
- normalizeShapeId(shapeId) {
11061
- if (shapeId.includes("#")) {
11062
- return shapeId;
11063
- }
11064
- return this.namespace + "#" + shapeId;
11065
- }
11066
- getNamespace(shapeId) {
11067
- return this.normalizeShapeId(shapeId).split("#")[0];
11068
- }
11069
- };
11070
- }
11071
- });
11072
-
11073
11008
  // node_modules/@smithy/core/dist-es/submodules/schema/schemas/Schema.js
11074
11009
  var Schema;
11075
11010
  var init_Schema = __esm({
11076
11011
  "node_modules/@smithy/core/dist-es/submodules/schema/schemas/Schema.js"() {
11077
- init_TypeRegistry();
11078
11012
  Schema = class {
11079
11013
  name;
11080
11014
  namespace;
11081
11015
  traits;
11082
11016
  static assign(instance, values2) {
11083
11017
  const schema = Object.assign(instance, values2);
11084
- TypeRegistry.for(schema.namespace).register(schema.name, schema);
11085
11018
  return schema;
11086
11019
  }
11087
11020
  static [Symbol.hasInstance](lhs) {
@@ -11212,7 +11145,7 @@ var init_OperationSchema = __esm({
11212
11145
  });
11213
11146
 
11214
11147
  // node_modules/@smithy/core/dist-es/submodules/schema/schemas/SimpleSchema.js
11215
- var SimpleSchema, sim;
11148
+ var SimpleSchema, sim, simAdapter;
11216
11149
  var init_SimpleSchema = __esm({
11217
11150
  "node_modules/@smithy/core/dist-es/submodules/schema/schemas/SimpleSchema.js"() {
11218
11151
  init_Schema();
@@ -11229,6 +11162,12 @@ var init_SimpleSchema = __esm({
11229
11162
  traits,
11230
11163
  schemaRef
11231
11164
  });
11165
+ simAdapter = (namespace, name14, traits, schemaRef) => Schema.assign(new SimpleSchema(), {
11166
+ name: name14,
11167
+ namespace,
11168
+ traits,
11169
+ schemaRef
11170
+ });
11232
11171
  }
11233
11172
  });
11234
11173
 
@@ -11274,7 +11213,7 @@ function member(memberSchema, memberName) {
11274
11213
  function hydrate(ss) {
11275
11214
  const [id, ...rest] = ss;
11276
11215
  return {
11277
- [0]: sim,
11216
+ [0]: simAdapter,
11278
11217
  [1]: list,
11279
11218
  [2]: map,
11280
11219
  [3]: struct,
@@ -11655,6 +11594,78 @@ var init_sentinels = __esm({
11655
11594
  }
11656
11595
  });
11657
11596
 
11597
+ // node_modules/@smithy/core/dist-es/submodules/schema/TypeRegistry.js
11598
+ var TypeRegistry;
11599
+ var init_TypeRegistry = __esm({
11600
+ "node_modules/@smithy/core/dist-es/submodules/schema/TypeRegistry.js"() {
11601
+ TypeRegistry = class _TypeRegistry {
11602
+ namespace;
11603
+ schemas;
11604
+ exceptions;
11605
+ static registries = /* @__PURE__ */ new Map();
11606
+ constructor(namespace, schemas = /* @__PURE__ */ new Map(), exceptions = /* @__PURE__ */ new Map()) {
11607
+ this.namespace = namespace;
11608
+ this.schemas = schemas;
11609
+ this.exceptions = exceptions;
11610
+ }
11611
+ static for(namespace) {
11612
+ if (!_TypeRegistry.registries.has(namespace)) {
11613
+ _TypeRegistry.registries.set(namespace, new _TypeRegistry(namespace));
11614
+ }
11615
+ return _TypeRegistry.registries.get(namespace);
11616
+ }
11617
+ register(shapeId, schema) {
11618
+ const qualifiedName = this.normalizeShapeId(shapeId);
11619
+ const registry = _TypeRegistry.for(qualifiedName.split("#")[0]);
11620
+ registry.schemas.set(qualifiedName, schema);
11621
+ }
11622
+ getSchema(shapeId) {
11623
+ const id = this.normalizeShapeId(shapeId);
11624
+ if (!this.schemas.has(id)) {
11625
+ throw new Error(`@smithy/core/schema - schema not found for ${id}`);
11626
+ }
11627
+ return this.schemas.get(id);
11628
+ }
11629
+ registerError(es, ctor) {
11630
+ const $error = es;
11631
+ const registry = _TypeRegistry.for($error[1]);
11632
+ registry.schemas.set($error[1] + "#" + $error[2], $error);
11633
+ registry.exceptions.set($error, ctor);
11634
+ }
11635
+ getErrorCtor(es) {
11636
+ const $error = es;
11637
+ const registry = _TypeRegistry.for($error[1]);
11638
+ return registry.exceptions.get(es);
11639
+ }
11640
+ getBaseException() {
11641
+ for (const exceptionKey of this.exceptions.keys()) {
11642
+ if (Array.isArray(exceptionKey)) {
11643
+ const [, ns, name14] = exceptionKey;
11644
+ const id = ns + "#" + name14;
11645
+ if (id.startsWith("smithy.ts.sdk.synthetic.") && id.endsWith("ServiceException")) {
11646
+ return exceptionKey;
11647
+ }
11648
+ }
11649
+ }
11650
+ return void 0;
11651
+ }
11652
+ find(predicate) {
11653
+ return [...this.schemas.values()].find(predicate);
11654
+ }
11655
+ clear() {
11656
+ this.schemas.clear();
11657
+ this.exceptions.clear();
11658
+ }
11659
+ normalizeShapeId(shapeId) {
11660
+ if (shapeId.includes("#")) {
11661
+ return shapeId;
11662
+ }
11663
+ return this.namespace + "#" + shapeId;
11664
+ }
11665
+ };
11666
+ }
11667
+ });
11668
+
11658
11669
  // node_modules/@smithy/core/dist-es/submodules/schema/index.js
11659
11670
  var schema_exports = {};
11660
11671
  __export(schema_exports, {
@@ -11679,6 +11690,7 @@ __export(schema_exports, {
11679
11690
  op: () => op,
11680
11691
  serializerMiddlewareOption: () => serializerMiddlewareOption2,
11681
11692
  sim: () => sim,
11693
+ simAdapter: () => simAdapter,
11682
11694
  struct: () => struct,
11683
11695
  translateTraits: () => translateTraits
11684
11696
  });
@@ -75224,16 +75236,14 @@ Remember: Use proper XML format with BOTH opening and closing tags:
75224
75236
  <parameter>value</parameter>
75225
75237
  </tool_name>
75226
75238
 
75227
- IMPORTANT: A schema was provided for the final output format. You have two options:
75239
+ IMPORTANT: A schema was provided for the final output format.
75228
75240
 
75229
- Option 1 - Use attempt_completion with your complete answer:
75241
+ You MUST use attempt_completion to provide your answer:
75230
75242
  <attempt_completion>
75231
- [Your complete answer here - will be automatically formatted to match the schema]
75243
+ [Your complete answer here - provide in natural language, it will be automatically formatted to match the schema]
75232
75244
  </attempt_completion>
75233
75245
 
75234
- Option 2 - Provide a natural response without any tool, and it will be automatically formatted.
75235
-
75236
- Do NOT try to format your response as JSON yourself - this will be done automatically.`;
75246
+ Your response will be automatically formatted to JSON. You can provide your answer in natural language or as JSON - either will work.`;
75237
75247
  } else {
75238
75248
  reminderContent = `Please use one of the available tools to help answer the question, or use attempt_completion if you have enough information to provide a final answer.
75239
75249
 
@@ -75470,7 +75480,7 @@ Convert your previous response content into actual JSON data that follows this s
75470
75480
  }
75471
75481
  } else if (reachedMaxIterations && options.schema && this.debug) {
75472
75482
  console.log("[DEBUG] Skipping schema formatting due to max iterations reached without completion");
75473
- } else if (completionAttempted && options.schema) {
75483
+ } else if (completionAttempted && options.schema && !options._schemaFormatted && !options._skipValidation) {
75474
75484
  try {
75475
75485
  finalResult = cleanSchemaResponse(finalResult);
75476
75486
  if (!this.disableMermaidValidation) {
@@ -75524,7 +75534,9 @@ Convert your previous response content into actual JSON data that follows this s
75524
75534
  );
75525
75535
  finalResult = await this.answer(schemaDefinitionPrompt, [], {
75526
75536
  ...options,
75527
- _schemaFormatted: true
75537
+ _schemaFormatted: true,
75538
+ _skipValidation: true
75539
+ // Skip validation in recursive correction calls to prevent loops
75528
75540
  });
75529
75541
  finalResult = cleanSchemaResponse(finalResult);
75530
75542
  validation = validateJsonResponse(finalResult);
@@ -75564,7 +75576,9 @@ Convert your previous response content into actual JSON data that follows this s
75564
75576
  }
75565
75577
  finalResult = await this.answer(correctionPrompt, [], {
75566
75578
  ...options,
75567
- _schemaFormatted: true
75579
+ _schemaFormatted: true,
75580
+ _skipValidation: true
75581
+ // Skip validation in recursive correction calls to prevent loops
75568
75582
  });
75569
75583
  finalResult = cleanSchemaResponse(finalResult);
75570
75584
  validation = validateJsonResponse(finalResult, { debug: this.debug });
@@ -75597,7 +75611,7 @@ Convert your previous response content into actual JSON data that follows this s
75597
75611
  }
75598
75612
  }
75599
75613
  }
75600
- if (!this.disableMermaidValidation) {
75614
+ if (!this.disableMermaidValidation && !options._schemaFormatted) {
75601
75615
  try {
75602
75616
  if (this.debug) {
75603
75617
  console.log(`[DEBUG] Mermaid validation: Performing final mermaid validation on result...`);
@@ -75628,9 +75642,11 @@ Convert your previous response content into actual JSON data that follows this s
75628
75642
  } else if (this.debug) {
75629
75643
  console.log(`[DEBUG] Mermaid validation: Skipped final validation due to disableMermaidValidation option`);
75630
75644
  }
75631
- finalResult = removeThinkingTags(finalResult);
75632
- if (this.debug) {
75633
- console.log(`[DEBUG] Removed thinking tags from final result`);
75645
+ if (!options._schemaFormatted) {
75646
+ finalResult = removeThinkingTags(finalResult);
75647
+ if (this.debug) {
75648
+ console.log(`[DEBUG] Removed thinking tags from final result`);
75649
+ }
75634
75650
  }
75635
75651
  return finalResult;
75636
75652
  } catch (error2) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@probelabs/probe",
3
- "version": "0.6.0-rc133",
3
+ "version": "0.6.0-rc135",
4
4
  "description": "Node.js wrapper for the probe code search tool",
5
5
  "main": "src/index.js",
6
6
  "module": "src/index.js",
@@ -1613,8 +1613,7 @@ When troubleshooting:
1613
1613
  // Build appropriate reminder message based on whether schema is provided
1614
1614
  let reminderContent;
1615
1615
  if (options.schema) { // Apply for ANY schema, not just JSON schemas
1616
- // When schema is provided, AI should either use tools OR provide natural response
1617
- // Schema formatting will happen automatically afterward
1616
+ // When schema is provided, AI must use attempt_completion to trigger schema formatting
1618
1617
  reminderContent = `Please use one of the available tools to help answer the question, or use attempt_completion if you have enough information to provide a final answer.
1619
1618
 
1620
1619
  Remember: Use proper XML format with BOTH opening and closing tags:
@@ -1623,16 +1622,14 @@ Remember: Use proper XML format with BOTH opening and closing tags:
1623
1622
  <parameter>value</parameter>
1624
1623
  </tool_name>
1625
1624
 
1626
- IMPORTANT: A schema was provided for the final output format. You have two options:
1625
+ IMPORTANT: A schema was provided for the final output format.
1627
1626
 
1628
- Option 1 - Use attempt_completion with your complete answer:
1627
+ You MUST use attempt_completion to provide your answer:
1629
1628
  <attempt_completion>
1630
- [Your complete answer here - will be automatically formatted to match the schema]
1629
+ [Your complete answer here - provide in natural language, it will be automatically formatted to match the schema]
1631
1630
  </attempt_completion>
1632
1631
 
1633
- Option 2 - Provide a natural response without any tool, and it will be automatically formatted.
1634
-
1635
- Do NOT try to format your response as JSON yourself - this will be done automatically.`;
1632
+ Your response will be automatically formatted to JSON. You can provide your answer in natural language or as JSON - either will work.`;
1636
1633
  } else {
1637
1634
  // Standard reminder without schema
1638
1635
  reminderContent = `Please use one of the available tools to help answer the question, or use attempt_completion if you have enough information to provide a final answer.
@@ -1928,8 +1925,9 @@ Convert your previous response content into actual JSON data that follows this s
1928
1925
  }
1929
1926
  } else if (reachedMaxIterations && options.schema && this.debug) {
1930
1927
  console.log('[DEBUG] Skipping schema formatting due to max iterations reached without completion');
1931
- } else if (completionAttempted && options.schema) {
1928
+ } else if (completionAttempted && options.schema && !options._schemaFormatted && !options._skipValidation) {
1932
1929
  // For attempt_completion results with schema, still clean markdown if needed
1930
+ // Skip this validation if we're in a recursive correction call (_skipValidation flag)
1933
1931
  try {
1934
1932
  finalResult = cleanSchemaResponse(finalResult);
1935
1933
 
@@ -1995,9 +1993,10 @@ Convert your previous response content into actual JSON data that follows this s
1995
1993
  0
1996
1994
  );
1997
1995
 
1998
- finalResult = await this.answer(schemaDefinitionPrompt, [], {
1999
- ...options,
2000
- _schemaFormatted: true
1996
+ finalResult = await this.answer(schemaDefinitionPrompt, [], {
1997
+ ...options,
1998
+ _schemaFormatted: true,
1999
+ _skipValidation: true // Skip validation in recursive correction calls to prevent loops
2001
2000
  });
2002
2001
  finalResult = cleanSchemaResponse(finalResult);
2003
2002
  validation = validateJsonResponse(finalResult);
@@ -2040,9 +2039,10 @@ Convert your previous response content into actual JSON data that follows this s
2040
2039
  );
2041
2040
  }
2042
2041
 
2043
- finalResult = await this.answer(correctionPrompt, [], {
2044
- ...options,
2045
- _schemaFormatted: true
2042
+ finalResult = await this.answer(correctionPrompt, [], {
2043
+ ...options,
2044
+ _schemaFormatted: true,
2045
+ _skipValidation: true // Skip validation in recursive correction calls to prevent loops
2046
2046
  });
2047
2047
  finalResult = cleanSchemaResponse(finalResult);
2048
2048
 
@@ -2083,7 +2083,7 @@ Convert your previous response content into actual JSON data that follows this s
2083
2083
  }
2084
2084
 
2085
2085
  // Final mermaid validation for all responses (regardless of schema or attempt_completion)
2086
- if (!this.disableMermaidValidation) {
2086
+ if (!this.disableMermaidValidation && !options._schemaFormatted) {
2087
2087
  try {
2088
2088
  if (this.debug) {
2089
2089
  console.log(`[DEBUG] Mermaid validation: Performing final mermaid validation on result...`);
@@ -2119,9 +2119,11 @@ Convert your previous response content into actual JSON data that follows this s
2119
2119
  }
2120
2120
 
2121
2121
  // Remove thinking tags from final result before returning to user
2122
- finalResult = removeThinkingTags(finalResult);
2123
- if (this.debug) {
2124
- console.log(`[DEBUG] Removed thinking tags from final result`);
2122
+ if (!options._schemaFormatted) {
2123
+ finalResult = removeThinkingTags(finalResult);
2124
+ if (this.debug) {
2125
+ console.log(`[DEBUG] Removed thinking tags from final result`);
2126
+ }
2125
2127
  }
2126
2128
 
2127
2129
  return finalResult;
@@ -483,7 +483,7 @@ class ProbeAgentMcpServer {
483
483
  // Retry once with correction prompt
484
484
  const correctionPrompt = createJsonCorrectionPrompt(result, schema, validation.error);
485
485
  try {
486
- result = await agent.answer(correctionPrompt, [], { schema });
486
+ result = await agent.answer(correctionPrompt, [], { schema, _schemaFormatted: true });
487
487
  result = cleanSchemaResponse(result);
488
488
 
489
489
  // Validate again after correction
@@ -822,11 +822,11 @@ async function main() {
822
822
  try {
823
823
  if (appTracer) {
824
824
  result = await appTracer.withSpan('agent.json_correction',
825
- () => agent.answer(correctionPrompt, [], { schema }),
825
+ () => agent.answer(correctionPrompt, [], { schema, _schemaFormatted: true }),
826
826
  { 'original_error': validation.error }
827
827
  );
828
828
  } else {
829
- result = await agent.answer(correctionPrompt, [], { schema });
829
+ result = await agent.answer(correctionPrompt, [], { schema, _schemaFormatted: true });
830
830
  }
831
831
  result = cleanSchemaResponse(result);
832
832