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

Function test_tool_checkpoint_minifies_json_parameters

ds4_server.c:13679–13751  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

13677 * client asked us to prefill. */
13678 server_log(DS4_LOG_WARNING,
13679 "ds4-server: responses replay RESPPROTO missing reasoning state; continuing from visible history source=%s cached=%d prompt=%d",
13680 cache_source,
13681 cached,
13682 prompt_tokens);
13683 trace_event(s, trace_id,
13684 "responses replay missing reasoning state; continuing from visible history source=%s cached=%d",
13685 cache_source, cached);
13686 }
13687 server_log(DS4_LOG_PREFILL,
13688 "ds4-server: %s ctx=%s%s%s prompt start",
13689 j->req.kind == REQ_CHAT ? "chat" : "completion",
13690 ctx_span,
13691 req_flags[0] ? " " : "",
13692 req_flags);
13693 ds4_session_set_progress(slot->session, server_progress_cb, &progress);
13694 ds4_session_set_display_progress(slot->session, server_progress_cb, &progress);
13695
13696 int cold_store_len = 0;
13697 if (!multimodal && cached == 0 &&
13698 s->kv.enabled &&
13699 prompt_for_sync->len >= s->kv.opt.min_tokens &&
13700 s->kv.opt.cold_max_tokens > 0 &&
13701 prompt_for_sync->len <= s->kv.opt.cold_max_tokens)
13702 {
13703 const int anchor = kv_cache_chat_anchor_pos(&s->kv, prompt_for_sync,
13704 ds4_token_user(s->engine),
13705 ds4_token_assistant(s->engine));
13706 cold_store_len = anchor >= s->kv.opt.min_tokens ?
13707 anchor : kv_cache_store_len(&s->kv, prompt_for_sync->len);
13708 }
13709 int suppressed_continued_last = -1;
13710 if (cold_store_len >= s->kv.opt.min_tokens) {
13711 /* A cold checkpoint can land exactly on the continued-checkpoint
13712 * frontier. The prefill progress callback would then write the same
13713 * prefix as "continued" while we are intentionally stopping there to
13714 * write it as "cold". Mark the frontier as already handled before the
13715 * sync reaches it; if the cold write fails, restore the old schedule so
13716 * a later continued write can still try. */
13717 suppressed_continued_last =
13718 kv_cache_slot_suppress_continued(s, slot, cold_store_len);
13719 }
13720
13721 if (s->kv.enabled &&
13722 cold_store_len >= s->kv.opt.min_tokens &&
13723 cold_store_len < prompt_for_sync->len)
13724 {
13725 ds4_tokens prefix = {0};
13726 tokens_copy_prefix(&prefix, prompt_for_sync, cold_store_len);
13727 if (server_session_sync(s, slot, &prefix, err, sizeof(err)) != 0) {
13728 ds4_tokens_free(&prefix);
13729 ds4_tokens_free(&effective_prompt);
13730 ds4_session_set_progress(slot->session, NULL, NULL);
13731 ds4_session_set_display_progress(slot->session, NULL, NULL);
13732 kv_cache_slot_restore_suppressed(slot, suppressed_continued_last,
13733 cold_store_len);
13734 kv_cache_discard_failed_disk_entry(s, slot, disk_cache_path);
13735 free(disk_cache_path);
13736 if (job_cancelled(j)) {

Callers 1

Calls 13

chat_msgs_pushFunction · 0.85
render_chat_prompt_textFunction · 0.85
request_initFunction · 0.85
buf_putsFunction · 0.85
chat_msgs_freeFunction · 0.85
tool_calls_freeFunction · 0.85
request_freeFunction · 0.85
tool_schema_orders_freeFunction · 0.85
xstrdupFunction · 0.70

Tested by

no test coverage detected