Repository navigation
[Team] Bound agent loops and resource consumption #56
Description
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, treemaxDepth/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 ameta.taskId, updatetask.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 ifusage.jsrows can be keyed to the task). - On exhaustion: transition to
failedwithwhy:'budget'and a reason, deny further tagged sends (verdict inownerPolicystyle) and cancel the owned Bot turns. TreecreateChildcharges the task'schildren. 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
Edit and pause scheduled tasks; document missed runs (ThinkFlowLab#474)
Show each scheduled task's last run, and Retry a failed one (ThinkFlo…
Birfy commentedon Oct 20, 2026
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.mdpass; 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. Labeledneeds-human; automation leaves it alone and writes no code for it.HugoXK commentedon Oct 21, 2026
Design for the owner to pick. The pieces exist:
MAX_HOPSand 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
exhaustedstate on the task/room and a stop that propagates. No token budget (telemetry is per-turn, not per-task, today).tasks.jsaccounting + 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-budgetstate, not reset by retry.(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.