@probelabs/probe 0.6.0-rc247 → 0.6.0-rc248

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@probelabs/probe",
3
- "version": "0.6.0-rc247",
3
+ "version": "0.6.0-rc248",
4
4
  "description": "Node.js wrapper for the probe code search tool",
5
5
  "main": "src/index.js",
6
6
  "module": "src/index.js",
@@ -85,7 +85,7 @@ import {
85
85
  validateAndFixMermaidResponse,
86
86
  tryAutoWrapForSimpleSchema
87
87
  } from './schemaUtils.js';
88
- import { removeThinkingTags } from './xmlParsingUtils.js';
88
+ import { removeThinkingTags, extractThinkingContent } from './xmlParsingUtils.js';
89
89
  import { predefinedPrompts } from './shared/prompts.js';
90
90
  import {
91
91
  MCPXmlBridge,
@@ -2904,10 +2904,11 @@ Follow these instructions carefully:
2904
2904
  // Track initial history length for storage
2905
2905
  const oldHistoryLength = this.history.length;
2906
2906
 
2907
- // Reset output buffer for this answer() call — but NOT during schema correction recursion
2908
- // When _schemaFormatted is true, this is a recursive call to fix JSON formatting,
2909
- // and we must preserve the output buffer so the parent call can append it
2910
- if (this._outputBuffer && !options?._schemaFormatted) {
2907
+ // Reset output buffer for this answer() call — but NOT during recursive calls.
2908
+ // _schemaFormatted: recursive call to fix JSON formatting
2909
+ // _completionPromptProcessed: recursive call for completionPrompt follow-up
2910
+ // Both must preserve the output buffer so the parent call can append it.
2911
+ if (this._outputBuffer && !options?._schemaFormatted && !options?._completionPromptProcessed) {
2911
2912
  this._outputBuffer.items = [];
2912
2913
  }
2913
2914
 
@@ -3554,8 +3555,25 @@ Follow these instructions carefully:
3554
3555
  continue; // Don't use broken response, continue the loop
3555
3556
  }
3556
3557
 
3557
- finalResult = prevContent;
3558
- if (this.debug) console.log(`[DEBUG] Using previous response as completion: ${finalResult.substring(0, 100)}...`);
3558
+ // Pre-strip thinking tags to avoid losing content at final cleanup stage
3559
+ const strippedContent = removeThinkingTags(prevContent);
3560
+ if (strippedContent.length > 50) {
3561
+ // Enough content outside thinking tags — use stripped version directly
3562
+ finalResult = strippedContent;
3563
+ if (this.debug) console.log(`[DEBUG] Using previous response (thinking-stripped) as completion: ${finalResult.substring(0, 100)}...`);
3564
+ } else {
3565
+ // Content was mostly/entirely inside thinking tags.
3566
+ // Extract thinking content and use it as the actual answer.
3567
+ const thinkingContent = extractThinkingContent(prevContent);
3568
+ if (thinkingContent && thinkingContent.length > 50) {
3569
+ finalResult = thinkingContent;
3570
+ if (this.debug) console.log(`[DEBUG] Previous response was mostly in thinking tags — using thinking content as completion: ${finalResult.substring(0, 100)}...`);
3571
+ } else {
3572
+ // Neither stripped nor thinking content is substantive — use raw as fallback
3573
+ finalResult = prevContent;
3574
+ if (this.debug) console.log(`[DEBUG] Using previous response as completion (raw): ${finalResult.substring(0, 100)}...`);
3575
+ }
3576
+ }
3559
3577
  } else {
3560
3578
  finalResult = 'Error: No previous response found to use as completion.';
3561
3579
  if (this.debug) console.log(`[DEBUG] No suitable previous response found for attempt_complete shorthand`);
@@ -4296,10 +4314,16 @@ After reviewing, provide your final answer using attempt_completion.`;
4296
4314
 
4297
4315
  // Make a follow-up call with the completion prompt
4298
4316
  // Pass _completionPromptProcessed to prevent infinite loops
4317
+ // Save output buffer — the recursive answer() must not destroy DSL output() content
4318
+ const savedOutputItems = this._outputBuffer ? [...this._outputBuffer.items] : [];
4299
4319
  const completionResult = await this.answer(completionPromptMessage, [], {
4300
4320
  ...options,
4301
4321
  _completionPromptProcessed: true
4302
4322
  });
4323
+ // Restore output buffer so the parent call can append it to the final result
4324
+ if (this._outputBuffer) {
4325
+ this._outputBuffer.items = savedOutputItems;
4326
+ }
4303
4327
 
4304
4328
  // Update finalResult with the result from the completion prompt
4305
4329
  finalResult = completionResult;