feat: add persistent multi-model workers and orchestration budgets
This commit is contained in:
@@ -111,6 +111,13 @@ typedef struct {
|
||||
char tools_off[1024]; /* ",name,name," tools switched off (/tools off) */
|
||||
/* Sub-agents (task tool). */
|
||||
int depth; /* 0 = top-level; sub-agents run at 1 */
|
||||
int orchestrate; /* coordinator delegates write/shell work */
|
||||
int orchestrate_override; /* CLI: 1 force on, -1 force off */
|
||||
int subagent_steps, subagent_tasks, subagent_total;
|
||||
void *worker_budget; /* owned by the top-level agent */
|
||||
int (*request_gate)(void *); /* reserve budget before each HTTP attempt */
|
||||
void *request_gate_ud;
|
||||
char cache_namespace[128];
|
||||
int read_only; /* no write / shell tools */
|
||||
char tools_only[1024]; /* ",a,b," allowlist; empty = every tool */
|
||||
const char *role_prompt; /* role instructions (not owned) */
|
||||
@@ -267,6 +274,7 @@ typedef struct {
|
||||
long http_status;
|
||||
char finish_reason[32];
|
||||
long prompt_tokens;
|
||||
int cache_reported;
|
||||
long completion_tokens;
|
||||
long cached_tokens; /* prompt tokens read from the provider's cache */
|
||||
long cache_miss_tokens; /* prompt tokens billed at the full input price */
|
||||
@@ -283,6 +291,8 @@ typedef struct {
|
||||
const char *api_key;
|
||||
const char *model;
|
||||
const char *reasoning_effort; /* NULL = not sent */
|
||||
int (*request_gate)(void *);
|
||||
void *request_gate_ud;
|
||||
const cst_message_t *msgs;
|
||||
int nmsgs;
|
||||
cst_llm_on_delta_fn on_delta;
|
||||
@@ -433,6 +443,7 @@ long cst_agent_last_prompt_tokens(const cst_agent_t *a);
|
||||
/* Token use since the session was opened, and of the latest turn. */
|
||||
typedef struct {
|
||||
int requests;
|
||||
int cache_known_requests;
|
||||
long prompt, cached, miss, write, out;
|
||||
double cost; /* in currency; valid when priced */
|
||||
int priced; /* every request had a known price */
|
||||
|
||||
+24
-2
@@ -3,18 +3,20 @@
|
||||
|
||||
/*
|
||||
* Sub-agents: the task(description, prompt, agent?) tool runs one turn of a
|
||||
* child agent with its own context and returns its final report.
|
||||
* child agent with its own context and returns its final report and worker_id.
|
||||
* Pass worker_id on subsequent calls to continue the persisted context.
|
||||
*
|
||||
* Roles: built-in general / explore / plan, plus Markdown files in
|
||||
* <ws>/.agent/agents/ and <config>/agents/ (the workspace wins, both win
|
||||
* over built-ins). Frontmatter: name, description, model, tools (allowlist),
|
||||
* max_steps, readonly; the body is the role's instructions.
|
||||
* profile, max_steps, readonly; the body is the role's instructions.
|
||||
*
|
||||
* Transcripts: <ws>/.agent/sessions/<parent-id>/sub-<n>.jsonl, with a
|
||||
* sub-<n>.json summary next to each (not listed as sessions).
|
||||
*/
|
||||
|
||||
#include <stddef.h>
|
||||
#include "cst_agent.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@@ -27,6 +29,7 @@ typedef struct {
|
||||
char desc[256];
|
||||
char source[16]; /* "builtin" | "workspace" | "user" */
|
||||
char model[128]; /* empty = the parent's */
|
||||
char profile[64];
|
||||
char tools[1024]; /* ",a,b," allowlist; empty = all but task */
|
||||
int max_steps; /* 0 = default */
|
||||
int read_only;
|
||||
@@ -46,11 +49,30 @@ typedef struct {
|
||||
char role[64];
|
||||
char desc[160];
|
||||
char status[32]; /* "done" | "error" | "cancelled" | "running" */
|
||||
char provider[32], model[128];
|
||||
int requests, max_steps;
|
||||
long prompt_tokens, cached_tokens, cache_write_tokens, output_tokens;
|
||||
int priced;
|
||||
int cache_known;
|
||||
double cost;
|
||||
char currency[8];
|
||||
int steps, tools;
|
||||
double ms;
|
||||
long long mtime;
|
||||
} cst_subagent_rec_t;
|
||||
|
||||
void *cst_worker_budget_new(void);
|
||||
void cst_worker_budget_free(void *budget);
|
||||
void cst_worker_budget_reset(void *budget);
|
||||
char *cst_workers_budget_json(const cst_agent_config_t *cfg);
|
||||
/* Validated JSON configuration, stored in <workspace>/.agent/workers.json. */
|
||||
char *cst_workers_config_get(const char *workspace);
|
||||
int cst_workers_config_set(const char *workspace, const char *json,
|
||||
char *err, size_t err_sz);
|
||||
void cst_workers_config_apply(cst_agent_config_t *cfg);
|
||||
int cst_worker_cancel(const char *workspace, const char *parent_id,
|
||||
const char *worker_id);
|
||||
|
||||
/* This parent session's sub-agent runs, newest first. */
|
||||
int cst_subagent_list(const char *workspace, const char *parent_id,
|
||||
cst_subagent_rec_t *out, int max);
|
||||
|
||||
Reference in New Issue
Block a user