feat: add v2 task control and asynchronous isolated workers

This commit is contained in:
WHC
2026-10-20 14:46:57 +08:00
parent 143dba203b
commit d971cb02b0
26 changed files with 1590 additions and 66 deletions
+19 -3
View File
@@ -388,6 +388,22 @@ int main(void) {
"read. Custom.\n");
put(root, "ws/.agent/sessions/.keep", "");
/* Machine defaults apply outside configured workspaces; local config wins. */
put(root, "cst-agent/workers.json", "{\"max_steps\":13}");
char *worker_defaults = cst_workers_config_get(ws);
CHECK(worker_defaults && strstr(worker_defaults, "13"), "user worker defaults");
free(worker_defaults);
put(root, "ws/.agent/workers.json", "{\"max_steps\":17}");
worker_defaults = cst_workers_config_get(ws);
CHECK(worker_defaults && strstr(worker_defaults, "17") && !strstr(worker_defaults, "13"),
"workspace configuration replaces user defaults");
free(worker_defaults);
char defaults_path[1024];
snprintf(defaults_path, sizeof(defaults_path), "%s/ws/.agent/workers.json", root);
CHECK(unlink(defaults_path) == 0, "remove temporary workspace defaults");
snprintf(defaults_path, sizeof(defaults_path), "%s/cst-agent/workers.json", root);
CHECK(unlink(defaults_path) == 0, "remove temporary user defaults");
/* roles */
cst_agent_role_t roles[CST_ROLES_MAX];
int nr = cst_roles_list(ws, roles, CST_ROLES_MAX);
@@ -602,9 +618,9 @@ int main(void) {
"delegation cap rejects without HTTP request");
cst_tool_result_free(&r);
cst_agent_config_mut(a)->orchestrate = 1;
CHECK(!cst_tool_active(cst_agent_config(a), cst_tool_find("write_file")) &&
!cst_tool_active(cst_agent_config(a), cst_tool_find("run_shell")) &&
cst_tool_active(cst_agent_config(a), td), "coordinator delegates mutations");
CHECK(cst_tool_active(cst_agent_config(a), cst_tool_find("write_file")) &&
cst_tool_active(cst_agent_config(a), cst_tool_find("run_shell")) &&
cst_tool_active(cst_agent_config(a), td), "coordinator retains authorized direct tools");
CHECK(cst_workers_config_set(ws,
"{\"max_steps\":20,\"max_tasks\":8,\"max_requests\":3}", err, sizeof(err)) == 0,
"configure small concurrent budget");