Repository navigation
fix(wake): an agent's key keeps its execution reads while a wake turn runs (abilityai/trinity-enterprise#1216) - #4472
Conversation
…o the agent's key keeps its execution reads (Abilityai/trinity-enterprise#1216) When a run an agent delegated ends, the platform wakes the delegator with a `caller_wake` turn. That turn had nobody on its row, so `turn_actor` rated it a visitor's turn, and the ledger rule (`acting_turn_user_id`) then hid every execution row from the agent's own key for as long as the wake ran: `get_execution_result` answered 404 and the list reads came back empty, inside the wake turn too, which was woken to read that result. The wake now carries the callee row's person when that person rates `owner` on the delegator (`_standing_person`, rated with the real `turn_actor` over a row with no source agent), and nobody otherwise. The owner's own work wakes as an owner turn and reads at the full view. A wake for a shared person, a visitor, a deleted user or a person who cannot open the delegator is the no-person turn it was. No email goes on the row. The wake audit records the standing (`owner` / `none`). Known behaviour change: auto-memory follows the existing owner rule, so it is on for an owner-standing wake (it was off for every wake). Tests: `tests/unit/test_ent1216_wake_turn_reads.py` drives the real `/task` admission, the real `maybe_wake_caller`, the real ledger and `viewer_row_scope` on a real database. Before the fix it fails with `('share', 'visitor', None)` and read scope -1. Mutations: removing the hand-off of the person turns 5 tests red; carrying every person turns 4 red. Co-Authored-By: Claude Fable 5.2 <[email protected]>
…tyai/trinity-enterprise#1216) The notice quotes the callee's own words capped at 2,000 characters. The cut was silent, so a longer answer read as if the run itself had stopped mid-sentence. When the cap cut the text, the frame now ends the quote with `[cut here: the first N of M characters]`. The cut is measured after redaction, so a text that fits once its credentials are redacted carries no marker. Tests: three cases in `tests/unit/test_ent1102_caller_wake.py` (cut, fits, measured after redaction). Co-Authored-By: Claude Fable 5.2 <[email protected]>
|
@vybe this is the fix for the wake-turn read blindness you reported. Two things need your call: whether the shape is right (owner-standing wakes only; every other wake unchanged), and whether it goes into the next release candidate. The open questions are on the issue. |
dolho
left a comment
There was a problem hiding this comment.
/review — approve
Scope: clean. The diff does what abilityai/trinity-enterprise#1216 asks: an owner-tier wake carries the callee row's person, and every other wake carries nobody as before. The cut marker and the standing audit field are small and the PR body names them. Docs are updated (security.md §5d, the agent-to-agent flow).
Test coverage
| changed symbol | executed by | live consumer | verdict |
|---|---|---|---|
_standing_person |
test_ent1216_wake_turn_reads.py: owner, admin, shared, cannot-open, deleted, nobody, and turn_actor raising |
maybe_wake_caller → dispatch_and_await_terminal(source_user_id=…) |
✅ executed. Real /task admission, real ledger, real acting_turn_user_id / viewer_row_scope, on a real DB |
standing on the audit row |
test_the_audit_names_the_standing_and_never_the_person |
_audit → platform_audit_service.log |
✅ |
_summary_of / cut marker |
3 new tests in test_ent1102_caller_wake.py, including the after-redaction case |
_framed_wake |
✅ |
Fix mutation: the PR reports 6 of 13 red with the fix reverted, 5 red with the hand-off removed and 4 red with every person carried. I read the tests and they are behavioural, not source-text. I did not re-run them locally because this machine has no pytest env; CI pytest (head) was still pending when I approved.
Critical
None.
Informational
- I1 (confidence 5/10, pre-existing class):
turn_origin_user_idreturns the key owner's id wheneveracting_turnisNone, meaning noX-Trinity-Execution-Idheader ormanual. Say a share-person or visitor turn on A delegates without the header, for example a shellcurlwith the agent key. The callee row then records the owner, and after this PR the wake is also ratedownerand reads at the full view. Two things limit the impact: the wake's output goes back to A's own turn, not to the visitor, and while the visitor's own turn is still RUNNING the ledger still narrows. The root cause is inturn_origin_user_id, not here, so this is not a blocker. It may be worth noting as a residual in §5d. - I2 (nit): the cut marker
[cut here: the first N of M characters]mixes two measures. N is the length after redaction and M is the raw length, so when redaction shrinks the text, N + (M − N) does not describe the same text. Labelling M as "raw" would remove the ambiguity.
Clean categories
SQL (no new SQL), concurrency (pure read, then dispatch kwargs), auth (fails closed to nobody on any error; tier is computed with the real turn_actor, so the delegation rule cannot lift it), credentials (summary is still sanitized before the cap; no email on the row, per ent#886), enterprise disclosure (no paid-module detail in the docs), no new enum values.
LGTM. Approving.
Conflict in tests/registry.json only (both sides appended an entry); rebuilt from the merge stages: dev's entries plus this branch's new one. Co-Authored-By: Claude Fable 5.2 <[email protected]>
Summary
get_execution_resultanswered 404 andlist_recent_executions,get_schedule_executionsandget_agent_activity_summarycame back empty, inside the wake turn too. The wake turn was woken to read a result it could not read.caller_wake) was dispatched with nobody on its row.turn_actorrates such a row a visitor's turn, and the ledger rule (acting_turn_user_id) gives the agent's key no rows while a share turn with no platform user is running.owneron the delegating agent, and nobody otherwise. An owner's own work wakes as an owner turn and reads at the full view. Every other wake is exactly what it was.owner/none).What is not changed
A wake for a person the delegating agent is only shared with, for a visitor, and for a person who cannot open the delegating agent still carries nobody and still reads no rows. The callee row's person, rated afresh on the delegator, is not always where the delegating turn stood, and no column records the delegating execution, so that standing cannot be rebuilt without a migration. The same holds for the turns that resume an agent after an answered or ended ask and for the gated-request notice. That work is tracked in the private tracker.
Changes
src/backend/services/caller_wake_service.py—_standing_person(rated with the realturn_actorover a row with no source agent; anything unreadable carries nobody), the hand-off to the dispatch,standingon the audit row, the cut marker.tests/unit/test_ent1216_wake_turn_reads.py— new, 13 tests.tests/unit/test_ent1102_caller_wake.py— 3 cut-marker tests.tests/registry.json,docs/memory/architecture/security.md§5d,docs/memory/feature-flows/agent-to-agent-collaboration.md,docs/security-reports/cso-diff-2026-11-11-ent1216-wake-standing.{md,json}.No migration, no schema change, no new endpoint, no MCP or frontend change.
Behaviour change to know about
Auto-memory follows the existing owner rule, so it is on for an owner-standing wake. It was off for every wake.
Evidence
Unit, on a real database. The new test drives the real
/taskadmission (which writes the callee row), the realmaybe_wake_caller, the real ledger (get_running_turn_attribution) and the realacting_turn_user_id/viewer_row_scope. Only the wake's dispatch is replaced, by a writer that records the row from the kwargs it was handed.('share', 'visitor', None) == ('owner', None, None)and-1 is None.Live,
v1.0.5-rc2(af465288a) plus this change, PostgreSQL. With the delegating agent's own key:share/visitorownerget_execution_resultwhile the wake runssuccesswith the responselist_recent_executionswhile the wake runsstanding: ownerRegression. 60 related unit files: 2,727 passed; the only failures are 39 in
test_ent926_turn_tier_hook.py, which fail the same way on the untouched base on this machine. Pinned guards (301 files, CI flags, seed 12345): no test fails at head that does not also fail at the merge-base.Security.
/cso --diff: no findings at the gate. The one grant is owner standing for a wake whose delegation already ran with the owner's identity. A shared person's turn cannot dispatch as the owner, because the turn header comes from the process environment and wins over a model-typed id.Test plan
cd tests && pytest -p no:randomly unit/test_ent1216_wake_turn_reads.py unit/test_ent1102_caller_wake.py -qFixes abilityai/trinity-enterprise#1216
🤖 Generated with Claude Code