| 7856 | * happen to repeat `<think>` we skip it; otherwise start from |
| 7857 | * position 0. The earlier "no-think-prefix => switch to TEXT" |
| 7858 | * shortcut here was incorrect: it leaked reasoning to clients as |
| 7859 | * regular output_text because the model was already inside the |
| 7860 | * think block when it produced its first token. The actual |
| 7861 | * mode change to TEXT happens only when `</think>` is observed. */ |
| 7862 | const char *open = "<think>"; |
| 7863 | const size_t open_len = strlen(open); |
| 7864 | if (raw_len < open_len && !strncmp(raw, open, raw_len) && !final) { |
| 7865 | return true; |
| 7866 | } |
| 7867 | if (raw_len >= open_len && !strncmp(raw, open, open_len)) { |
| 7868 | st->emit_pos = open_len; |
| 7869 | } |
| 7870 | st->checked_think_prefix = true; |
| 7871 | } |
| 7872 | |
| 7873 | const char *close = strstr(raw + st->emit_pos, "</think>"); |
| 7874 | const char *tool = r->has_tools ? |
| 7875 | find_any_tool_start(raw + st->emit_pos) : NULL; |
no test coverage detected