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

Function tool_memory_put_locked

ds4_server.c:7889–7929  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7887 } else {
7888 const size_t hold = strlen("</think>") - 1;
7889 limit = raw_len > hold ? raw_len - hold : st->emit_pos;
7890 limit = utf8_stream_safe_len(raw, st->emit_pos, limit, false);
7891 }
7892
7893 if (limit > st->emit_pos) {
7894 if (emit_reasoning) {
7895 if (!st->reasoning_item_opened) {
7896 st->reasoning_index = st->next_output_index++;
7897 if (!responses_sse_reasoning_added(fd, st)) return false;
7898 st->reasoning_item_opened = true;
7899 }
7900 if (!st->reasoning_summary_started) {
7901 if (!responses_sse_reasoning_summary_part_added(fd, st)) return false;
7902 st->reasoning_summary_started = true;
7903 }
7904 if (!responses_sse_reasoning_delta(fd, st,
7905 raw + st->emit_pos,
7906 limit - st->emit_pos)) return false;
7907 buf_append(&st->reasoning_text, raw + st->emit_pos, limit - st->emit_pos);
7908 st->reasoning_emitted_any = true;
7909 }
7910 st->emit_pos = limit;
7911 }
7912
7913 if (tool_before_close) {
7914 if (complete_tool) {
7915 st->emit_pos = (size_t)(tool - raw);
7916 st->mode = RESP_STREAM_SUPPRESS;
7917 }
7918 return true;
7919 }
7920
7921 if (close) {
7922 st->emit_pos = (size_t)(close - raw) + strlen("</think>");
7923 st->mode = RESP_STREAM_TEXT;
7924 st->reasoning_closed_naturally = true;
7925 } else if (final) {
7926 st->mode = RESP_STREAM_SUPPRESS;
7927 return true;
7928 } else {
7929 return true;
7930 }
7931 }
7932

Callers 2

tool_memory_rememberFunction · 0.85
tool_memory_put_sourceFunction · 0.85

Calls 13

tool_memory_init_lockedFunction · 0.85
tool_memory_touchFunction · 0.85
tool_memory_prune_lockedFunction · 0.85
raxInsertFunction · 0.85
tool_block_unlink_entryFunction · 0.85
tool_memory_link_headFunction · 0.85
xmallocFunction · 0.70
xstrdupFunction · 0.70

Tested by

no test coverage detected