Repository navigation
feat(asks): agents wake on an answered ask by default, and a missed wake is delivered on the next start (abilityai/trinity-enterprise#1108) - #4261
Conversation
…ake is delivered on the next start (Abilityai/trinity-enterprise#1108) The ent#329 "wake on ask ending" switch was per agent and off unless an owner found it; in the 2026-11-05 film an approval in the Inbox moved nothing until the person wrote "go ahead" in the chat. The operator's ruling: on by default, on every instance. * `agent_ownership.operator_resume_enabled` is tri-state going forward: NULL is the platform default (on), 0 the owner's explicit off, 1 explicit on. The getter resolves NULL to on; `register_agent_owner` passes NULL explicitly because an upgraded SQLite column keeps its baked DEFAULT 0. Data migration (SQLite `operator_resume_default_on` + Alembic 0116): every 0 moves to NULL except an agent whose latest audited `operator_resume_config` toggle said off, which keeps its explicit 0. * AC4: `operator_queue.wake_state` (SQLite + Alembic 0117) — `pending` ("agent not yet woken") when the answer wake found the agent stopped or the turn never reached it (NETWORK class, idempotency claim released), `woken` once a turn ran. `start_agent_internal` spawns `redispatch_pending_wakes`, which waits for the agent's readiness and then re-dispatches each pending ask once through the ent#329 path (the idempotency key is the ask's). The Execution Context `ended_asks` line marks what it carries `woken`, so the status never lies. Capacity and rate-limit pressure is not `pending`: admission queues the turn on the backlog, which is already "delivered when next able". * Receipt, Workspace ask payload and the Inbox card carry the state; the Reliability panel reads "Wakes when an ask ends: on/off"; the platform prompt and the MCP tool tell agents the answer wakes them, so skills stop saying "write me again after you approve". Red first: the getter read NULL as off, the insert stamped an explicit off, the stopped agent dispatched anyway, the hook line was absent from `start_agent_internal`, readiness was not awaited before the first dispatch (`test_ent1108_wake_default.py`, `test_ent1108_deferred_wake.py`). Closes Abilityai/trinity-enterprise#1108 Co-Authored-By: Claude Fable 5.1 <[email protected]>
…the new copy (Abilityai/trinity-enterprise#1108) A trailing SQL comment on the last column before a table-level FOREIGN KEY hides the comma from the Postgres translator, so REFERENCES was stripped alone and a bare FOREIGN KEY reached CREATE TABLE. The comment moves above the column. operatorQueueEnding.spec pinned the wake setting's previous sentence. Co-Authored-By: Claude Opus 5.5 <[email protected]>
… NULL (Abilityai/trinity-enterprise#1108) register_agent_owner writes NULL (platform default: on) where the ent#329 column default was 0, so the twelve pinned agent_ownership rows move 0 → null. Regenerated with TRINITY_ENT695_REGENERATE_GOLDEN per the test's docstring; the diff is those rows plus the _meta.regenerated_by entry, nothing else. Co-Authored-By: Claude Fable 5.1 <[email protected]>
start_agent_internal also spawns the ent#752 skill-gate marker sync, and the #421 harness runs it on a loop it then closes; the dead task stayed in skill_gate_service._inflight and every later gather() over that set in test_ent752_marker_sync (and the pre-fix-gate-record case of test_2328_per_task_max_turns_wire) raised "The future belongs to a different loop". The marker spawn is stubbed in this test, so test order cannot matter. Co-Authored-By: Claude Fable 5.1 <[email protected]>
…acity it queues (Abilityai/trinity-enterprise#1108) operator_resume_service treated only error_code=network as "no turn ran": a capacity, circuit_open, ephemeral_exhausted, auth or billing failure wrote wake_state=woken and completed the idempotency key, so the wake was never retried. NO_TURN_ERROR_CODES is spelled from TaskExecutionErrorCode and covers every class in which no turn started on the agent; a timeout means a turn ran and keeps reading woken. Both wakes now dispatch with queue_on_capacity=True: execute_task's new producer opt-in makes build_pull_queue_payload return the overflow payload for ANY agent, so capacity_manager.acquire hands a wake arriving at capacity to BacklogService (queue_persistent) instead of rejecting it, the push drain runs it when a slot frees, and dispatch_and_await_terminal waits out the queue for the real terminal. The #2391 default is unchanged: without the opt-in the pull predicate stays the sole widening (test_2048's structural pin still holds). The ent#329 closed kwarg set admits the new keyword. Co-Authored-By: Claude Fable 5.1 <[email protected]>
…ot when its prompt is composed (Abilityai/trinity-enterprise#1108) platform_prompt_service._resolve_ended_asks stamped every answered ask in the Execution Context line `woken` while composing the system prompt — before any turn reached the agent. A schedule firing at a stopped agent composes, the HTTP call fails, and the pending wake was dropped silently (AC #4). The compose step now hands the answers the line LISTS (carried_answer_wakes: the first MAX_ENDED_ASKS rows, never the overflow row the resolver reads to say "and more") to operator_resume_service.note_carried_wakes, keyed by the execution id. mark_carried_wakes hangs off event_dispatch_service .spawn_task_terminal_event — the fan-out every CAS-won terminal writer calls (push, the #1083 callback, the pull sink, the sweeps) — and flips them `woken` on SUCCESS; any other terminal drops the entry and leaves the rows `pending` for the next start. Best-effort and process-local: a compose and a terminal on different workers miss the entry and the next start re-dispatches once, a duplicate turn rather than a dropped wake. Tests fix two module-binding leaks of their own: the ending wake and the resolver import services.operator_queue_service lazily, and a first import under a fake `database` in sys.modules bound the fake for the whole session (32 ent#715 failures when run after this file). Co-Authored-By: Claude Fable 5.1 <[email protected]>
…'s answer or cancel (Abilityai/trinity-enterprise#1108) Product ruling on the merge train: with the wake on by default, the expiry sweep spending an owner's turn for a timeout nobody chose is out; the issue names answers and cancellations. ask_service._wake_filer returns before the ending spawn on `expired`; the expired row is still committed, announced and read on the agent's next turn (readback, Execution Context line, get_my_ask), where the rider stands verbatim. Cancel and dismiss still wake. Copy follows: the Reliability panel names an answer or a cancel and says an expiry wakes nobody (cost sentence kept accurate), the platform prompt and the ask_operator description tell the agent the same, and the user docs (FAQ, agent configuration, approvals, executions) plus the feature flow and requirement sentences stop saying "off by default" / "or expires". config/trinity-meta-prompt/prompt.md is a dead-but-present reference copy (test_1402_prompt_contract) and is left alone. Co-Authored-By: Claude Fable 5.1 <[email protected]>
…eue_wake_state (Abilityai/trinity-enterprise#1107) `0116_terms_acceptances` shared `down_revision` 0115 with #4261's `0116_operator_resume_default_on` → `0117_operator_queue_wake_state`, which merges first. Two revisions off one parent are two heads, and `upgrade head` then applies nothing (#2068). Renamed to `0118_terms_acceptances`, revises 0117; every reference follows (the SQLite docstring, database.md, the enterprise companion's docstring in its own PR). `check_alembic_heads.py` reports a missing parent until #4261 lands — expected. A local PostgreSQL stamped with the old id needs `alembic downgrade 0115_access_requests_requester_identity && alembic upgrade head` once both are on dev. Co-Authored-By: Claude Fable 5.1 <[email protected]>
…enterprise#1108) The backend receipt gained wake_state (pending | woken | null); the MCP OperatorAskReceipt type did not, so the third surface read it as unknown. Co-Authored-By: Claude Fable 5.1 <[email protected]>
…as answered (Abilityai/trinity-enterprise#1108) ReliabilityPanel initialised resumeEnabled to false, so a failed GET showed "Wakes when an ask ends: off" for a setting that is on by default. null renders "unknown" and keeps the switch disabled until the read lands. Co-Authored-By: Claude Fable 5.1 <[email protected]>
… is pinned _agent_ready could be replaced by `return True` and every test stayed green; the probe now has to return lifecycle.wait_for_agent_ready's verdict, both ways, for the named agent (verified red under that mutation). Co-Authored-By: Claude Fable 5.1 <[email protected]>
…s nobody (Abilityai/trinity-enterprise#1108) The replace-ask path's expiry pin still expected the ent#329 expiry wake; with the ruling that an expiry spends no owner's turn, the sweep's event and audit row stand and no wake is spawned. Co-Authored-By: Claude Fable 5.1 <[email protected]>
|
Pushed by the merge train — head
Verification: 47 backend suites (PR-touched + ent752, 2328, ent695, ent329, 2048/2391/4105/3114/3127, 1578/2523/2524/1804, migrations, alembic) — 1627 passed; frontend Noted, not changed: the carried-wake stash is process-local — a compose and a terminal on different uvicorn workers (#1083 callback, pull claim result) miss it and the next start re-dispatches once (a duplicate turn, never a dropped wake); the queued wake needs no priority or caller-side idempotency key ( 🤖 Generated with Claude Code |
…n-ask-default # Conflicts: # tests/unit/fixtures/ent695_create_mode_golden.json
…acity (Abilityai/trinity-enterprise#1108) test_ent751_gate_guards pins that every execute_task keyword has a fate; the new keyword is DROP — the wake producer's own admission choice, never replayed into an approved run. Co-Authored-By: Claude Fable 5.1 <[email protected]>
|
merge-train: one more mechanical commit — |
Summary
The ent#329 "wake on ask ending" switch was per agent and off unless an owner found it; in the 2026-11-05 film an approval in the Inbox moved nothing until the person wrote "go ahead" in the chat. Operator's ruling: on by default, on every instance.
agent_ownership.operator_resume_enabledis tri-state going forward: NULL = platform default (on), 0 = owner's explicit off, 1 = explicit on. The getter resolves NULL to on;register_agent_ownerpasses NULL explicitly because an upgraded SQLite column keeps its bakedDEFAULT 0. Data migration (SQLiteoperator_resume_default_on+ Alembic0116): every 0 moves to NULL except an agent whose latest auditedoperator_resume_configtoggle said off.operator_queue.wake_state(SQLite + Alembic0117):pending("agent not yet woken") when the answer wake found the agent stopped, or when the result is a class in which no turn started on the agent (NO_TURN_ERROR_CODES, spelled fromTaskExecutionErrorCode:network,capacity,circuit_open,ephemeral_exhausted,auth,billing; the idempotency claim is released);wokenonce a turn ran (atimeoutis a turn that ran).start_agent_internalspawnsredispatch_pending_wakes, which waits for readiness and re-dispatches each pending ask once through the ent#329 path. A turn whose Execution Contextended_asksline lists a pending answer marks itwokenat its SUCCESS terminal (note_carried_wakesat compose,mark_carried_wakesoffspawn_task_terminal_event), never at compose time — composing proves nothing reached the agent. Capacity pressure is notpendingbecause both wakes now dispatch withexecute_task(queue_on_capacity=True): the producer's opt-in puts a wake arriving at capacity on the durable backlog (queue_persistent, pilot or not), the push drain runs it when a slot frees, anddispatch_and_await_terminalwaits out the queue; only a full backlog iscapacity, and that stayspending._wake_filerreturns before the ending spawn onexpired; the expired row is still announced and read on the agent's next turn. Cancel and dismiss still wake (operator_ending).OperatorAskReceipttype), Workspace ask payload and Inbox card carrywake_state; the Reliability panel reads "Wakes when an ask ends: on/off" — and "unknown", with the switch disabled, until the GET has answered; the panel copy, the platform prompt, theask_operatordescription and the user docs say an answer or a cancel wakes the agent and an expiry does not, so skills stop saying "write me again after you approve".Merge-train follow-ups (pushed by the train)
test(ent695): golden fixture regenerated — twelveoperator_resume_enabled: 0 → nullrows plus_meta.regenerated_by.test(ent1108): the start-hook test stubs the ent#752 marker spawn, so no task is left on a closed loop fortest_ent752_marker_sync/test_2328_per_task_max_turns_wireto trip over.fix(asks):NO_TURN_ERROR_CODES+queue_on_capacity=True(above).fix(asks): carried answers marked at the terminal, not at compose (above); two module-binding leaks in the new tests fixed.feat(asks): expiry no longer wakes (above), with copy and docs;test(3247): the replace-ask expiry pin follows.fix(mcp):wake_stateon the receipt type.fix(ui): unknown state until the GET answers.test(ent1108):_agent_ready's hand-off pinned (red under areturn Truemutation).Test plan
tests/unit/test_ent1108_wake_default.py(14) +test_ent1108_deferred_wake.py(54) — red first on behaviour; mutations: getter coalesce, hook line, readiness gate and its hand-off, the no-turn set, compose-time marking each turn their tests redcheck_alembic_heads.py: 118 revisions, 1 head (0117_operator_queue_wake_state);check_alembic_parity.py(merge-base..HEAD): PASS, both tracks updatedreliabilityPanelWakeStatus.spec.js(4),operatorQueueEnding.spec.js,portalAskWakePending.mount.spec.jsmounted; raw-color and loading-gate ratchets unchanged;src/mcp-servertsc --noEmitclean,npm test1152/1154 (the 2 failures are the pre-existing real-transport tests, identical withtypes.tsat the base)Closes abilityai/trinity-enterprise#1108 (cross-repo: close manually at release)
🤖 Generated with Claude Code