Skip to content

feat: fail-closed per-task Hyperagent budgets - #12

Open
Shifat7 wants to merge 1 commit into
clutchpbcfo:mainfrom
Shifat7:pr-05-per-task-budgets
Open

Shifat7 wants to merge 1 commit into
clutchpbcfo:mainfrom
Shifat7:pr-05-per-task-budgets

Conversation

@Shifat7

@Shifat7 Shifat7 commented Aug 22, 2026

Copy link
Copy Markdown

What changed

Daily caps bound a whole day; runaway agent loops happen per task. Adds durable named tasks with their own budgets:

  • hacb task start <name> / hacb task status / hacb task stop (src/cli.mjs)
  • Durable state in /tasks.json behind the existing file-lock pattern (src/config.mjs): startTask, getActiveTask, stopTask, reserveTaskRequest, commitTaskToolLoop
  • Bridge enforcement (src/bridge.mjs): after the daily reservation succeeds, requests count against the active task. Exhaustion fails closed with exactly: "This local Hyperagent task budget is exhausted. Start a new task or raise maxRequestsPerTask." — and releases the unused daily slot so nothing leaks.

Config: maxRequestsPerTask (8), maxPromptCharsPerTask (180000), warnAtPromptCharsPerTask (120000 → audit task_budget_warning).

Guarantees (test-enforced):

  • Budgets persist across process restarts.
  • Per-task budget is separate from — and can never bypass — the daily budget.
  • Requests without an active task are unaffected.
  • Counting + fail-closed behaviour covered at both module and HTTP levels.

Testing

npm test: 81 pass, 0 fail (3 pre-existing skips). New files: test/task-budget.test.mjs; bridge-level 200→429 flow asserts the daily slot was released.

Add hacb task start/status/stop managing durable named tasks with
their own request, prompt-char, and tool-loop limits. The bridge
reserves from the active task after the daily reservation succeeds;
exhaustion releases the unused daily slot and fails closed with an
explicit operator message. No active task means no per-task
enforcement; daily caps always remain authoritative.

Defaults: 8 requests, 180k prompt chars, warn at 120k chars.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant