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

Function agent_write_temp_text

ds4_agent.c:6524–6556  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6522 } else {
6523 if (sha_out) memcpy(sha_out, sha, 41);
6524 if (tokens_out) *tokens_out = stripped_token_count;
6525 }
6526
6527 free(tmp);
6528 free(title);
6529 free(text);
6530 free(path);
6531 return ok;
6532}
6533
6534/* Load a saved session KV into the live transcript and optionally replay recent
6535 * history for the human. */
6536static bool agent_worker_switch_session(agent_worker *w, const char *prefix,
6537 int history_turns,
6538 char *err, size_t err_len) {
6539 if (!worker_is_idle(w)) {
6540 snprintf(err, err_len, "model is busy");
6541 return false;
6542 }
6543 char sha[41];
6544 char *path = NULL;
6545 if (!agent_worker_find_session(w, prefix, sha, &path, err, err_len))
6546 return false;
6547
6548 bool stripped = false;
6549 ds4_kvstore_entry entry = {0};
6550 if (ds4_kvstore_read_entry_file(path, sha, &entry)) {
6551 stripped = entry.payload_bytes == 0;
6552 ds4_kvstore_entry_free(&entry);
6553 }
6554 if (stripped) {
6555 printf("rebuilding stripped session %.8s from rendered text...\n", sha);
6556 fflush(stdout);
6557 }
6558
6559 ds4_tokens loaded = {0};

Callers 1

agent_tool_visit_pageFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected