| 5713 | fprintf(stderr, "ds4-server: thinking not closed, ignoring incomplete GLM tool calls in reasoning\n"); |
| 5714 | ds4_local_unterminated_reasoning(text, content_out, reasoning_out); |
| 5715 | return true; |
| 5716 | } |
| 5717 | tool_search = candidate; |
| 5718 | recovered_unclosed_tool = true; |
| 5719 | } else { |
| 5720 | tool_search = think_end + 8; |
| 5721 | } |
| 5722 | } |
| 5723 | |
| 5724 | const char *start = strstr(tool_search, tool_start); |
| 5725 | if (!start) { |
| 5726 | split_reasoning_content(text, strlen(text), content_out, reasoning_out); |
| 5727 | return true; |
| 5728 | } |
| 5729 | |
| 5730 | const char *raw_block_start = start; |
| 5731 | if (start >= text + 2 && start[-2] == '\n' && start[-1] == '\n') { |
| 5732 | raw_block_start = start - 2; |
| 5733 | } |
| 5734 | size_t content_len = trim_tool_separator_ws(text, 0, |
| 5735 | (size_t)(raw_block_start - text)); |
| 5736 | const char *p = start; |
| 5737 | for (;;) { |
| 5738 | p = skip_ascii_ws(p); |
| 5739 | if (strncmp(p, tool_start, strlen(tool_start)) != 0) break; |
| 5740 | p += strlen(tool_start); |
no test coverage detected