* Parse XML reason: ... * Strips thinking content first to avoid matching tags inside reasoning.
(text: string)
| 588 | * Strips thinking content first to avoid matching tags inside reasoning. |
| 589 | */ |
| 590 | function parseXmlReason(text: string): string | null { |
| 591 | const matches = [ |
| 592 | ...stripThinking(text).matchAll(/<reason>([\s\S]*?)<\/reason>/g), |
| 593 | ] |
| 594 | if (matches.length === 0) return null |
| 595 | return matches[0]![1]!.trim() |
| 596 | } |
| 597 | |
| 598 | /** |
| 599 | * Parse XML thinking content: <thinking>...</thinking> |
no test coverage detected