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

Function agent_tool_write

ds4_agent.c:5747–5774  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5745 snprintf(err, err_len, "cached session identity does not match file name");
5746 free(title);
5747 free(text);
5748 free(path);
5749 return false;
5750 }
5751
5752 ds4_tokens stripped_tokens = {0};
5753 ds4_tokenize_rendered_chat(w->engine, text, &stripped_tokens);
5754 uint32_t stripped_token_count = (uint32_t)stripped_tokens.len;
5755 ds4_tokens_free(&stripped_tokens);
5756
5757 agent_buf tmpl = {0};
5758 agent_buf_puts(&tmpl, path);
5759 agent_buf_puts(&tmpl, ".tmp.XXXXXX");
5760 char *tmp = agent_buf_take(&tmpl);
5761 int fd = mkstemp(tmp);
5762 if (fd < 0) {
5763 snprintf(err, err_len, "%s", strerror(errno));
5764 free(tmp);
5765 free(text);
5766 free(path);
5767 return false;
5768 }
5769
5770 fp = fdopen(fd, "wb");
5771 if (!fp) {
5772 snprintf(err, err_len, "%s", strerror(errno));
5773 close(fd);
5774 unlink(tmp);
5775 free(tmp);
5776 free(text);
5777 free(path);

Callers 1

agent_execute_tool_callFunction · 0.85

Calls 4

agent_tool_arg_valueFunction · 0.85
agent_buf_putsFunction · 0.85
agent_buf_takeFunction · 0.85
xstrdupFunction · 0.70

Tested by

no test coverage detected