MCPcopy Create free account
hub / github.com/antirez/ds4 / tool_memory_remove_entry_locked

Function tool_memory_remove_entry_locked

ds4_server.c:7858–7872  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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;

Callers 3

tool_memory_prune_lockedFunction · 0.85
tool_memory_put_lockedFunction · 0.85
tool_memory_freeFunction · 0.85

Calls 4

raxRemoveFunction · 0.85
tool_memory_unlinkFunction · 0.85
tool_block_unlink_entryFunction · 0.85

Tested by

no test coverage detected