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

Function append_json_object_or_empty

ds4_server.c:2225–2240  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2223 goto bad;
2224 }
2225 chat_msg_add_tool_call_id(msg, id);
2226 buf b = {0};
2227 buf_puts(&b, msg->content ? msg->content : "");
2228 const size_t begin = b.len;
2229 buf_puts(&b, "<tool_result>");
2230 append_tool_result_text(&b, nested.content);
2231 buf_puts(&b, "</tool_result>");
2232 /* Preserve parsed boundaries, not just markup which ordinary user
2233 * text can also contain. V4.1 orders and separates these blocks. */
2234 msg->tool_results = xrealloc(msg->tool_results,
2235 (size_t)(msg->tool_results_len + 1) * sizeof(msg->tool_results[0]));
2236 msg->tool_results[msg->tool_results_len++] = (tool_result_span){
2237 .begin = begin, .end = b.len, .id = id ? xstrdup(id) : NULL,
2238 .content = nested.content};
2239 nested.content = NULL;
2240 free(msg->content);
2241 msg->content = buf_take(&b);
2242 if (nested.images.len) {
2243 size_t total = msg->images.len + nested.images.len;

Callers 3

Calls 5

json_args_parseFunction · 0.85
buf_putsFunction · 0.85
buf_putcFunction · 0.85
append_json_arg_pairFunction · 0.85
json_args_freeFunction · 0.85

Tested by

no test coverage detected