You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
bug: ephemeral budget gate counts the execution's own pre-created row — max_executions=1 ghosts can never run #1601
Live smoke of ghost activation (trinity-enterprise#148, entitled build): a fresh ephemeral agent created with max_executions: 1 refuses its first/task with 410 ephemeral_budget_exhausted. Both smoke attempts produced failed rows with ephemeral_exhausted: ghost agent budget spent (budget_exhausted) — the ghost never executed anything:
The /task router (routers/chat.py::execute_parallel_task) pre-creates the execution row with status=RUNNING (db.create_task_execution) beforeexecute_task → CapacityManager.acquire. The #69 admission gate then counts terminal + active (count_ephemeral_budget_usage, active = queued/running/pending_retry) — which includes the execution's own pre-created row. For max_executions=1: 0 terminal + 1 active(self) ≥ 1 → deny. Every pre-created-row path (task, scheduler) loses the ghost's final budgeted execution; max_executions=1 ghosts are unusable.
The active-count itself is correct in intent (bounds concurrent check-then-act overshoot) — the bug is only that the row being admitted counts against itself.
Fix
acquire already knows the execution_id being admitted. Thread it into the gate:
count_ephemeral_budget_usage(agent_name, exclude_execution_id=None) — exclude that row id from the count when given.
Gate in capacity_manager.acquire passes exclude_execution_id=execution_id.
The terminal discard hook keeps the un-excluded count (the just-finished row must count).
Paths that acquire before creating the row are unaffected (the id isn't in the table yet — exclusion is a no-op).
Acceptance criteria
A max_executions=1 ghost admits and runs its first execution, then hard-discards at the terminal hook
A ghost at terminal ≥ max_executions still denies admission (410)
A concurrent second admission (another active row, budget 1) still denies
Unit coverage in tests/unit/test_69_ephemeral_agents.py
Found by the live smoke required by trinity-enterprise#148 (activation of #69 / PR #1580).
Activity
vybe commentedon Jul 14, 2026
/claim
github-actions commentedon Jul 14, 2026
Claimed by @vybe. Label
status-in-progressadded.Next steps:
feature/1601-<short-slug>Fixes #1601docs(feature-flows): ephemeral admission gate excludes the admitted r…
Merge pull request #1602 from Abilityai/feature/1601-ephemeral-self-c…
fix(capacity): ephemeral budget gate no longer counts the execution's…