@probelabs/probe 0.6.0-rc252 → 0.6.0-rc253
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/bin/binaries/probe-v0.6.0-rc253-aarch64-apple-darwin.tar.gz +0 -0
- package/bin/binaries/probe-v0.6.0-rc253-aarch64-unknown-linux-musl.tar.gz +0 -0
- package/bin/binaries/probe-v0.6.0-rc253-x86_64-apple-darwin.tar.gz +0 -0
- package/bin/binaries/probe-v0.6.0-rc253-x86_64-pc-windows-msvc.zip +0 -0
- package/bin/binaries/probe-v0.6.0-rc253-x86_64-unknown-linux-musl.tar.gz +0 -0
- package/build/agent/ProbeAgent.js +24 -4
- package/build/agent/index.js +143 -47
- package/build/agent/xmlParsingUtils.js +28 -2
- package/cjs/agent/ProbeAgent.cjs +9782 -7349
- package/cjs/index.cjs +9785 -7352
- package/package.json +1 -1
- package/src/agent/ProbeAgent.js +24 -4
- package/src/agent/xmlParsingUtils.js +28 -2
- package/bin/binaries/probe-v0.6.0-rc252-aarch64-apple-darwin.tar.gz +0 -0
- package/bin/binaries/probe-v0.6.0-rc252-aarch64-unknown-linux-musl.tar.gz +0 -0
- package/bin/binaries/probe-v0.6.0-rc252-x86_64-apple-darwin.tar.gz +0 -0
- package/bin/binaries/probe-v0.6.0-rc252-x86_64-pc-windows-msvc.zip +0 -0
- package/bin/binaries/probe-v0.6.0-rc252-x86_64-unknown-linux-musl.tar.gz +0 -0
package/package.json
CHANGED
package/src/agent/ProbeAgent.js
CHANGED
|
@@ -3571,7 +3571,12 @@ Follow these instructions carefully:
|
|
|
3571
3571
|
} else {
|
|
3572
3572
|
// Content was mostly/entirely inside thinking tags.
|
|
3573
3573
|
// Extract thinking content and use it as the actual answer.
|
|
3574
|
-
|
|
3574
|
+
// extractThinkingContent now handles nested thinking tags (issue #439)
|
|
3575
|
+
let thinkingContent = extractThinkingContent(prevContent);
|
|
3576
|
+
// Also apply removeThinkingTags as extra safety to catch any edge cases
|
|
3577
|
+
if (thinkingContent) {
|
|
3578
|
+
thinkingContent = removeThinkingTags(thinkingContent) || thinkingContent.replace(/<\/?thinking>/g, '');
|
|
3579
|
+
}
|
|
3575
3580
|
if (thinkingContent && thinkingContent.length > 50) {
|
|
3576
3581
|
finalResult = thinkingContent;
|
|
3577
3582
|
if (this.debug) console.log(`[DEBUG] Previous response was mostly in thinking tags — using thinking content as completion: ${finalResult.substring(0, 100)}...`);
|
|
@@ -4795,10 +4800,25 @@ Convert your previous response content into actual JSON data that follows this s
|
|
|
4795
4800
|
}
|
|
4796
4801
|
|
|
4797
4802
|
// Remove thinking tags from final result before returning to user
|
|
4803
|
+
// Skip for valid JSON to avoid destroying JSON structure when <thinking> appears
|
|
4804
|
+
// inside string values (e.g., after tryAutoWrapForSimpleSchema embeds content with
|
|
4805
|
+
// residual thinking tag fragments — issue #439)
|
|
4798
4806
|
if (!options._schemaFormatted) {
|
|
4799
|
-
|
|
4800
|
-
|
|
4801
|
-
|
|
4807
|
+
let isValidJson = false;
|
|
4808
|
+
try {
|
|
4809
|
+
JSON.parse(finalResult);
|
|
4810
|
+
isValidJson = true;
|
|
4811
|
+
} catch {
|
|
4812
|
+
// Not valid JSON, proceed with thinking tag removal
|
|
4813
|
+
}
|
|
4814
|
+
|
|
4815
|
+
if (!isValidJson) {
|
|
4816
|
+
finalResult = removeThinkingTags(finalResult);
|
|
4817
|
+
if (this.debug) {
|
|
4818
|
+
console.log(`[DEBUG] Removed thinking tags from final result`);
|
|
4819
|
+
}
|
|
4820
|
+
} else if (this.debug) {
|
|
4821
|
+
console.log(`[DEBUG] Skipped thinking tag removal for valid JSON result (issue #439)`);
|
|
4802
4822
|
}
|
|
4803
4823
|
}
|
|
4804
4824
|
|
|
@@ -45,12 +45,38 @@ export function removeThinkingTags(xmlString) {
|
|
|
45
45
|
|
|
46
46
|
/**
|
|
47
47
|
* Extract thinking content for potential logging
|
|
48
|
+
* Handles nested thinking tags by recursively stripping inner tags.
|
|
48
49
|
* @param {string} xmlString - The XML string to extract from
|
|
49
|
-
* @returns {string|null} - Thinking content or null if not found
|
|
50
|
+
* @returns {string|null} - Thinking content (cleaned of nested tags) or null if not found
|
|
50
51
|
*/
|
|
51
52
|
export function extractThinkingContent(xmlString) {
|
|
52
53
|
const thinkingMatch = xmlString.match(/<thinking>([\s\S]*?)<\/thinking>/);
|
|
53
|
-
|
|
54
|
+
if (!thinkingMatch) {
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
let content = thinkingMatch[1].trim();
|
|
59
|
+
|
|
60
|
+
// Handle nested thinking tags: if the extracted content itself starts with <thinking>,
|
|
61
|
+
// recursively extract from it until we get clean content.
|
|
62
|
+
// This handles: <thinking><thinking>content</thinking></thinking>
|
|
63
|
+
// where non-greedy match captures "<thinking>content" (issue #439)
|
|
64
|
+
while (content.startsWith('<thinking>')) {
|
|
65
|
+
const innerMatch = content.match(/<thinking>([\s\S]*?)<\/thinking>/);
|
|
66
|
+
if (innerMatch) {
|
|
67
|
+
content = innerMatch[1].trim();
|
|
68
|
+
} else {
|
|
69
|
+
// Unclosed inner <thinking> tag - strip the opening tag and use remaining content
|
|
70
|
+
// e.g., "<thinking>content" becomes "content"
|
|
71
|
+
content = content.substring('<thinking>'.length).trim();
|
|
72
|
+
break;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// Also strip any remaining thinking tags that might be embedded in the content
|
|
77
|
+
content = content.replace(/<\/?thinking>/g, '').trim();
|
|
78
|
+
|
|
79
|
+
return content || null;
|
|
54
80
|
}
|
|
55
81
|
|
|
56
82
|
/**
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|