fix: interactive Realm password, recoverable worker budget (0.9.15)
Prompt for Realm password when CST_REALM_PASSWORD is unset; map worker request-gate exhaustion to a clear budget error with partial progress; hard-skip identical tool failures after 3 tries. Add docs/parliament.md. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1193,6 +1193,15 @@ static void exec_begin(turn_t *t, pcall_t *pc, exec_t *x) {
|
||||
!(def->parallel && def->parallel(c, def->ud)));
|
||||
uint64_t h = call_hash(c);
|
||||
x->h = h;
|
||||
if (fail_count(a, h, 0) >= 3) {
|
||||
const char *msg =
|
||||
"error: this exact call already failed 3+ times this turn; skipped. "
|
||||
"Change approach instead of repeating the same call.";
|
||||
set_output(pc, msg, strlen(msg), 1);
|
||||
pc->status = PC_DENIED;
|
||||
hook_status(t, "skip repeated failure");
|
||||
return;
|
||||
}
|
||||
int dup = 0;
|
||||
/* plugin and MCP results can change between identical calls */
|
||||
int external = def->owner && strncmp(def->owner, "builtin:", 8) != 0;
|
||||
@@ -3173,6 +3182,26 @@ static int run_turn_once(cst_agent_t *a, const char *user_text,
|
||||
t.ncalls = kept;
|
||||
if (t.ncalls > 0)
|
||||
persist_calls(&t);
|
||||
/* Worker request-gate exhaustion is recoverable: keep partial progress
|
||||
* and return a clear budget error instead of a generic llm: failure. */
|
||||
int budget =
|
||||
lerr[0] && (strstr(lerr, "budget:") || strstr(lerr, "budget exhausted"));
|
||||
if (budget) {
|
||||
const char *body = t.text.buf ? trim_left(t.text.buf) : "";
|
||||
if (text_is_meaningful(body, strlen(body)))
|
||||
append_reply(&t, body, NULL, meta_json("budget", proto));
|
||||
else if (tools_ran || t.ncalls > 0) {
|
||||
append_msg(a, CST_ROLE_ASSISTANT,
|
||||
"Stopped: shared worker request budget is exhausted. "
|
||||
"Partial tool work above is kept; raise max_requests or "
|
||||
"finish without further worker HTTP calls.",
|
||||
NULL, NULL, NULL, meta_json("budget", proto));
|
||||
}
|
||||
turn_free(&t);
|
||||
snprintf(err, err_sz, "budget: worker request budget exhausted");
|
||||
rc = 1;
|
||||
break;
|
||||
}
|
||||
turn_free(&t);
|
||||
snprintf(err, err_sz, "llm: %s", lerr);
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user