Skip to content

[Team] Bound agent loops and resource consumption #56

Open

Description

@hsliuustc0106

Planning ID: TODO-K

Proposed issue / PR title: feat(tasks): bound Chief delegation depth and per-task work budgets.

Goal: a request cannot generate unbounded Chief ping-pong or specialist spawning.

Scope: per-task hop/delegation and concurrency limits, an execution/time or token budget appropriate to available telemetry, stop propagation and visible exhausted-budget state. Apply across Chiefs and internal specialists; restarting or retrying does not reset the budget. Owners can stop their execution without granting another owner broader control.

Out of scope: billing, monetary cost guarantees and optimization dashboards.

Dependencies: TODO-I (#54), TODO-J (#55); use the creation-policy decision from TODO-A (#46)/#16.

Code area: task accounting, delivery, groups and tree limits/integration.

Acceptance and tests: looping Chief requests and recursive specialist requests stop at the configured limits, preserve spent budget across recovery, and report why work stopped. Ordinary bounded delegation still succeeds; cancellation interrupts downstream owned work and reports remaining external requests accurately.

Plan update (2026-10-16, team mode via groups): No separate team-mode subsystem is needed; groups with per-Bot grants cover it, and this is step 4 of the ordered plan on #51 (after #55). Effort: M.

  • Gives: hop, unread, round and tree limits (MAX_HOPS, ROOM_BOT_ROUNDS, tree maxDepth / maxChildren) are per message or per room and reset on user input; restart does not count them.
  • Gap: no per-task accounting and no visible exhausted state.
  • Per-task persisted budget: on every run() with a meta.taskId, update task.budget = {hops, deliveries, children, startedAt, tokens?}. It is persisted and recovery never resets it. Limits come from a constants block (TASK_MAX_DELIVERIES, TASK_MAX_MS; tokens only if usage.js rows can be keyed to the task).
  • On exhaustion: transition to failed with why:'budget' and a reason, deny further tagged sends (verdict in ownerPolicy style) and cancel the owned Bot turns. Tree createChild charges the task's children. Cancel from the requester or owner propagates only to Bots that owner owns.
  • Files: tasks.js, hooks.js, tools.js, plugins/tree/src/tree.js, constants.js.

Delivery

One focused implementation PR for this issue. This is planned work, not a claim of shipped multi-human support. Preserve the pristine upstream pin and generated patch/client boundaries. Keep team mode disabled until the documented authorization gates pass. Record exact tested head, executed checks, missing checks and independent review. No production credentials or live deployment are part of this issue.

Activity

  1. added
    needs-humanThe agent loop stopped; a person must decide (reason in the last comment)
    on Oct 20, 2026
  2. Birfy commented on Oct 20, 2026

    @Birfy
    Collaborator

    Triaged: this is team-via-groups work, and the team mode contract is not shipped (AGENTS.md: team mode stays disabled until the authorization gates in docs/subsystems/team.md pass; issue #16 is resolved as Option B and must not be re-opened).

    So it is not agent-ready: it waits for the owner to explicitly turn team work on. Labeled needs-human; automation leaves it alone and writes no code for it.

  3. HugoXK commented on Oct 21, 2026

    @HugoXK
    Contributor

    Design for the owner to pick. The pieces exist: MAX_HOPS and hop tracking in delivery, ROOM_BOT_ROUNDS/ROOM_* caps in groups, per-turn tool calls in the feed, and the task layer (#54).

    (a) Caps on hops and concurrency only (recommended first step). Enforce the existing hop limit across a task (not only a single relay), and a per-task limit on how many Bot turns it may start at once, with a visible exhausted state on the task/room and a stop that propagates. No token budget (telemetry is per-turn, not per-task, today).

    • Size: ~150 lines (extend tasks.js accounting + the room/tree integration) + tests.

    (b) Add a per-task token or wall-clock budget. Uses the per-Bot token counts already recorded (#537) summed over the task's turns, or wall-clock from the timeline. A visible exhausted-budget state, not reset by retry.

    • Size: +~120 lines.

    (c) Per-owner global budget. Broader; overlaps team mode and #51, so it needs the team gate.

    Recommendation: (a) now (the loop/spawn bound #56 names first), then (b) when the owner wants a cost bound. Both are T2 and testable with a looping Chief fixture.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:automationScheduled tasks and automationarea:securityAuth, grants, approvals, secretsenhancementNew feature or requestneeds-humanThe agent loop stopped; a person must decide (reason in the last comment)

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions