@probelabs/probe 0.6.0-rc233 → 0.6.0-rc234

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.
@@ -81,7 +81,8 @@ import {
81
81
  generateSchemaInstructions,
82
82
  isJsonSchemaDefinition,
83
83
  createSchemaDefinitionCorrectionPrompt,
84
- validateAndFixMermaidResponse
84
+ validateAndFixMermaidResponse,
85
+ tryAutoWrapForSimpleSchema
85
86
  } from './schemaUtils.js';
86
87
  import { removeThinkingTags } from './xmlParsingUtils.js';
87
88
  import { predefinedPrompts } from './shared/prompts.js';
@@ -4501,6 +4502,19 @@ Convert your previous response content into actual JSON data that follows this s
4501
4502
  retryCount = 1; // Start at 1 since we already did one correction
4502
4503
  }
4503
4504
 
4505
+ // Before entering correction loop, try auto-wrapping for simple schemas
4506
+ // This avoids re-invoking AI for schemas like {text: string} where we can just wrap programmatically
4507
+ if (!validation.isValid) {
4508
+ const autoWrapped = tryAutoWrapForSimpleSchema(finalResult, options.schema, { debug: this.debug });
4509
+ if (autoWrapped) {
4510
+ if (this.debug) {
4511
+ console.log(`[DEBUG] JSON validation: Auto-wrapped plain text for simple schema`);
4512
+ }
4513
+ finalResult = autoWrapped;
4514
+ validation = validateJsonResponse(finalResult, { debug: this.debug });
4515
+ }
4516
+ }
4517
+
4504
4518
  while (!validation.isValid && retryCount < maxRetries) {
4505
4519
  if (this.debug) {
4506
4520
  console.log(`[DEBUG] JSON validation: attempt_completion validation failed (attempt ${retryCount + 1}/${maxRetries}):`, validation.error);